additional test for activate event handling

master^2
Michał 'rysiek' Woźniak 2024-03-13 03:35:19 +00:00
rodzic 935b9c27ac
commit c573810762
1 zmienionych plików z 10 dodań i 2 usunięć

Wyświetl plik

@ -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 = {