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

53 lines
1.8 KiB
JavaScript

/*
Copyright 2018 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.
*/
const expect = require('chai').expect;
const activateAndControlSW = require('../../../infra/testing/activate-and-control');
const cleanSWEnv = require('../../../infra/testing/clean-sw');
const runInSW = require('../../../infra/testing/comlink/node-interface');
describe(`[workbox-strategies] NetworkOnly Requests`, function () {
const baseURL = `${global.__workbox.server.getAddress()}/test/workbox-strategies/static/network-only/`;
beforeEach(async function () {
// Navigate to our test page and clear all caches before this test runs.
await cleanSWEnv(global.__workbox.webdriver, `${baseURL}integration.html`);
});
it(`should respond with a non-cached entry`, async function () {
const swURL = `${baseURL}sw.js`;
// Wait for the service worker to register and activate.
await activateAndControlSW(swURL);
let response = await global.__workbox.webdriver.executeAsyncScript((cb) => {
fetch(`/__WORKBOX/uniqueValue`)
.then((response) => response.text())
.then((responseBody) => cb(responseBody))
.catch((err) => cb(err.message));
});
const firstResponse = response.trim();
expect(firstResponse).to.not.eql('Cached');
await runInSW('clearAllCaches');
response = await global.__workbox.webdriver.executeAsyncScript((cb) => {
fetch(`/__WORKBOX/uniqueValue`)
.then((response) => response.text())
.then((responseBody) => cb(responseBody))
.catch((err) => cb(err.message));
});
const secondResponse = response.trim();
expect(secondResponse).to.not.eql(firstResponse);
const keys = await runInSW('cachesKeys');
expect(keys).to.eql([]);
});
});