forked from nightscout/cgm-remote-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbridge.test.js
83 lines (66 loc) · 1.78 KB
/
bridge.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
80
81
82
83
'use strict';
var should = require('should');
describe('bridge', function ( ) {
var bridge = require('../lib/plugins/bridge');
var env = {
extendedSettings: {
bridge: {
userName: 'nightscout'
, password: 'wearenotwaiting'
, interval: 60000
}
}
};
it('be creatable', function () {
var configed = bridge(env);
should.exist(configed);
should.exist(configed.startEngine);
should.exist(configed.startEngine.call);
});
it('set options from env', function () {
var opts = bridge.options(env);
should.exist(opts);
opts.login.accountName.should.equal('nightscout');
opts.login.password.should.equal('wearenotwaiting');
opts.interval.should.equal(60000);
});
it('store entries from share', function (done) {
var mockEntries = {
create: function mockCreate (err, callback) {
callback(null);
done();
}
};
bridge.bridged(mockEntries)(null);
});
it('set too low bridge interval option from env', function () {
var tooLowInterval = {
extendedSettings: {
bridge: { interval: 900 }
}
};
var opts = bridge.options(tooLowInterval);
should.exist(opts);
opts.interval.should.equal(156000);
});
it('set too high bridge interval option from env', function () {
var tooHighInterval = {
extendedSettings: {
bridge: { interval: 500000 }
}
};
var opts = bridge.options(tooHighInterval);
should.exist(opts);
opts.interval.should.equal(156000);
});
it('set no bridge interval option from env', function () {
var noInterval = {
extendedSettings: {
bridge: { }
}
};
var opts = bridge.options(noInterval);
should.exist(opts);
opts.interval.should.equal(156000);
});
});