Created
March 27, 2017 00:32
-
-
Save zackargyle/2c59b9bc717678118349d4f952162254 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const makeServiceWorkerEnv = require('service-worker-mock'); | |
describe('Service worker', () => { | |
beforeEach(() => { | |
Object.assign(global, makeServiceWorkerEnv()); | |
jest.resetModules(); | |
}); | |
it('should delete old caches on activate', async () => { | |
require('../sw.js'); | |
// Create old cache | |
await self.caches.open('OLD_CACHE'); | |
expect(self.snapshot().caches.OLD_CACHE).toBeDefined(); | |
// Activate and verify old cache is removed | |
await self.trigger('activate'); | |
expect(self.snapshot().caches.OLD_CACHE).toBeUndefined(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment