electron/spec/window-helpers.js

20 строки
555 B
JavaScript
Исходник Обычный вид История

2018-09-13 19:10:51 +03:00
const { expect } = require('chai')
const { BrowserWindow } = require('electron').remote
2018-09-13 19:10:51 +03:00
const { emittedOnce } = require('./events-helpers')
exports.closeWindow = async (window = null,
2018-09-13 19:10:51 +03:00
{ 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)
}
}