Add "app.whenReady()" (#12652)

* Make "chai-as-promised" avaialble in tests

* Add "app.whenReady()"

Closes #9561.
This commit is contained in:
Alexey Kuzmin 2018-04-20 09:09:23 +02:00 committed by Samuel Attard
parent c7a0b419a9
commit fcc82ebd35
4 changed files with 41 additions and 0 deletions

View file

@ -1,4 +1,6 @@
const assert = require('assert')
const chai = require('chai')
const chaiAsPromised = require('chai-as-promised')
const ChildProcess = require('child_process')
const https = require('https')
const net = require('net')
@ -7,10 +9,13 @@ const path = require('path')
const {ipcRenderer, remote} = require('electron')
const {closeWindow} = require('./window-helpers')
const {expect} = chai
const {app, BrowserWindow, Menu, ipcMain} = remote
const isCI = remote.getGlobal('isCi')
chai.use(chaiAsPromised)
describe('electron module', () => {
it('does not expose internal modules to require', () => {
assert.throws(() => {
@ -903,4 +908,15 @@ describe('app module', () => {
v8Util.requestGarbageCollectionForTesting()
})
})
describe('whenReady', () => {
it('returns a Promise', () => {
expect(app.whenReady()).to.be.an.instanceOf(Promise)
})
it('becomes fulfilled if the app is already ready', () => {
assert(app.isReady())
return expect(app.whenReady()).to.be.eventually.fulfilled
})
})
})