From 1aca54da06817ca628ccb5c7093753e88c2d6bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joost=20Z=C3=B6llner?= Date: Fri, 28 Sep 2018 09:43:24 +0200 Subject: [PATCH] refactor(service-worker): Code optimizations (#25860) - Add missing new line in tests - Add proper noop method in MockNotificationEvent PR Close #25860 --- packages/service-worker/test/comm_spec.ts | 7 ++++--- packages/service-worker/worker/testing/scope.ts | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/service-worker/test/comm_spec.ts b/packages/service-worker/test/comm_spec.ts index 8f739923c4..323c7afae9 100644 --- a/packages/service-worker/test/comm_spec.ts +++ b/packages/service-worker/test/comm_spec.ts @@ -303,14 +303,15 @@ import {async_fit, async_it} from './async'; ]); }); }); + describe('messagesClicked', () => { it('receives notification clicked messages', () => { - const sendMessage = (type: string, message: string) => - mock.sendMessage({type, data: {message}}); + const sendMessage = (type: string, action: string) => + mock.sendMessage({type, data: {action}}); const receivedMessages: string[] = []; push.messagesClicked.subscribe( - (msg: {message: string}) => receivedMessages.push(msg.message)); + (msg: {action: string}) => receivedMessages.push(msg.action)); sendMessage('NOTIFICATION_CLICK', 'this was a click'); sendMessage('NOT_IFICATION_CLICK', 'this was not a click'); diff --git a/packages/service-worker/worker/testing/scope.ts b/packages/service-worker/worker/testing/scope.ts index 4ecf148a69..5262257800 100644 --- a/packages/service-worker/worker/testing/scope.ts +++ b/packages/service-worker/worker/testing/scope.ts @@ -351,7 +351,7 @@ class MockPushEvent extends MockExtendableEvent { } class MockNotificationEvent extends MockExtendableEvent { constructor(private _notification: any, readonly action?: string) { super(); } - readonly notification = {...this._notification, close: () => { return; }}; + readonly notification = {...this._notification, close: () => undefined}; } class MockInstallEvent extends MockExtendableEvent {}