spec: initial spike of main-process based tests
This commit is contained in:
parent
2e89348541
commit
ca701bb9af
14 changed files with 656 additions and 332 deletions
26
spec-main/window-helpers.ts
Normal file
26
spec-main/window-helpers.ts
Normal 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
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue