Files
Jeffrey PosnickandGitHub 7d4c4434a4 Enable prettier (#2929)
* Deps and config

* Prettier output

* Update hardcoded file sizes

* More file size updates
2021-08-26 14:57:20 -07:00

41 lines
1.2 KiB
JavaScript

/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
import {getCacheKeyForURL} from 'workbox-precaching/getCacheKeyForURL.mjs';
import {precache} from 'workbox-precaching/precache.mjs';
import {resetDefaultPrecacheController} from './resetDefaultPrecacheController.mjs';
describe(`getCacheKeyForURL()`, function () {
const sandbox = sinon.createSandbox();
beforeEach(async function () {
sandbox.restore();
resetDefaultPrecacheController();
// Spy on all added event listeners so they can be removed.
sandbox.spy(self, 'addEventListener');
});
afterEach(function () {
for (const args of self.addEventListener.args) {
self.removeEventListener(...args);
}
sandbox.restore();
});
it(`should return the expected cache keys for various URLs`, async function () {
precache(['/one', {url: '/two', revision: '1234'}]);
expect(getCacheKeyForURL('/one')).to.eql(`${location.origin}/one`);
expect(getCacheKeyForURL(`${location.origin}/two`)).to.eql(
`${location.origin}/two?__WB_REVISION__=1234`,
);
expect(getCacheKeyForURL('/not-precached')).to.not.exist;
});
});