kopia lustrzana https://gitlab.com/rysiekpl/libresilient
additional test for activate event handling
rodzic
935b9c27ac
commit
c573810762
|
@ -232,9 +232,9 @@ beforeAll(async ()=>{
|
|||
postMessage: window.clients.prototypePostMessage
|
||||
}
|
||||
},
|
||||
claim: async () => {
|
||||
claim: spy(async () => {
|
||||
return undefined
|
||||
},
|
||||
}),
|
||||
// the actual spy function must be possible to reference
|
||||
// but we want spy data per test, so we set it properly in beforeEach()
|
||||
prototypePostMessage: null
|
||||
|
@ -443,6 +443,14 @@ describe('service-worker', async () => {
|
|||
|
||||
window.test_id = 0
|
||||
|
||||
it("should call clients.claim() when activated", async () => {
|
||||
await import("../../service-worker.js?" + window.test_id);
|
||||
await self.dispatchEvent(new Event('install'))
|
||||
await self.waitForSWInstall()
|
||||
await self.dispatchEvent(new Event('activate'))
|
||||
assertSpyCalls(window.clients.claim, 1)
|
||||
})
|
||||
|
||||
it("should use default LibResilientConfig values when config.json is missing", async () => {
|
||||
|
||||
let mock_response_data = {
|
||||
|
|
Ładowanie…
Reference in New Issue