diff --git a/packages/service-worker/test/comm_spec.ts b/packages/service-worker/test/comm_spec.ts index bada39f98c..8f739923c4 100644 --- a/packages/service-worker/test/comm_spec.ts +++ b/packages/service-worker/test/comm_spec.ts @@ -313,7 +313,7 @@ import {async_fit, async_it} from './async'; (msg: {message: string}) => receivedMessages.push(msg.message)); sendMessage('NOTIFICATION_CLICK', 'this was a click'); - sendMessage('NOT_OTIFICATION_CLICK', 'this was not a click'); + sendMessage('NOT_IFICATION_CLICK', 'this was not a click'); sendMessage('NOTIFICATION_CLICK', 'this was a click too'); sendMessage('KCILC_NOITACIFITON', 'this was a KCILC_NOITACIFITON message'); diff --git a/packages/service-worker/test/integration_spec.ts b/packages/service-worker/test/integration_spec.ts index f9e4b3300b..de1a62a8ab 100644 --- a/packages/service-worker/test/integration_spec.ts +++ b/packages/service-worker/test/integration_spec.ts @@ -135,11 +135,12 @@ const serverUpdate = scope.updateServerState(serverUpdate); const gotNotificationClick = (async() => { - const event = await obsToSinglePromise(push.messagesClicked); - expect(event).toEqual({action: 'clicked', notification: {clicked: true}}); + const event: any = await obsToSinglePromise(push.messagesClicked); + expect(event.action).toEqual('clicked'); + expect(event.notification.title).toEqual('This is a test'); })(); - await scope.handleClick({clicked: true}, 'clicked'); + await scope.handleClick({title: 'This is a test'}, 'clicked'); await gotNotificationClick; }); }); diff --git a/packages/service-worker/worker/src/service-worker.d.ts b/packages/service-worker/worker/src/service-worker.d.ts index b49bf82944..e0f8cefb13 100644 --- a/packages/service-worker/worker/src/service-worker.d.ts +++ b/packages/service-worker/worker/src/service-worker.d.ts @@ -72,7 +72,7 @@ interface ActivateEvent extends ExtendableEvent {} // Notification API -interface NotificationEvent { +interface NotificationEvent extends ExtendableEvent { action: string; notification: Notification; } @@ -83,8 +83,6 @@ interface PushEvent extends ExtendableEvent { data: PushMessageData; } -interface NotificationClickEvent extends NotificationEvent, ExtendableEvent {} - interface PushMessageData { arrayBuffer(): ArrayBuffer; blob(): Blob; @@ -116,7 +114,7 @@ interface ServiceWorkerGlobalScope { addEventListener(event: 'fetch', fn: (event?: FetchEvent) => any): void; addEventListener(event: 'install', fn: (event?: ExtendableEvent) => any): void; addEventListener(event: 'push', fn: (event?: PushEvent) => any): void; - addEventListener(event: 'notificationclick', fn: (event?: NotificationClickEvent) => any): void; + addEventListener(event: 'notificationclick', fn: (event?: NotificationEvent) => any): void; addEventListener(event: 'sync', fn: (event?: SyncEvent) => any): void; fetch(request: Request|string): Promise; diff --git a/packages/service-worker/worker/test/happy_spec.ts b/packages/service-worker/worker/test/happy_spec.ts index 24deaa42b5..c0b84a990a 100644 --- a/packages/service-worker/worker/test/happy_spec.ts +++ b/packages/service-worker/worker/test/happy_spec.ts @@ -593,10 +593,12 @@ const manifestUpdateHash = sha1(JSON.stringify(manifestUpdate)); expect(await makeRequest(scope, '/foo.txt')).toEqual('this is foo'); await driver.initialized; await scope.handleClick({title: 'This is a test', body: 'Test body'}, 'button'); - expect(scope.clients.getMock('default') !.messages).toEqual([{ - type: 'NOTIFICATION_CLICK', - data: {action: 'button', notification: {title: 'This is a test', body: 'Test body'}} - }]); + const message: any = scope.clients.getMock('default') !.messages[0]; + + expect(message.type).toEqual('NOTIFICATION_CLICK'); + expect(message.data.action).toEqual('button'); + expect(message.data.notification.title).toEqual('This is a test'); + expect(message.data.notification.body).toEqual('Test body'); }); async_it('prefetches updates to lazy cache when set', async() => {