Skip to content

Commit 6ee87e4

Browse files
committed
Minimal ts changes to let the test run
1 parent 26a367b commit 6ee87e4

File tree

7 files changed

+19
-7
lines changed

7 files changed

+19
-7
lines changed

test/support/mocks/service-workers/models/MockClients.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export class MockClients implements Clients {
1010
return Promise.resolve(client || null);
1111
}
1212

13-
async matchAll(_options?: ClientQueryOptions): Promise<Client[]> {
14-
return this.clients;
13+
async matchAll<T extends ClientQueryOptions>(options?: T): Promise<ReadonlyArray<T["type"] extends "window" ? WindowClient : Client>> {
14+
return Object.freeze(this.clients) as ReadonlyArray<T["type"] extends "window" ? WindowClient : Client>;
1515
}
1616

1717
async openWindow(_url: string): Promise<WindowClient | null> {

test/support/mocks/service-workers/models/MockPushManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class MockPushManager implements PushManager {
1212
return this.subscription;
1313
}
1414

15-
public async permissionState(_options?: PushSubscriptionOptionsInit): Promise<PushPermissionState> {
15+
public async permissionState(_options?: PushSubscriptionOptionsInit): Promise<PermissionState> {
1616
return "granted";
1717
}
1818

test/support/mocks/service-workers/models/MockServiceWorker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class MockServiceWorker implements ServiceWorker {
2222
throw new NotImplementedError();
2323
}
2424

25-
postMessage(message: any, transfer: Array<Transferable> | PostMessageOptions): void {
25+
postMessage(message: any, transfer: Array<Transferable> | any): void {
2626
}
2727

2828
removeEventListener<K extends keyof ServiceWorkerEventMap>(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, options?: boolean | EventListenerOptions): void;

test/support/mocks/service-workers/models/MockServiceWorkerGlobalScope.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ export class MockServiceWorkerGlobalScope implements ServiceWorkerGlobalScope {
1818
return this.registration;
1919
}
2020

21+
readonly fonts: FontFaceSet;
22+
readonly crossOriginIsolated: boolean;
23+
reportError: (e: any) => void;
24+
structuredClone: (input: any) => any;
25+
2126
readonly caches: CacheStorage;
2227
readonly clients: Clients = new MockClients();
2328
readonly console: Console;
@@ -51,7 +56,7 @@ export class MockServiceWorkerGlobalScope implements ServiceWorkerGlobalScope {
5156
onrejectionhandled: ((this: WorkerGlobalScope, ev: PromiseRejectionEvent) => any) | null = null;
5257
onpush: ((this: ServiceWorkerGlobalScope, ev: PushEvent) => any) | null = null;
5358
onpushsubscriptionchange: ((this: ServiceWorkerGlobalScope, ev: PushSubscriptionChangeEvent) => any) | null = null;
54-
onsync: ((this: ServiceWorkerGlobalScope, ev: SyncEvent) => any) | null = null;
59+
onsync: ((this: ServiceWorkerGlobalScope, ev: Event) => any) | null = null;
5560
onunhandledrejection: ((this: WorkerGlobalScope, ev: PromiseRejectionEvent) => any) | null = null;
5661
queueMicrotask(callback: VoidFunction): void {}
5762

test/support/mocks/service-workers/models/MockServiceWorkerRegistration.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export class MockServiceWorkerRegistration implements ServiceWorkerRegistration
77
waiting: ServiceWorker | null;
88
onupdatefound: ((this: ServiceWorkerRegistration, ev: Event) => any) | null;
99
readonly pushManager: PushManager;
10-
readonly sync: SyncManager;
1110
navigationPreload: NavigationPreloadManager;
1211
updateViaCache: ServiceWorkerUpdateViaCache;
1312

test/support/mocks/service-workers/models/MockWorkerNavigator.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ export class MockWorkerNavigator implements WorkerNavigator {
88
public readonly userAgent: string
99
) {
1010
}
11+
mediaCapabilities: MediaCapabilities;
12+
clearAppBadge(): Promise<void> {
13+
throw new Error("Method not implemented.");
14+
}
15+
setAppBadge(contents?: unknown): Promise<void> {
16+
throw new Error("Method not implemented.");
17+
}
18+
locks: LockManager;
1119

1220
readonly hardwareConcurrency: number;
1321
readonly onLine: boolean;

test/unit/managers/SubscriptionManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ test(
477477

478478
// Set the initial datetime
479479
timemachine.config({
480-
timestamp: dateString
480+
timestamp: Date.parse(dateString)
481481
});
482482

483483
const initialSubscriptionOptions: PushSubscriptionOptions = {

0 commit comments

Comments
 (0)