()
| 55 | }; |
| 56 | |
| 57 | const setup = function () { |
| 58 | const sendToInstallationSpy = jasmine.createSpy(); |
| 59 | |
| 60 | const pushAdapter = { |
| 61 | send: function (body, installations) { |
| 62 | const badge = body.data.badge; |
| 63 | const promises = installations.map(installation => { |
| 64 | sendToInstallationSpy(installation); |
| 65 | |
| 66 | if (installation.deviceType == 'ios') { |
| 67 | expect(installation.badge).toEqual(badge); |
| 68 | expect(installation.originalBadge + 1).toEqual(installation.badge); |
| 69 | } else { |
| 70 | expect(installation.badge).toBeUndefined(); |
| 71 | } |
| 72 | return Promise.resolve({ |
| 73 | err: null, |
| 74 | device: installation, |
| 75 | transmitted: true, |
| 76 | }); |
| 77 | }); |
| 78 | return Promise.all(promises); |
| 79 | }, |
| 80 | getValidPushTypes: function () { |
| 81 | return ['ios', 'android']; |
| 82 | }, |
| 83 | }; |
| 84 | |
| 85 | return reconfigureServer({ |
| 86 | appId: Parse.applicationId, |
| 87 | masterKey: Parse.masterKey, |
| 88 | serverURL: Parse.serverURL, |
| 89 | push: { |
| 90 | adapter: pushAdapter, |
| 91 | }, |
| 92 | }) |
| 93 | .then(() => { |
| 94 | const installations = []; |
| 95 | while (installations.length != 10) { |
| 96 | const installation = new Parse.Object('_Installation'); |
| 97 | installation.set('installationId', 'installation_' + installations.length); |
| 98 | installation.set('deviceToken', 'device_token_' + installations.length); |
| 99 | installation.set('badge', installations.length); |
| 100 | installation.set('originalBadge', installations.length); |
| 101 | installation.set('deviceType', 'ios'); |
| 102 | installations.push(installation); |
| 103 | } |
| 104 | return Parse.Object.saveAll(installations); |
| 105 | }) |
| 106 | .then(() => { |
| 107 | return { |
| 108 | sendToInstallationSpy, |
| 109 | }; |
| 110 | }); |
| 111 | }; |
| 112 | |
| 113 | describe('Parse.Push', () => { |
| 114 | it_id('d1e591c4-2b21-466b-9ee2-5be467b6b771')(it)('should properly send push', async () => { |
no test coverage detected