From 38d65967429cb7fe99e34d1c65ad84c101b72a45 Mon Sep 17 00:00:00 2001 From: Sonu Kapoor Date: Fri, 31 Jul 2020 08:40:48 -0400 Subject: [PATCH] test(service-worker): add helper function remove individual cache (#36847) This commit adds a helper method to remove individual cached items. PR Close #36847 --- packages/service-worker/worker/test/happy_spec.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/service-worker/worker/test/happy_spec.ts b/packages/service-worker/worker/test/happy_spec.ts index 7506d11ad6..c54b04ea95 100644 --- a/packages/service-worker/worker/test/happy_spec.ts +++ b/packages/service-worker/worker/test/happy_spec.ts @@ -1762,6 +1762,16 @@ describe('Driver', () => { }); })(); +async function removeAssetFromCache( + scope: SwTestHarness, appVersionManifest: Manifest, assetPath: string) { + const assetGroupName = + appVersionManifest.assetGroups?.find(group => group.urls.includes(assetPath))?.name; + const cacheName = `${scope.cacheNamePrefix}:${sha1(JSON.stringify(appVersionManifest))}:assets:${ + assetGroupName}:cache`; + const cache = await scope.caches.open(cacheName); + return cache.delete(assetPath); +} + async function makeRequest( scope: SwTestHarness, url: string, clientId: string|null = 'default', init?: Object): Promise {