parent
b6e8d19313
commit
7217525da4
|
@ -114,8 +114,6 @@ import {SwTestHarness, SwTestHarnessBuilder} from '../testing/scope';
|
||||||
.withManifest(seqIncreasedManifest)
|
.withManifest(seqIncreasedManifest)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
const scope = new SwTestHarnessBuilder().withServerState(server).build();
|
|
||||||
|
|
||||||
|
|
||||||
describe('data cache', () => {
|
describe('data cache', () => {
|
||||||
let scope: SwTestHarness;
|
let scope: SwTestHarness;
|
||||||
|
@ -242,28 +240,16 @@ import {SwTestHarness, SwTestHarnessBuilder} from '../testing/scope';
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
async function makeRequest(scope: SwTestHarness, url: string, clientId?: string):
|
function makeRequest(scope: SwTestHarness, url: string, clientId?: string): Promise<string|null> {
|
||||||
Promise<string|null> {
|
const [resTextPromise, done] = makePendingRequest(scope, url, clientId);
|
||||||
const [resPromise, done] = scope.handleFetch(new MockRequest(url), clientId || 'default');
|
return done.then(() => resTextPromise);
|
||||||
await done;
|
}
|
||||||
const res = await resPromise;
|
|
||||||
if (res !== undefined) {
|
|
||||||
return res.text();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function makePendingRequest(scope: SwTestHarness, url: string, clientId?: string):
|
function makePendingRequest(
|
||||||
[Promise<string|null>, Promise<void>] {
|
scope: SwTestHarness, url: string, clientId?: string): [Promise<string|null>, Promise<void>] {
|
||||||
const [resPromise, done] = scope.handleFetch(new MockRequest(url), clientId || 'default');
|
const [resPromise, done] = scope.handleFetch(new MockRequest(url), clientId || 'default');
|
||||||
return [
|
return [
|
||||||
(async() => {
|
resPromise.then<string|null>(res => res ? res.text() : null),
|
||||||
const res = await resPromise;
|
done,
|
||||||
if (res !== undefined) {
|
];
|
||||||
return res.text();
|
}
|
||||||
}
|
|
||||||
return null;
|
|
||||||
})(),
|
|
||||||
done
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue