Created
March 6, 2017 22:12
-
-
Save gauntface/04e0c196fb5fc62fbfede3760b2247fb to your computer and use it in GitHub Desktop.
Testing a fake push event.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it('should be able to test a push event', function() { | |
| const pushData = { | |
| title: 'Example Title.', | |
| body: 'Example Body.', | |
| }; | |
| return new Promise((resolve, reject) => { | |
| const fakePushEvent = new PushEvent('push', { | |
| data: JSON.stringify(pushData), | |
| }); | |
| // Override waitUntil so we can detect when the notification | |
| // has been show by the push event. | |
| fakePushEvent.waitUntil = (promise) => { | |
| promise.then(resolve, reject); | |
| }; | |
| self.dispatchEvent(fakePushEvent); | |
| }) | |
| .then(() => { | |
| // TODO: Test what the push event had done | |
| }) | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment