-
Notifications
You must be signed in to change notification settings - Fork 73.1k
Expand file tree
/
Copy pathopenaps.missingPill.test.js
More file actions
63 lines (55 loc) · 2.34 KB
/
openaps.missingPill.test.js
File metadata and controls
63 lines (55 loc) · 2.34 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'use strict';
const _ = require('lodash');
const should = require('should');
const helper = require('./inithelper')();
const openaps = require('../lib/plugins/openaps')(helper.getctx());
const sandbox = require('../lib/sandbox')(helper.getctx());
// Load test data
const missingRateOnLastEnacted = require('./data/missingRateOnLastEnacted.json');
const workingStatus = require('./data/statusWithWorkingForecast.json');
describe('OpenAPS Visualization Tests', function () {
let ctx, now;
beforeEach(function () {
let top_ctx = helper.getctx();
now = top_ctx.moment(missingRateOnLastEnacted[0].created_at);
_.forEach(missingRateOnLastEnacted, function updateMills (status) {
status.mills = top_ctx.moment(status.created_at).valueOf();
});
_.forEach(workingStatus, function updateMills (status) {
status.mills = top_ctx.moment(status.created_at).valueOf();
});
ctx = {
settings: {
units: 'mg/dl',
},
pluginBase: {
updatePillText: function mockedUpdatePillText(plugin, options) {
options.label.should.equal('OpenAPS ⌁');
}
, addForecastPoints: function mockAddForecastPoints (points) {
points.length.should.greaterThan(100);
}
},
language: top_ctx.language,
levels: top_ctx.levels,
};
});
it('should correctly generate pill and prediction lines for working status', function (done) {
const sbx = sandbox.clientInit(ctx, now.valueOf(), { devicestatus: workingStatus });
openaps.setProperties(sbx);
openaps.updateVisualisation(sbx);
const result = sbx.properties.openaps;
should.exist(result.lastPredBGs);
result.lastPredBGs.UAM.should.be.an.Array();
done();
});
it('should correctly generate pill and prediction lines for status without rate on last enacted', function (done) {
const sbx = sandbox.clientInit(ctx, now.valueOf(), { devicestatus: missingRateOnLastEnacted });
openaps.setProperties(sbx);
openaps.updateVisualisation(sbx);
const result = sbx.properties.openaps;
should.exist(result.lastPredBGs);
result.lastPredBGs.UAM.should.be.an.Array();
done();
});
});