forked from nightscout/cgm-remote-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mmconnect.test.js
83 lines (73 loc) · 2.27 KB
/
mmconnect.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
/* jshint node: true */
/* globals describe, it */
'use strict';
var _ = require('lodash'),
should = require('should');
describe('mmconnect', function () {
var mmconnect = require('../lib/plugins/mmconnect');
var env = {
extendedSettings: {
mmconnect: {
// 'userName' for consistency with the bridge plugin
userName: 'nightscout'
, password: 'wearenotwaiting'
, sgvLimit: '99'
, interval: '12000'
, maxRetryDuration: 1024
, verbose: 'true'
}
}
};
describe('init()', function () {
it('should create a runner if env vars are present', function () {
var runner = mmconnect.init(env);
should.exist(runner);
should.exist(runner.run);
runner.run.should.be.instanceof(Function);
});
it('should not create a runner if any env vars are absent', function () {
[
{}
, {mmconnect: {}}
, {mmconnect: {userName: 'nightscout'}}
, {mmconnect: {password: 'wearenotwaiting'}}
].forEach(function (extendedSettings) {
should.not.exist(mmconnect.init({extendedSettings: extendedSettings}));
});
});
});
describe('getOptions()', function () {
it('should set the carelink client config from env', function () {
mmconnect.getOptions(env).should.have.properties({
username: 'nightscout'
, password: 'wearenotwaiting'
, sgvLimit: 99
, interval: 12000
, maxRetryDuration: 1024
, verbose: true
});
});
});
describe('rawDataEntry()', function () {
it('should generate a "carelink_raw" entry with sgs truncated and PII redacted', function () {
var data = {
'lastMedicalDeviceDataUpdateServerTime': 1445471797479
, 'sgs': _.range(10)
, 'firstName': 'sensitive'
, 'lastName': 'sensitive'
, 'medicalDeviceSerialNumber': 'sensitive'
};
var entry = mmconnect.rawDataEntry(data);
entry.should.have.properties({
'date': 1445471797479
, 'type': 'carelink_raw'
});
entry.data.should.have.properties({
'firstName': '<redacted>'
, 'lastName': '<redacted>'
, 'medicalDeviceSerialNumber': '<redacted>'
});
entry.data.sgs.length.should.equal(6);
});
});
});