Skip to content

Commit 1840250

Browse files
committed
fixup: serviceWorker test
1 parent eaba90e commit 1840250

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/serviceWorker.test.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import makeServiceWorkerEnv = require("service-worker-mock")
22
const makeFetchMock = require("service-worker-mock/fetch")
33

44
describe("serviceWorker", () => {
5+
let spy: jest.SpyInstance
56
beforeEach(() => {
67
Object.assign(
78
global,
@@ -11,10 +12,13 @@ describe("serviceWorker", () => {
1112
// fetch: sinon.stub().returns(Promise.resolve())
1213
)
1314
jest.resetModules()
15+
16+
spy = jest.spyOn(console, "log")
1417
})
1518

1619
afterEach(() => {
1720
jest.restoreAllMocks()
21+
spy.mockRestore()
1822
})
1923

2024
it("should add listeners", () => {
@@ -26,17 +30,15 @@ describe("serviceWorker", () => {
2630
})
2731

2832
it("should call the proper callbacks for 'install'", async () => {
29-
const consoleLogSpy = jest.spyOn(console, "log")
3033
require("../src/browser/serviceWorker.ts")
3134
await self.trigger("install")
32-
expect(consoleLogSpy).toHaveBeenCalledWith("[Service Worker] installed")
35+
expect(spy).toHaveBeenCalledWith("[Service Worker] installed")
3336
})
3437
it("should call the proper callbacks for 'activate'", async () => {
35-
const consoleLogSpy = jest.spyOn(console, "log")
3638
require("../src/browser/serviceWorker.ts")
3739
await self.trigger("activate")
3840

3941
// Activate serviceWorker
40-
expect(consoleLogSpy).toHaveBeenCalledWith("[Service Worker] activated")
42+
expect(spy).toHaveBeenCalledWith("[Service Worker] activated")
4143
})
4244
})

0 commit comments

Comments
 (0)