@@ -34,9 +34,10 @@ describe('boluswizardpreview', function ( ) {
3434
3535 var profile = {
3636 dia : 3
37- , sens : 90
38- , target_high : 120
39- , target_low : 100
37+ , units : ctx . settings . units
38+ , sens : ctx . settings . units === 'mmol' ? 5 : 90
39+ , target_high : ctx . settings . units === 'mmol' ? 6.7 : 120
40+ , target_low : ctx . settings . units === 'mmol' ? 5.6 : 100
4041 } ;
4142
4243 it ( 'should calculate IOB results correctly with 0 IOB' , function ( done ) {
@@ -50,8 +51,12 @@ describe('boluswizardpreview', function ( ) {
5051
5152 results . effect . should . equal ( 0 ) ;
5253 results . effectDisplay . should . equal ( 0 ) ;
53- results . outcome . should . equal ( 100 ) ;
54- results . outcomeDisplay . should . equal ( 100 ) ;
54+
55+ var expectedOutcome =
56+ ctx . settings . units === 'mmol' ? 5.6 : 100 ;
57+ results . outcome . should . equal ( expectedOutcome ) ;
58+ results . outcomeDisplay . should . equal ( expectedOutcome ) ;
59+
5560 results . bolusEstimate . should . equal ( 0 ) ;
5661 results . displayLine . should . equal ( 'BWP: 0U' ) ;
5762
@@ -65,20 +70,27 @@ describe('boluswizardpreview', function ( ) {
6570
6671 var profile = {
6772 dia : 3
68- , sens : 50
69- , target_high : 100
70- , target_low : 50
73+ , units : ctx . settings . units
74+ , sens : ctx . settings . units === 'mmol' ? 2.8 : 50
75+ , target_high : ctx . settings . units === 'mmol' ? 5.6 : 100
76+ , target_low : ctx . settings . units === 'mmol' ? 2.8 : 50
7177 } ;
7278
7379 ctx . ddata . profiles = [ profile ] ;
7480
7581 var sbx = prepareSandbox ( ) ;
7682 var results = boluswizardpreview . calc ( sbx ) ;
7783
78- Math . round ( results . effect ) . should . equal ( 50 ) ;
79- results . effectDisplay . should . equal ( 50 ) ;
80- Math . round ( results . outcome ) . should . equal ( 50 ) ;
81- results . outcomeDisplay . should . equal ( 50 ) ;
84+ var expectedEffect =
85+ ctx . settings . units === 'mmol' ? 2.8 : 50 ;
86+ results . effect . should . equal ( expectedEffect ) ;
87+ results . effectDisplay . should . equal ( expectedEffect ) ;
88+
89+ var expectedOutcome =
90+ ctx . settings . units === 'mmol' ? 2.8 : 50 ;
91+ results . outcome . should . equal ( expectedOutcome ) ;
92+ results . outcomeDisplay . should . equal ( expectedOutcome ) ;
93+
8294 results . bolusEstimate . should . equal ( 0 ) ;
8395 results . displayLine . should . equal ( 'BWP: 0U' ) ;
8496
@@ -92,9 +104,10 @@ describe('boluswizardpreview', function ( ) {
92104
93105 var profile = {
94106 dia : 3
95- , sens : 50
96- , target_high : 200
97- , target_low : 100
107+ , units : ctx . settings . units
108+ , sens : ctx . settings . units === 'mmol' ? 2.8 : 50
109+ , target_high : ctx . settings . units === 'mmol' ? 11.1 : 200
110+ , target_low : ctx . settings . units === 'mmol' ? 5.6 : 100
98111 , basal : 1
99112 } ;
100113
@@ -104,10 +117,16 @@ describe('boluswizardpreview', function ( ) {
104117 var sbx = prepareSandbox ( ) ;
105118 var results = boluswizardpreview . calc ( sbx ) ;
106119
107- Math . round ( results . effect ) . should . equal ( 50 ) ;
108- results . effectDisplay . should . equal ( 50 ) ;
109- Math . round ( results . outcome ) . should . equal ( 50 ) ;
110- results . outcomeDisplay . should . equal ( 50 ) ;
120+ var expectedResult =
121+ ctx . settings . units === 'mmol' ? 2.8 : 50 ;
122+ results . effect . should . equal ( expectedResult ) ;
123+ results . effectDisplay . should . equal ( expectedResult ) ;
124+
125+ var expectedOutcome =
126+ ctx . settings . units === 'mmol' ? 2.8 : 50 ;
127+ results . outcome . should . equal ( expectedOutcome ) ;
128+ results . outcomeDisplay . should . equal ( expectedOutcome ) ;
129+
111130 Math . round ( results . bolusEstimate ) . should . equal ( - 1 ) ;
112131 results . displayLine . should . equal ( 'BWP: -1.00U' ) ;
113132 results . tempBasalAdjustment . thirtymin . should . equal ( - 100 ) ;
@@ -116,7 +135,7 @@ describe('boluswizardpreview', function ( ) {
116135 done ( ) ;
117136 } ) ;
118137
119- it ( 'should calculate IOB results correctly with 1.0 U IOB resulting in going low in MMOL' , function ( done ) {
138+ it ( 'should calculate IOB results correctly with 1.0 U IOB resulting in going low in MMOL' , function ( done ) {
120139
121140 // boilerplate for client sandbox running in mmol
122141
@@ -159,8 +178,7 @@ describe('boluswizardpreview', function ( ) {
159178 done ( ) ;
160179 } ) ;
161180
162-
163- it ( 'should calculate IOB results correctly with 0.45 U IOB resulting in going low in MMOL' , function ( done ) {
181+ it ( 'should calculate IOB results correctly with 0.45 U IOB resulting in going low in MMOL' , function ( done ) {
164182
165183 // boilerplate for client sandbox running in mmol
166184
@@ -230,7 +248,13 @@ describe('boluswizardpreview', function ( ) {
230248 var highest = ctx . notifications . findHighestAlarm ( ) ;
231249 highest . level . should . equal ( ctx . levels . WARN ) ;
232250 highest . title . should . equal ( 'Warning, Check BG, time to bolus?' ) ;
233- highest . message . should . equal ( 'BG Now: 180 +5 ↗ mg/dl\nBG 15m: 187 mg/dl\nBWP: 0.66U' ) ;
251+
252+ var expectedMessage =
253+ ctx . settings . units === 'mmol' ?
254+ 'BG Now: 10 +0.3 ↗ mmol/L\nBG 15m: 10.4 mmol/L\nBWP: 0.65U' :
255+ 'BG Now: 180 +5 ↗ mg/dl\nBG 15m: 187 mg/dl\nBWP: 0.66U' ;
256+ highest . message . should . equal ( expectedMessage ) ;
257+
234258 done ( ) ;
235259 } ) ;
236260
@@ -274,8 +298,11 @@ describe('boluswizardpreview', function ( ) {
274298 } ) ;
275299
276300 it ( 'set a pill to the BWP with infos' , function ( done ) {
301+
277302 var ctx = {
278- settings : { }
303+ settings : {
304+ units : helper . ctx . settings . units
305+ }
279306 , pluginBase : {
280307 updatePillText : function mockedUpdatePillText ( plugin , options ) {
281308 options . label . should . equal ( 'BWP' ) ;
0 commit comments