From 4516c35fc0fffcf52a0feaa4f81f0c51264d7416 Mon Sep 17 00:00:00 2001 From: Josh Kasten Date: Fri, 19 Feb 2021 11:33:44 -0800 Subject: [PATCH] Small formating and naming cleanup --- src/managers/ServiceWorkerManager.ts | 2 +- .../models/MockServiceWorkerContainer.ts | 2 +- .../models/MockServiceWorkerContainerWithAPIBan.ts | 4 ++-- test/unit/helpers/page/ServiceWorkerUtilHelper.ts | 2 +- test/unit/meta/mockPushManager.ts | 11 +++++------ 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/managers/ServiceWorkerManager.ts b/src/managers/ServiceWorkerManager.ts index 2ed0b7470..13f9c07c6 100644 --- a/src/managers/ServiceWorkerManager.ts +++ b/src/managers/ServiceWorkerManager.ts @@ -86,7 +86,7 @@ export class ServiceWorkerManager { if (!serviceWorker) { return null; } - + const workerScriptPath = new URL(serviceWorker.scriptURL).pathname; const swFileName = new Path(workerScriptPath).getFileName(); diff --git a/test/support/mocks/service-workers/models/MockServiceWorkerContainer.ts b/test/support/mocks/service-workers/models/MockServiceWorkerContainer.ts index b19d2b5bd..27d4631f5 100644 --- a/test/support/mocks/service-workers/models/MockServiceWorkerContainer.ts +++ b/test/support/mocks/service-workers/models/MockServiceWorkerContainer.ts @@ -4,7 +4,7 @@ import { MockServiceWorkerRegistration } from "./MockServiceWorkerRegistration"; // abstract to indicate this isn't designed to be used directly as part of the tests. (expect for the meta one) // This is a generic mock. -// - no OneSignal specifics, see MockServiceWorkerContainerWithAPIBan +// - no OneSignal specifics, see MockServiceWorkerContainerWithAPIBan export abstract class MockServiceWorkerContainer implements ServiceWorkerContainer { protected _controller: ServiceWorker | null; get controller(): ServiceWorker | null { diff --git a/test/support/mocks/service-workers/models/MockServiceWorkerContainerWithAPIBan.ts b/test/support/mocks/service-workers/models/MockServiceWorkerContainerWithAPIBan.ts index f2c8313d0..aa6b87279 100644 --- a/test/support/mocks/service-workers/models/MockServiceWorkerContainerWithAPIBan.ts +++ b/test/support/mocks/service-workers/models/MockServiceWorkerContainerWithAPIBan.ts @@ -10,7 +10,7 @@ export class MockServiceWorkerContainerWithAPIBan extends MockServiceWorkerConta constructor() { super(); } - + get controller(): ServiceWorker | null { throw new Error("Don't use, assumes page control!"); } @@ -43,4 +43,4 @@ export class MockServiceWorkerContainerWithAPIBan extends MockServiceWorkerConta throw new Error("Don't use, assumes page control!"); } } -} \ No newline at end of file +} diff --git a/test/unit/helpers/page/ServiceWorkerUtilHelper.ts b/test/unit/helpers/page/ServiceWorkerUtilHelper.ts index 98e776782..7cacce4f8 100644 --- a/test/unit/helpers/page/ServiceWorkerUtilHelper.ts +++ b/test/unit/helpers/page/ServiceWorkerUtilHelper.ts @@ -31,4 +31,4 @@ test('getAvailableServiceWorker() - returns null - when no ServiceWorker', async t.falsy(ServiceWorkerUtilHelper.getAvailableServiceWorker(serviceWorkerRegistration)) }); -// See test/unit/manager/ServiceWorkerManager.ts for other tests that cover this class \ No newline at end of file +// See test/unit/manager/ServiceWorkerManager.ts for other tests that cover this class diff --git a/test/unit/meta/mockPushManager.ts b/test/unit/meta/mockPushManager.ts index 3d9e9dc15..92a13a1b5 100644 --- a/test/unit/meta/mockPushManager.ts +++ b/test/unit/meta/mockPushManager.ts @@ -53,13 +53,12 @@ test('mock push manager should subscribe successfully', async t => { test('mock push manager should unsubscribe successfully', async t => { const registration = await getServiceWorkerRegistration(); - - const subscribedSubscription = await registration!.pushManager.subscribe({ + const subscription = await registration!.pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: Random.getRandomUint8Array(64).buffer }); - await subscribedSubscription.unsubscribe(); - const subscription = await registration!.pushManager.getSubscription(); - t.is(subscription, null); -}); + await subscription.unsubscribe(); + const subscriptionToCheck = await registration!.pushManager.getSubscription(); + t.is(subscriptionToCheck, null); +});