Function
makePushSubscriptionChangeEvent
(
oldSubscription: {
endpoint: string;
options?: { applicationServerKey?: ArrayBuffer | Uint8Array | string };
} | null,
newSubscription: {
endpoint: string;
options?: { applicationServerKey?: ArrayBuffer | Uint8Array | string };
toJSON: () => unknown;
} | null,
)
Source from the content-addressed store, hash-verified
| 334 | // Helper to build a minimal PushSubscriptionChangeEvent-like object. |
| 335 | // Mirrors the spec shape consumed by the service worker handler. |
| 336 | function makePushSubscriptionChangeEvent( |
| 337 | oldSubscription: { |
| 338 | endpoint: string; |
| 339 | options?: { applicationServerKey?: ArrayBuffer | Uint8Array | string }; |
| 340 | } | null, |
| 341 | newSubscription: { |
| 342 | endpoint: string; |
| 343 | options?: { applicationServerKey?: ArrayBuffer | Uint8Array | string }; |
| 344 | toJSON: () => unknown; |
| 345 | } | null, |
| 346 | ) { |
| 347 | let waitUntilPromise: Promise<unknown> = Promise.resolve(); |
| 348 | return { |
| 349 | oldSubscription, |
| 350 | newSubscription, |
| 351 | waitUntil: (p: Promise<unknown>) => { |
| 352 | waitUntilPromise = p; |
| 353 | }, |
| 354 | get _waitUntilPromise() { |
| 355 | return waitUntilPromise; |
| 356 | }, |
| 357 | }; |
| 358 | } |
| 359 | |
| 360 | describe("serviceWorker pushsubscriptionchange handler", () => { |
| 361 | const originalFetch = globalThis.fetch; |
Tested by
no test coverage detected