fix: reject with error when url not loaded (#16571)

* fix: reject with error when url not loaded

* improve descriptive spec naming
This commit is contained in:
Shelley Vohr 2019-01-28 14:42:36 -08:00 committed by GitHub
parent 138ba53511
commit a25f82c91f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View file

@ -229,13 +229,18 @@ describe('webContents module', () => {
})
describe('ServiceWorker APIs', () => {
it('can successfully register a ServiceWorker', async () => {
it('can successfully check for presence of a ServiceWorker', async () => {
await w.loadFile(path.join(fixtures, 'api', 'service-worker', 'service-worker.html'))
const hasSW = await w.webContents.hasServiceWorker()
expect(hasSW).to.be.true()
})
it('can successfully register a ServiceWorker (callback)', (done) => {
it('throws properly for invalid url', async () => {
const promise = w.webContents.hasServiceWorker()
return expect(promise).to.be.eventually.rejectedWith(Error, 'URL invalid or not yet loaded.')
})
it('can successfully check for presence of a ServiceWorker (callback)', (done) => {
w.loadFile(path.join(fixtures, 'api', 'service-worker', 'service-worker.html')).then(() => {
w.webContents.hasServiceWorker(hasSW => {
expect(hasSW).to.be.true()