mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 23:10:29 +00:00
Add missing service-worker-mock trigger signatures (#38267)
These are undocumented, but they are needed to make some triggers useful.
This commit is contained in:
committed by
Mine Starks
parent
8850cc80da
commit
448d6d2922
Vendored
+4
@@ -42,6 +42,10 @@ declare global {
|
||||
* Used to trigger active listeners.
|
||||
*/
|
||||
function trigger(type: keyof ServiceWorkerGlobalScopeEventMap): Promise<void>;
|
||||
function trigger(name: 'fetch', request: string | Request): Promise<void>;
|
||||
function trigger(name: 'notificationclick' | 'notificationclose', args: Notification): Promise<void>;
|
||||
function trigger(name: 'push', args: Partial<PushEvent>): Promise<void>;
|
||||
function trigger(name: 'message', args: Partial<MessageEvent>): Promise<void>;
|
||||
|
||||
/**
|
||||
* Used to generate a snapshot of the service worker internals.
|
||||
|
||||
@@ -8,6 +8,18 @@ trigger('install');
|
||||
mock.trigger('install');
|
||||
trigger('fetch');
|
||||
mock.trigger('fetch');
|
||||
trigger('fetch', 'https://example.com');
|
||||
mock.trigger('fetch', 'https://example.com');
|
||||
trigger('fetch', new Request('https://example.com'));
|
||||
mock.trigger('fetch', new Request('https://example.com'));
|
||||
trigger('notificationclick', new Notification('Hello!'));
|
||||
mock.trigger('notificationclick', new Notification('Hello!'));
|
||||
trigger('notificationclose', new Notification('Hello!'));
|
||||
mock.trigger('notificationclose', new Notification('Hello!'));
|
||||
trigger('push', { data: null });
|
||||
mock.trigger('push', { data: null });
|
||||
trigger('message', { source: null });
|
||||
mock.trigger('message', { source: null });
|
||||
|
||||
const emitFetch = listeners.get('fetch') as EventListener;
|
||||
emitFetch(new Event('fetch'));
|
||||
|
||||
Reference in New Issue
Block a user