forked from matt-kruse/find-my-iphone
-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.js
79 lines (66 loc) · 1.86 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
var icloud = require("./index").findmyphone;
var assert = require("assert");
//[email protected] apple_password=somePassword mocha test
describe('Logged in: ', function() {
var device;
before(function(done) {
this.timeout(30000);
if (!process.env.hasOwnProperty("apple_id")) {
console.error("Missing apple_id environmental variable");
}
if (!process.env.hasOwnProperty("apple_password")) {
console.error("Missing apple_password environmental variable");
}
icloud.apple_id = process.env.apple_id;
icloud.password = process.env.apple_password;
icloud.cookieFileStore = "icloud.cookie";
assert(icloud.apple_id);
assert(icloud.password);
icloud.getDevices(function(error, devices) {
assert(!error);
assert(devices);
assert(devices.length > 0);
devices.forEach(function(d) {
if (device == undefined && d.location && d.lostModeCapable) {
device = d;
}
});
assert(device);
done();
});
});
it('should get distance / driving time', function(done) {
icloud.getDistanceOfDevice(device, 38.8977, -77.0366, function(err, result) {
assert(result.distance.value > 0);
assert(result.duration.value > 0);
console.log(result.distance.text);
console.log(result.duration.text);
done();
});
});
it('should get location', function(done) {
this.timeout(30000);
icloud.getLocationOfDevice(device, function(error, location) {
assert(!error);
assert(location);
done();
});
});
it('should send alert', function(done) {
this.timeout(30000);
icloud.alertDevice(device.id, function(error) {
assert(!error);
done();
});
});
it('should alert with legacy api', function() {
this.timeout(30000);
var find = require('./index');
it('should send legacy alert', function(done) {
find(icloud.apple_id, icloud.password, null, function(error) {
assert(!error);
done();
});
});
});
});