-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes problems related to increment badge
- name conventions are aweful in PushController - properly looks at the badge into body.data instead of body - We may want to refactor that as it's confusing to use a full body
- Loading branch information
1 parent
4259c5d
commit c582225
Showing
3 changed files
with
87 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
describe('Parse.Push', () => { | ||
it('should properly send push', (done) => { | ||
var pushAdapter = { | ||
send: function(body, installations) { | ||
let badge = body.data.badge; | ||
installations.forEach((installation) => { | ||
if (installation.deviceType == "ios") { | ||
expect(installation.badge).toEqual(badge); | ||
expect(installation.originalBadge+1).toEqual(installation.badge); | ||
} else { | ||
expect(installation.badge).toBeUndefined(); | ||
} | ||
}); | ||
return Promise.resolve({ | ||
body: body, | ||
installations: installations | ||
}); | ||
}, | ||
getValidPushTypes: function() { | ||
return ["ios", "android"]; | ||
} | ||
} | ||
setServerConfiguration({ | ||
appId: Parse.applicationId, | ||
masterKey: Parse.masterKey, | ||
serverURL: Parse.serverURL, | ||
push: { | ||
adapter: pushAdapter | ||
} | ||
}); | ||
var installations = []; | ||
while(installations.length != 10) { | ||
var installation = new Parse.Object("_Installation"); | ||
installation.set("installationId", "installation_"+installations.length); | ||
installation.set("deviceToken","device_token_"+installations.length) | ||
installation.set("badge", installations.length); | ||
installation.set("originalBadge", installations.length); | ||
installation.set("deviceType", "ios"); | ||
installations.push(installation); | ||
} | ||
Parse.Object.saveAll(installations).then(() => { | ||
return Parse.Push.send({ | ||
where: { | ||
deviceType: 'ios' | ||
}, | ||
data: { | ||
badge: 'Increment', | ||
alert: 'Hello world!' | ||
} | ||
}, {useMasterKey: true}); | ||
}) | ||
.then(() => { | ||
done(); | ||
}, (err) => { | ||
console.error(err); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file contains 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
This file contains 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