Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use idb 7 for products using shared idb library #6154

Merged
merged 7 commits into from
May 4, 2022
Prev Previous commit
Next Next commit
Fix typing issue in messaging
  • Loading branch information
hsubox76 committed Apr 15, 2022
commit bde166b009653b5525e6697d9d9cb0b58558f55f
16 changes: 13 additions & 3 deletions packages/messaging/src/listeners/sw-listeners.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
} from '../interfaces/internal-message-payload';
import {
NotificationEvent,
PushSubscriptionChangeEvent,
ServiceWorkerGlobalScope,
ServiceWorkerGlobalScopeEventMap,
WindowClient
Expand Down Expand Up @@ -427,9 +428,9 @@ describe('SwController', () => {

describe('onSubChange', () => {
it('calls deleteToken if there is no new subscription', async () => {
const event = makeEvent('pushsubscriptionchange', {
const event = makeFakePushSubscriptionChangeEvent({
oldSubscription: new FakePushSubscription(),
newSubscription: undefined
newSubscription: null
});

await callEventListener(event);
Expand All @@ -439,7 +440,7 @@ describe('SwController', () => {
});

it('calls deleteToken and getToken if subscription changed', async () => {
const event = makeEvent('pushsubscriptionchange', {
const event = makeFakePushSubscriptionChangeEvent({
oldSubscription: new FakePushSubscription(),
newSubscription: new FakePushSubscription()
});
Expand Down Expand Up @@ -474,3 +475,12 @@ function makeEvent<K extends keyof ServiceWorkerGlobalScopeEventMap>(
Object.assign(event, data);
return event as unknown as ServiceWorkerGlobalScopeEventMap[K];
}

function makeFakePushSubscriptionChangeEvent(data: {
newSubscription: PushSubscription | null,
oldSubscription: PushSubscription | null
}): PushSubscriptionChangeEvent {
const event = new FakeEvent('pushsubscriptionchange');
Object.assign(event, data);
return event as unknown as PushSubscriptionChangeEvent;
}