forked from nightscout/cgm-remote-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenv.test.js
80 lines (58 loc) · 2.2 KB
/
env.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
'use strict';
require('should');
describe('env', function ( ) {
it('set thresholds', function () {
process.env.BG_HIGH = 200;
process.env.BG_TARGET_TOP = 170;
process.env.BG_TARGET_BOTTOM = 70;
process.env.BG_LOW = 60;
var env = require('../env')();
env.thresholds.bg_high.should.equal(200);
env.thresholds.bg_target_top.should.equal(170);
env.thresholds.bg_target_bottom.should.equal(70);
env.thresholds.bg_low.should.equal(60);
env.alarm_types.should.equal('simple');
delete process.env.BG_HIGH;
delete process.env.BG_TARGET_TOP;
delete process.env.BG_TARGET_BOTTOM;
delete process.env.BG_LOW;
});
it('handle screwed up thresholds in a way that will display something that looks wrong', function () {
process.env.BG_HIGH = 89;
process.env.BG_TARGET_TOP = 90;
process.env.BG_TARGET_BOTTOM = 95;
process.env.BG_LOW = 96;
var env = require('../env')();
env.thresholds.bg_high.should.equal(91);
env.thresholds.bg_target_top.should.equal(90);
env.thresholds.bg_target_bottom.should.equal(89);
env.thresholds.bg_low.should.equal(88);
env.alarm_types.should.equal('simple');
delete process.env.BG_HIGH;
delete process.env.BG_TARGET_TOP;
delete process.env.BG_TARGET_BOTTOM;
delete process.env.BG_LOW;
});
it('show the right plugins', function () {
process.env.SHOW_PLUGINS = 'iob';
process.env.ENABLE = 'iob cob';
var env = require('../env')();
env.defaults.showPlugins.should.containEql('iob');
env.defaults.showPlugins.should.containEql('delta');
env.defaults.showPlugins.should.containEql('direction');
env.defaults.showPlugins.should.containEql('upbat');
env.defaults.showPlugins.should.not.containEql('cob');
delete process.env.SHOW_PLUGINS;
delete process.env.ENABLE;
});
it('get extended settings', function () {
process.env.ENABLE = 'scaryplugin';
process.env.SCARYPLUGIN_DO_THING = 'yes';
var env = require('../env')();
env.isEnabled('scaryplugin').should.equal(true);
//Note the camelCase
env.extendedSettings.scaryplugin.doThing.should.equal('yes');
delete process.env.ENABLE;
delete process.env.SCARYPLUGIN_DO_THING;
});
});