refactor(service-worker): Code optimizations (#25860)

- Add missing new line in tests
- Add proper noop method in MockNotificationEvent

PR Close #25860
This commit is contained in:
Joost Zöllner 2018-09-28 09:43:24 +02:00 committed by Kara Erickson
parent f5d5a3df59
commit 1aca54da06
2 changed files with 5 additions and 4 deletions

View File

@ -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');

View File

@ -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 {}