Skip to content

Commit

Permalink
reinstate sw tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Jan 21, 2018
1 parent df6a702 commit 70ae275
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion test/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,28 @@ describe('no real fetch', function () {
fetchMock.realFetch = realFetchCache;
window.fetch = fetchCache;
});
});
});

describe('service worker', () => {
it('should work within a service worker', () => {
return navigator.serviceWorker && navigator.serviceWorker.register('__sw.js')
.then(registration => {
return new Promise((resolve, reject) => {
if (registration.installing) {
registration.installing.onstatechange = function () {
if (this.state === 'activated') {
resolve();
}
}
} else {
reject('No idea what happened');
}
})
.then(() => {
expect(true).to.be.true;
return navigator.serviceWorker.getRegistration()
.then(registration => registration ? registration.unregister() : false);
})
})
})
})

0 comments on commit 70ae275

Please sign in to comment.