MCPcopy Index your code
hub / github.com/coder/coder / makePushSubscriptionChangeEvent

Function makePushSubscriptionChangeEvent

site/src/serviceWorker.test.ts:336–358  ·  view source on GitHub ↗
(
	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.
336function 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
360describe("serviceWorker pushsubscriptionchange handler", () => {
361 const originalFetch = globalThis.fetch;

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected