MCPcopy
hub / github.com/angular/angular / initializeSwFor

Function initializeSwFor

packages/service-worker/worker/test/happy_spec.ts:1525–1546  ·  view source on GitHub ↗
(baseHref: string, initialCacheState = '{}')

Source from the content-addressed store, hash-verified

1523 };
1524
1525 const initializeSwFor = async (baseHref: string, initialCacheState = '{}') => {
1526 const newDistDir = dist.extend().addFile('/foo.txt', `this is foo v${++uid}`).build();
1527 const newManifest = createManifestWithBaseHref(baseHref, newDistDir);
1528 const newManifestHash = sha1(JSON.stringify(newManifest));
1529
1530 const serverState = new MockServerStateBuilder()
1531 .withRootDirectory(baseHref)
1532 .withStaticFiles(newDistDir)
1533 .withManifest(newManifest)
1534 .build();
1535
1536 const newScope = new SwTestHarnessBuilder(`http://localhost${baseHref}`)
1537 .withCacheState(initialCacheState)
1538 .withServerState(serverState)
1539 .build();
1540 const newDriver = new Driver(newScope, newScope, new CacheDatabase(newScope));
1541
1542 await makeRequest(newScope, newManifest.index, baseHref.replace(/\//g, '_'));
1543 await newDriver.initialized;
1544
1545 return [newScope, newManifestHash] as [SwTestHarness, string];
1546 };
1547
1548 beforeEach(() => {
1549 uid = 0;

Callers 1

happy_spec.tsFile · 0.85

Calls 12

sha1Function · 0.90
withManifestMethod · 0.80
withStaticFilesMethod · 0.80
withRootDirectoryMethod · 0.80
withServerStateMethod · 0.80
withCacheStateMethod · 0.80
makeRequestFunction · 0.70
buildMethod · 0.45
addFileMethod · 0.45
extendMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…