(event)
| 23 | }; |
| 24 | |
| 25 | export const spyOnEvent = (event) => { |
| 26 | const promises = []; |
| 27 | extendLifetimePromises.set(event, promises); |
| 28 | |
| 29 | event.waitUntil = sinon.stub().callsFake((promise) => { |
| 30 | promises.push(promise); |
| 31 | }); |
| 32 | |
| 33 | if (event instanceof FetchEvent) { |
| 34 | event.respondWith = sinon.stub().callsFake((responseOrPromise) => { |
| 35 | const promise = Promise.resolve(responseOrPromise); |
| 36 | |
| 37 | eventResponses.set(event, promise); |
| 38 | promises.push(promise); |
| 39 | |
| 40 | // TODO(philipwalton): we cannot currently call the native |
| 41 | // `respondWith()` due to this bug in Firefox: |
| 42 | // https://bugzilla.mozilla.org/show_bug.cgi?id=1538756 |
| 43 | // FetchEvent.prototype.respondWith.call(event, responseOrPromise); |
| 44 | }); |
| 45 | } |
| 46 | }; |
| 47 | |
| 48 | export const dispatchAndWaitUntilDone = async (event) => { |
| 49 | spyOnEvent(event); |
no outgoing calls
no test coverage detected