spec: initial spike of main-process based tests

This commit is contained in:
Samuel Attard 2019-03-10 15:38:44 -07:00
parent 2e89348541
commit ca701bb9af
No known key found for this signature in database
GPG key ID: 191FEF027779CC6C
14 changed files with 656 additions and 332 deletions

View file

@ -0,0 +1,26 @@
import { expect } from 'chai'
import { BrowserWindow, WebContents } from 'electron'
import { emittedOnce } from './events-helpers';
export const closeWindow = async (
window: BrowserWindow | null = null,
{ assertNotWindows } = { assertNotWindows: true }
) => {
if (window && !window.isDestroyed()) {
const isClosed = emittedOnce(window, 'closed')
window.setClosable(true)
window.close()
await isClosed
}
if (assertNotWindows) {
expect(BrowserWindow.getAllWindows()).to.have.lengthOf(0)
}
}
exports.waitForWebContentsToLoad = async (webContents: WebContents) => {
const didFinishLoadPromise = emittedOnce(webContents, 'did-finish-load')
if (webContents.isLoadingMainFrame()) {
await didFinishLoadPromise
}
}