forked from nightscout/cgm-remote-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
careportal.test.js
92 lines (68 loc) · 2.09 KB
/
careportal.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
84
85
86
87
88
89
90
91
92
'use strict';
require('should');
var benv = require('benv');
var read = require('fs').readFileSync;
var serverSettings = require('./fixtures/default-server-settings');
var nowData = {
sgvs: [
{ mgdl: 100, mills: Date.now(), direction: 'Flat', type: 'sgv' }
]
, treatments: []
};
describe('client', function ( ) {
this.timeout(30000); // TODO: see why this test takes longer on Travis to complete
var self = this;
var headless = require('./fixtures/headless')(benv, this);
before(function (done) {
done( );
});
after(function (done) {
done( );
});
beforeEach(function (done) {
headless.setup({mockAjax: true}, done);
});
afterEach(function (done) {
headless.teardown( );
done( );
});
it ('open careportal, and enter a treatment', function (done) {
var client = window.Nightscout.client;
var hashauth = require('../lib/hashauth');
hashauth.init(client,$);
hashauth.verifyAuthentication = function mockVerifyAuthentication(next) {
hashauth.authenticated = true;
next(true);
};
client.init();
client.dataUpdate(nowData);
client.careportal.prepareEvents();
$('#eventType').val('Snack Bolus');
$('#glucoseValue').val('100');
$('#carbsGiven').val('10');
$('#insulinGiven').val('0.60');
$('#preBolus').val(15);
$('#notes').val('Testing');
$('#enteredBy').val('Dad');
//simulate some events
client.careportal.eventTimeTypeChange();
client.careportal.dateTimeFocus();
client.careportal.dateTimeChange();
window.confirm = function mockConfirm (message) {
function containsLine (line) {
message.indexOf(line + '\n').should.be.greaterThan(0);
}
containsLine('Event Type: Snack Bolus');
containsLine('Blood Glucose: 100');
containsLine('Carbs Given: 10');
containsLine('Insulin Given: 0.60');
containsLine('Carb Time: 15 mins');
containsLine('Notes: Testing');
containsLine('Entered By: Dad');
return true;
};
window.alert = function mockAlert() {};
client.careportal.save();
done();
});
});