electron/spec/window-helpers.js
2018-09-14 14:57:01 +10:00

19 lines
555 B
JavaScript

const { expect } = require('chai')
const { BrowserWindow } = require('electron').remote
const { emittedOnce } = require('./events-helpers')
exports.closeWindow = async (window = null,
{ assertSingleWindow } = { assertSingleWindow: true }) => {
const windowExists = (window !== null) && !window.isDestroyed()
if (windowExists) {
const isClosed = emittedOnce(window, 'closed')
window.setClosable(true)
window.close()
await isClosed
}
if (assertSingleWindow) {
expect(BrowserWindow.getAllWindows()).to.have.lengthOf(1)
}
}