forked from ClearBlade/JavaScript-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeviceSpec.js
More file actions
45 lines (43 loc) · 1.16 KB
/
DeviceSpec.js
File metadata and controls
45 lines (43 loc) · 1.16 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
41
42
43
44
45
/*
* JavaScript tests to test the device table functionality
*/
describe("ClearBlade Device", function(){
it("gets device info", function() {
var device = cb.Device();
var expectedData = {
method: 'GET',
endpoint: "api/v/2/devices/fakeSystemKey/fakeName",
URI: undefined,
user: {
authToken: "testUserToken"
}
};
var callNum = ClearBlade.request.calls.count();
device.getDeviceByName("fakeName", function (err, body){
expect(err).toBeNull();
expect(ClearBlade.request.calls.argsFor(callNum)[0]).toEqual(expectedData);
});
});
it("Updates a device's information", function () {
var device = cb.Device();
var expectedData = {
method: 'PUT',
endpoint: "api/v/2/devices/fakeSystemKey/fakeName",
URI: undefined,
body: {
state: "on",
causeTrigger: false
},
user: {
authToken: "testUserToken"
}
};
var callNum = ClearBlade.request.calls.count();
device.updateDevice("fakeName", {state:"on"}, false, function (err, body) {
expect(err).toBeNull();
expect(ClearBlade.request.calls.argsFor(callNum)[0]).toEqual(expectedData);
});
});
});