-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPush.test.ts
More file actions
40 lines (38 loc) · 1.14 KB
/
Push.test.ts
File metadata and controls
40 lines (38 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* Tests for the push messaging components of the ClearBlade JavaScript SDK
*/
import { cb, platformUrl, systemKey } from "./utils";
describe("ClearBlade Push messaging", function() {
// cb.init({ systemKey, systemSecret: "fake" });
it("sends a push message", function() {
var users = ["user1", "user2", "user3"],
payload = {
// I have no idea what's supposed to go here
alert: "hello"
},
appId = "someIDSuppliedByApple",
callNum = ClearBlade.request.mock.calls.length,
expectedData = {
method: "POST",
endpoint: `api/v/1/push/${systemKey}`,
URI: platformUrl,
body: {
cbids: ["user1", "user2", "user3"],
"apple-message": JSON.stringify({
aps: {
alert: "hello"
}
}),
appid: "someIDSuppliedByApple"
},
user: {
email: "test@fake.com",
authToken: "testUserToken"
}
};
cb.sendPush(users, payload, appId, function(err, data) {
expect(err).toBeNull();
expect(ClearBlade.request.mock.calls[callNum][0]).toEqual(expectedData);
});
});
});