-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.js
44 lines (37 loc) · 1011 Bytes
/
test.js
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
var icloud = require("./index");
var assert = require("assert");
icloudSettingsFile = "settings.json";
(() => {
var device;
icloud.icloudSettingsFile = icloudSettingsFile;
assert(icloud.icloudSettingsFile);
icloud.getDevices(function(error, devices) {
assert(!error);
assert(devices);
assert(devices.length > 0);
devices.forEach(function(d) {
if (device == undefined && d.location && d.lostModeCapable) {
console.log(d);
device = d;
}
});
assert(device);
});
setTimeout(() => {
icloud.getDistanceOfDevice(device, 51.9189046, 19.1343786, function(error, result) {
assert(!error);
assert(result.distance.value > 0);
assert(result.duration.value > 0);
console.log(result.distance.text);
console.log(result.duration.text);
});
icloud.getLocationOfDevice(device, function(error, location) {
assert(!error);
assert(location);
console.log(location);
});
icloud.alertDevice(device.id, function(error) {
assert(!error);
});
}, 15000);
})();