2018-06-21 14:43:15 +00:00
|
|
|
const {expect} = require('chai')
|
2016-11-29 19:06:22 +00:00
|
|
|
const {BrowserWindow} = require('electron').remote
|
|
|
|
|
2018-06-21 14:43:15 +00:00
|
|
|
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)
|
2016-08-03 19:47:53 +00:00
|
|
|
}
|
|
|
|
}
|