@hedia/recommendation-screen 2.0.2 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/coverage/clover.xml +700 -0
  2. package/coverage/coverage-final.json +28 -0
  3. package/coverage/lcov-report/base.css +224 -0
  4. package/coverage/lcov-report/block-navigation.js +79 -0
  5. package/coverage/lcov-report/favicon.png +0 -0
  6. package/coverage/lcov-report/index.html +201 -0
  7. package/coverage/lcov-report/prettify.css +1 -0
  8. package/coverage/lcov-report/prettify.js +2 -0
  9. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  10. package/coverage/lcov-report/sorter.js +170 -0
  11. package/coverage/lcov-report/src/RecommendationScreen.tsx.html +1460 -0
  12. package/coverage/lcov-report/src/__tests__/index.html +111 -0
  13. package/coverage/lcov-report/src/__tests__/utils.tsx.html +512 -0
  14. package/coverage/lcov-report/src/components/Header.tsx.html +347 -0
  15. package/coverage/lcov-report/src/components/InfoBars.tsx.html +404 -0
  16. package/coverage/lcov-report/src/components/InvisibleNumberInput.tsx.html +374 -0
  17. package/coverage/lcov-report/src/components/LimitationMessage.tsx.html +191 -0
  18. package/coverage/lcov-report/src/components/LineSeparator.tsx.html +152 -0
  19. package/coverage/lcov-report/src/components/RecentInsulin.tsx.html +383 -0
  20. package/coverage/lcov-report/src/components/RecommendationModal.tsx.html +737 -0
  21. package/coverage/lcov-report/src/components/RecommendedCarbs.tsx.html +857 -0
  22. package/coverage/lcov-report/src/components/RecommendedInsulin.tsx.html +605 -0
  23. package/coverage/lcov-report/src/components/Remeasure.tsx.html +440 -0
  24. package/coverage/lcov-report/src/components/TransferToLogbook.tsx.html +380 -0
  25. package/coverage/lcov-report/src/components/TwoOptionModal.tsx.html +635 -0
  26. package/coverage/lcov-report/src/components/activity/Activity.tsx.html +311 -0
  27. package/coverage/lcov-report/src/components/activity/ActivityIcon.tsx.html +242 -0
  28. package/coverage/lcov-report/src/components/activity/ActivityIntensity.tsx.html +257 -0
  29. package/coverage/lcov-report/src/components/activity/index.html +141 -0
  30. package/coverage/lcov-report/src/components/index.html +276 -0
  31. package/coverage/lcov-report/src/components/mood/Emotion.tsx.html +278 -0
  32. package/coverage/lcov-report/src/components/mood/MoodIcon.tsx.html +260 -0
  33. package/coverage/lcov-report/src/components/mood/index.html +126 -0
  34. package/coverage/lcov-report/src/index.html +111 -0
  35. package/coverage/lcov-report/src/locale/i18nUtils.ts.html +161 -0
  36. package/coverage/lcov-report/src/locale/index.html +111 -0
  37. package/coverage/lcov-report/src/utils/AttentionMessages.tsx.html +326 -0
  38. package/coverage/lcov-report/src/utils/Constants.ts.html +176 -0
  39. package/coverage/lcov-report/src/utils/RecommendationError.tsx.html +500 -0
  40. package/coverage/lcov-report/src/utils/RecommendationUtils.ts.html +467 -0
  41. package/coverage/lcov-report/src/utils/Translations.ts.html +107 -0
  42. package/coverage/lcov-report/src/utils/Utils.ts.html +263 -0
  43. package/coverage/lcov-report/src/utils/Validations.ts.html +815 -0
  44. package/coverage/lcov-report/src/utils/index.html +201 -0
  45. package/coverage/lcov.info +1581 -0
  46. package/jest.config.js +2 -1
  47. package/package.json +2 -2
  48. package/src/RecommendationScreen.d.ts +2 -3
  49. package/src/__tests__/components/Emotion.test.jsx +7 -8
  50. package/src/components/Icon.d.ts +13 -0
  51. package/src/components/Icon.jsx +42 -0
  52. package/src/components/LimitationMessage.d.ts +1 -2
  53. package/src/components/RecommendationModal.d.ts +2 -3
  54. package/src/components/RecommendationModal.jsx +2 -1
  55. package/src/components/activity/ActivityIntensity.jsx +4 -3
  56. package/src/utils/AttentionMessages.d.ts +16 -10
  57. package/src/utils/AttentionMessages.jsx +15 -10
  58. package/src/utils/RecommendationUtils.d.ts +2 -3
  59. package/src/utils/RecommendationUtils.js +10 -6
  60. package/src/utils/Utils.d.ts +1 -0
  61. package/src/utils/Utils.js +4 -0
  62. package/tsconfig.json +7 -5
  63. package/App.d.ts +0 -27
  64. package/App.jsx +0 -98
  65. package/App.tsx +0 -140
  66. package/app.json +0 -4
  67. package/index.ts +0 -6
  68. package/src/RecommendationScreen.tsx +0 -461
  69. package/src/__tests__/RecommendationScreen.test.tsx +0 -1231
  70. package/src/__tests__/RecommendationUtils.test.ts +0 -332
  71. package/src/__tests__/Translate.test.tsx +0 -31
  72. package/src/__tests__/Utils.test.ts +0 -91
  73. package/src/__tests__/Validations.test.ts +0 -648
  74. package/src/__tests__/components/Activity.test.tsx +0 -163
  75. package/src/__tests__/components/Emotion.test.tsx +0 -110
  76. package/src/__tests__/components/Header.test.tsx +0 -44
  77. package/src/__tests__/components/InfoBars.test.tsx +0 -152
  78. package/src/__tests__/components/InvisibleNumberInput.test.tsx +0 -294
  79. package/src/__tests__/components/LimitationMessage.test.tsx +0 -58
  80. package/src/__tests__/components/MoodIcon.test.tsx +0 -45
  81. package/src/__tests__/components/RecommendationModal.test.tsx +0 -169
  82. package/src/__tests__/components/RecommendedCarbs.test.tsx +0 -234
  83. package/src/__tests__/components/RecommendedInsulin.test.tsx +0 -241
  84. package/src/__tests__/components/Remeasure.test.tsx +0 -97
  85. package/src/__tests__/components/TransferToLogbook.test.tsx +0 -38
  86. package/src/__tests__/components/TwoOptionModal.test.tsx +0 -72
  87. package/src/__tests__/utils.tsx +0 -144
  88. package/src/components/Header.tsx +0 -89
  89. package/src/components/Icon.js +0 -41
  90. package/src/components/InfoBars.tsx +0 -108
  91. package/src/components/InvisibleNumberInput.tsx +0 -98
  92. package/src/components/LimitationMessage.tsx +0 -38
  93. package/src/components/LineSeparator.tsx +0 -24
  94. package/src/components/RecentInsulin.tsx +0 -101
  95. package/src/components/RecommendationModal.tsx +0 -224
  96. package/src/components/RecommendedCarbs.tsx +0 -259
  97. package/src/components/RecommendedInsulin.tsx +0 -175
  98. package/src/components/Remeasure.tsx +0 -120
  99. package/src/components/TransferToLogbook.tsx +0 -100
  100. package/src/components/TwoOptionModal.tsx +0 -185
  101. package/src/components/activity/Activity.tsx +0 -77
  102. package/src/components/activity/ActivityIcon.tsx +0 -54
  103. package/src/components/activity/ActivityIntensity.tsx +0 -58
  104. package/src/components/mood/Emotion.tsx +0 -66
  105. package/src/components/mood/MoodIcon.tsx +0 -60
  106. package/src/locale/CleanLanguage.ts +0 -13
  107. package/src/locale/i18nUtils.ts +0 -27
  108. package/src/types/enum.ts +0 -108
  109. package/src/types/types.ts +0 -16
  110. package/src/utils/AttentionMessages.tsx +0 -75
  111. package/src/utils/Constants.ts +0 -32
  112. package/src/utils/RecommendationError.tsx +0 -140
  113. package/src/utils/RecommendationUtils.ts +0 -125
  114. package/src/utils/Translations.ts +0 -9
  115. package/src/utils/Utils.ts +0 -57
  116. package/src/utils/Validations.ts +0 -245
@@ -1,648 +0,0 @@
1
- import { Activity, BloodGlucoseUnit, BloodKetonesUnit, Languages, Milliseconds, UserSettings } from "@hedia/types";
2
- import { ActivitySettings, IActivityParams, IRecentBolus, logbookEntry } from "../types/types";
3
- import { FOUR_HOURS_SECONDS } from "../utils/Constants";
4
- import * as Errors from "../utils/RecommendationError";
5
- import * as Validations from "../utils/Validations";
6
- import { generateDefaultActivitySettings, generateDefaultLogbook } from "./utils";
7
-
8
- const ActivityEnum = Activity.Enums.ActivityEnum;
9
- const ActivityIntensity = Activity.Enums.ActivityIntensity;
10
- const InjectionMethod = UserSettings.Enums.InjectionMethod;
11
-
12
- const { light, moderate, hard } = ActivityIntensity;
13
-
14
- describe(`Test validations functions for the recommendation props`, (): void => {
15
- test.each`
16
- validInjectionMethod
17
- ${InjectionMethod.PenHalf}
18
- ${InjectionMethod.PenWhole}
19
- ${InjectionMethod.Pump}
20
- `(
21
- `Validation checking on treatment types $validInjectionMethod `,
22
- ({ validInjectionMethod }: { validInjectionMethod: UserSettings.Enums.InjectionMethod }): void => {
23
- expect((): void => Validations.checkInjectionMethod(validInjectionMethod)).not.toThrowError(
24
- Errors.InjectionMethodError(),
25
- );
26
- },
27
- );
28
-
29
- test.each`
30
- invalidInjectionMethod
31
- ${`Pen`}
32
- ${`Injection`}
33
- ${`Hedia`}
34
- `(
35
- `Validation checking on treatment types $invalidInjectionMethod throws error`,
36
- (invalidInjectionMethod: UserSettings.Enums.InjectionMethod): void => {
37
- expect((): void => Validations.checkInjectionMethod(invalidInjectionMethod)).toThrowError(
38
- Errors.InjectionMethodError(),
39
- );
40
- },
41
- );
42
-
43
- test.each`
44
- validUnit
45
- ${BloodGlucoseUnit.MG_DL}
46
- ${BloodGlucoseUnit.MMOL_L}
47
- `(
48
- `Validation checking on blood glucose unit types $validUnit`,
49
- ({ validUnit }: { validUnit: BloodGlucoseUnit }): void => {
50
- expect((): void => Validations.checkBGLUnit(validUnit)).not.toThrowError(Errors.BloodGlucoseUnitError());
51
- },
52
- );
53
-
54
- test.each`
55
- invalidUnit
56
- ${`Kilogram`}
57
- ${`Litre`}
58
- ${`MMOL`}
59
- `(
60
- `Validation checking on invalid blood glucose unit types $invalidUnit throws error`,
61
- ({ invalidUnit }: { invalidUnit: BloodGlucoseUnit }): void => {
62
- expect((): void => Validations.checkBGLUnit(invalidUnit)).toThrowError(Errors.BloodGlucoseUnitError());
63
- },
64
- );
65
- test.each`
66
- validUnit
67
- ${BloodKetonesUnit.MG_DL}
68
- ${BloodKetonesUnit.MMOL_L}
69
- `(
70
- `Validation checking on blood ketones unit types $validUnit`,
71
- ({ validUnit }: { validUnit: BloodKetonesUnit }): void => {
72
- expect((): void => Validations.checkBKLUnit(validUnit)).not.toThrowError(Errors.BloodKetoneUnitError());
73
- },
74
- );
75
-
76
- test.each`
77
- invalidUnit
78
- ${`Kilogram`}
79
- ${`Litre`}
80
- ${`MMOL`}
81
- `(
82
- `Validation checking on invalid blood ketones unit types $invalidUnit throws error`,
83
- ({ invalidUnit }: { invalidUnit: BloodKetonesUnit }): void => {
84
- expect((): void => Validations.checkBKLUnit(invalidUnit)).toThrowError(Errors.BloodKetoneUnitError());
85
- },
86
- );
87
-
88
- test.each`
89
- validLanguage
90
- ${Languages.da}
91
- ${Languages.en}
92
- ${Languages.de}
93
- ${Languages.es}
94
- ${Languages.it}
95
- ${Languages.fr}
96
- `(
97
- `Validation checking on supported languages types $validLanguage`,
98
- ({ validLanguage }: { validLanguage: Languages }): void => {
99
- expect((): void => Validations.checkLanguage(validLanguage)).not.toThrowError(Errors.LanguageError());
100
- },
101
- );
102
-
103
- test.each`
104
- invalidLanguage
105
- ${`Polish`}
106
- ${`Danish`}
107
- ${`Dansk`}
108
- ${`Deutsch`}
109
- `(
110
- `Validation checking on supported languages types $invalidLanguage throws error`,
111
- (invalidLanguage: Languages): void => {
112
- expect((): void => Validations.checkLanguage(invalidLanguage)).toThrowError(Errors.LanguageError());
113
- },
114
- );
115
-
116
- it.each`
117
- validLatestLogbookFrom6Hours
118
- ${generateDefaultLogbook()}
119
- ${null}
120
- `(
121
- `Validation checking on the latest logbook from the latest 6 hours with a valid logbook`,
122
- ({ validLatestLogbookFrom6Hours }: { validLatestLogbookFrom6Hours: logbookEntry }): void => {
123
- expect((): void => Validations.checkLatestLogbook6Hours(validLatestLogbookFrom6Hours)).not.toThrowError(
124
- Errors.LatestLogbook6HoursBGLError(),
125
- );
126
- },
127
- );
128
- it.each`
129
- invalidLatestLogbookFrom6Hours
130
- ${undefined}
131
- ${{}}
132
- ${[]}
133
- ${{ ...generateDefaultLogbook(), blood_glucose_millimolar: 1 }}
134
- ${{ ...generateDefaultLogbook(), blood_glucose_millimolar: 33.4 }}
135
- `(
136
- `Validation checking on the latest logbook from the latest 6 hours with an invalid logbook `,
137
- ({ invalidLatestLogbookFrom6Hours }: { invalidLatestLogbookFrom6Hours: logbookEntry }): void => {
138
- expect((): void => Validations.checkLatestLogbook6Hours(invalidLatestLogbookFrom6Hours)).toThrowError(
139
- Errors.LatestLogbook6HoursBGLError(),
140
- );
141
- },
142
- );
143
-
144
- test.each`
145
- validActivityType
146
- ${ActivityEnum.Walk}
147
- ${ActivityEnum.Swim}
148
- ${ActivityEnum.Run}
149
- ${ActivityEnum.Other}
150
- ${ActivityEnum.Cycling}
151
- `(
152
- `Validation checking on activity types $validActivityType `,
153
- ({ validActivityType }: { validActivityType: Activity.Enums.ActivityEnum }): void => {
154
- expect((): void => Validations.checkActivityType(validActivityType)).not.toThrowError(
155
- Errors.ActivityTypeError(),
156
- );
157
- },
158
- );
159
-
160
- test.each`
161
- invalidActivityType
162
- ${`Dance`}
163
- ${`Walking`}
164
- ${`Swimming`}
165
- ${`Running`}
166
- ${`Cycle`}
167
- `(
168
- `Validation checking on activity types $invalidActivityType throws error`,
169
- (invalidActivityType: Activity.Enums.ActivityEnum): void => {
170
- expect((): void => Validations.checkActivityType(invalidActivityType)).toThrowError(
171
- Errors.ActivityTypeError(),
172
- );
173
- },
174
- );
175
-
176
- test.each`
177
- validUserReminder
178
- ${0}
179
- ${6}
180
- ${3}
181
- ${4.5}
182
- `(
183
- `Validation checking on the user reminder value $validUserReminder`,
184
- ({ validUserReminder: validUserReminder }: { validUserReminder: number }): void => {
185
- expect((): void => Validations.checkUserReminder(validUserReminder)).not.toThrowError(
186
- Errors.UserReminderError(),
187
- );
188
- },
189
- );
190
- test.each`
191
- invalidUserReminder
192
- ${-1}
193
- ${null}
194
- ${undefined}
195
- ${7}
196
- `(
197
- `Validation checking on the user reminder value $invalidUserReminder throws error`,
198
- ({ invalidUserReminder }: { invalidUserReminder: number }): void => {
199
- expect((): void => Validations.checkUserReminder(invalidUserReminder)).toThrowError(
200
- Errors.UserReminderError(),
201
- );
202
- },
203
- );
204
- });
205
-
206
- describe(`Test validations for the calculator parameters`, (): void => {
207
- test.each`
208
- validDuration
209
- ${1}
210
- ${60}
211
- ${34}
212
- ${5.555}
213
- `(`Validation checking on activity $validDuration `, ({ validDuration }: { validDuration: number }): void => {
214
- expect((): void => Validations.checkActivityDuration(validDuration)).not.toThrowError(
215
- Errors.ActivityDurationError(),
216
- );
217
- });
218
-
219
- test.each`
220
- invalidDuration
221
- ${0}
222
- ${61}
223
- ${undefined}
224
- ${null}
225
- `(`Validation checking on activity $invalidDuration throws error`, (invalidDuration: number): void => {
226
- expect((): void => Validations.checkActivityDuration(invalidDuration)).toThrowError(
227
- Errors.ActivityDurationError(),
228
- );
229
- });
230
-
231
- test.each`
232
- validIntensity
233
- ${hard}
234
- ${light}
235
- ${moderate}
236
- `(
237
- `Validation checking on activity $validIntensity`,
238
- ({ validIntensity }: { validIntensity: Activity.Enums.ActivityIntensity }): void => {
239
- expect((): void => Validations.checkActivityIntensity(validIntensity)).not.toThrowError(
240
- Errors.ActivityIntensityError(),
241
- );
242
- },
243
- );
244
-
245
- test.each`
246
- invalidIntensity
247
- ${`Hard`}
248
- ${`easy`}
249
- ${undefined}
250
- ${null}
251
- `(
252
- `Validation checking on activity $invalidIntensity throws error`,
253
- ({ invalidIntensity }: { invalidIntensity: Activity.Enums.ActivityIntensity }): void => {
254
- expect((): void => Validations.checkActivityIntensity(invalidIntensity)).toThrowError(
255
- Errors.ActivityIntensityError(),
256
- );
257
- },
258
- );
259
-
260
- const validActivitySettings1: ActivitySettings = generateDefaultActivitySettings();
261
-
262
- const validActivitySettings2: ActivitySettings = {
263
- ...validActivitySettings1,
264
- hard: { fromZero: 1, fromThirty: 0.99, fromFortysix: null },
265
- };
266
-
267
- const validActivitySettings3: ActivitySettings = {
268
- ...validActivitySettings1,
269
- hard: { fromZero: 0, fromThirty: 0, fromFortysix: 0 },
270
- };
271
-
272
- const invalidActivitySettings1: ActivitySettings = {
273
- ...validActivitySettings1,
274
- // @ts-ignore Purposefully invalid settings
275
- hard: { fromZero: 0, fromThirty: null, fromFortysix: null },
276
- };
277
-
278
- const invalidActivitySettings2: ActivitySettings = {
279
- ...validActivitySettings1,
280
- // @ts-ignore Purposefully invalid settings
281
- light: { fromZero: undefined, fromThirty: 0.99, fromFortysix: 0.25 },
282
- };
283
-
284
- const invalidActivitySettings3: ActivitySettings = {
285
- ...validActivitySettings1,
286
- hard: { fromZero: 1, fromThirty: 0.99, fromFortysix: 1.1 },
287
- };
288
-
289
- const validActivity1: IActivityParams = {
290
- activityDate: new Date(Date.now() - Milliseconds.Hour * 5 - Milliseconds.Minute * 9.9),
291
- activityDuration: 60,
292
- activityIntensity: moderate,
293
- activitySettings: validActivitySettings1,
294
- };
295
-
296
- const validActivity2: IActivityParams = {
297
- ...validActivity1,
298
- activityDate: new Date(Date.now() - Milliseconds.Hour * 4.5 - Milliseconds.Minute * 9.9),
299
- activityDuration: 30,
300
- };
301
-
302
- const invalidActivity1: IActivityParams = {
303
- ...validActivity1,
304
- activityDate: new Date(Date.now() - Milliseconds.Hour * 4.5 - Milliseconds.Minute * 10),
305
- activityDuration: 30,
306
- };
307
-
308
- const invalidActivity2: IActivityParams = {
309
- ...validActivity1,
310
- activityDate: new Date(Date.now() - Milliseconds.Hour * 4.25 - Milliseconds.Minute * 10),
311
- activityDuration: 15,
312
- };
313
-
314
- test(`Can call checkActivity with a valid activity`, (): void => {
315
- expect((): void => Validations.checkActivity(validActivity1)).not.toThrow();
316
- });
317
-
318
- test(`Can call checkActivity with an invalid activity and throw error`, (): void => {
319
- expect((): void => Validations.checkActivity(invalidActivity1)).toThrow();
320
- });
321
-
322
- test.each`
323
- validActivity
324
- ${validActivity1}
325
- ${validActivity2}
326
- `(
327
- `Validation checking on activity date $validActivity.activityDate`,
328
- ({ validActivity }: { validActivity: IActivityParams }): void => {
329
- expect((): void => Validations.checkActivityDate(validActivity)).not.toThrowError(
330
- Errors.ActivityDateError(),
331
- );
332
- },
333
- );
334
-
335
- test.each`
336
- invalidActivity
337
- ${invalidActivity1}
338
- ${invalidActivity2}
339
- `(
340
- `Validation checking on invalid activity $invalidActivity.activityDate throws error`,
341
- ({ invalidActivity }: { invalidActivity: IActivityParams }): void => {
342
- expect((): void => Validations.checkActivityDate(invalidActivity)).toThrowError(Errors.ActivityDateError());
343
- },
344
- );
345
-
346
- test.each`
347
- validActivitySettings
348
- ${validActivitySettings1}
349
- ${validActivitySettings2}
350
- ${validActivitySettings3}
351
- `(
352
- `Validation checking on validActivitySettings`,
353
- ({ validActivitySettings }: { validActivitySettings: ActivitySettings }): void => {
354
- expect((): void => Validations.checkActivitySettings(validActivitySettings)).not.toThrowError(
355
- Errors.ActivitySettingsError(),
356
- );
357
- },
358
- );
359
-
360
- test.each`
361
- invalidActivitySettings
362
- ${invalidActivitySettings1}
363
- ${invalidActivitySettings2}
364
- ${invalidActivitySettings3}
365
- `(
366
- `Validation checking on invalidActivitySettings throws error`,
367
- ({ invalidActivitySettings }: { invalidActivitySettings: ActivitySettings }): void => {
368
- expect((): void => Validations.checkActivitySettings(invalidActivitySettings)).toThrowError(
369
- Errors.ActivitySettingsError(),
370
- );
371
- },
372
- );
373
-
374
- test.each`
375
- validActivityTargetBGL
376
- ${5}
377
- ${13.9}
378
- ${8}
379
- ${10}
380
- `(
381
- `Validation checking on $validActivityTargetBGL `,
382
- ({ validActivityTargetBGL }: { validActivityTargetBGL: number }): void => {
383
- expect((): void => Validations.checkActivityTargetBGL(validActivityTargetBGL)).not.toThrowError(
384
- Errors.ActivityTargetBGLError(),
385
- );
386
- },
387
- );
388
-
389
- test.each`
390
- invalidActivityTargetBGL
391
- ${4.99}
392
- ${null}
393
- ${undefined}
394
- ${13.91}
395
- `(
396
- `Validation checking on $invalidActivityTargetBGL throws error`,
397
- ({ invalidActivityTargetBGL }: { invalidActivityTargetBGL: number }): void => {
398
- expect((): void => Validations.checkActivityTargetBGL(invalidActivityTargetBGL)).toThrowError(
399
- Errors.ActivityTargetBGLError(),
400
- );
401
- },
402
- );
403
-
404
- test.each`
405
- validTargetBGL
406
- ${5}
407
- ${13.9}
408
- ${8}
409
- ${10}
410
- `(`Validation checking on $validTargetBGL `, ({ validTargetBGL }: { validTargetBGL: number }): void => {
411
- expect((): void => Validations.checkTargetBGL(validTargetBGL)).not.toThrowError(Errors.TargetBGLError());
412
- });
413
-
414
- test.each`
415
- invalidTargetBGL
416
- ${4.99}
417
- ${null}
418
- ${undefined}
419
- ${13.91}
420
- `(
421
- `Validation checking on $invalidTargetBGL throws error `,
422
- ({ invalidTargetBGL }: { invalidTargetBGL: number }): void => {
423
- expect((): void => Validations.checkTargetBGL(invalidTargetBGL)).toThrowError(Errors.TargetBGLError());
424
- },
425
- );
426
-
427
- test.each`
428
- validCarbohydrates
429
- ${0}
430
- ${100}
431
- ${300}
432
- ${10}
433
- `(
434
- `Validation checking on provided $validCarbohydrates `,
435
- ({ validCarbohydrates }: { validCarbohydrates: number }): void => {
436
- expect((): void => Validations.checkCarbohydrates(validCarbohydrates)).not.toThrowError(
437
- Errors.CarbohydrateLimitError(),
438
- );
439
- },
440
- );
441
-
442
- test.each`
443
- invalidCarbohydrates
444
- ${-2}
445
- ${null}
446
- ${undefined}
447
- ${301}
448
- `(
449
- `Validation checking on provided $invalidCarbohydrates throws error`,
450
- ({ invalidCarbohydrates }: { invalidCarbohydrates: number }): void => {
451
- expect((): void => Validations.checkCarbohydrates(invalidCarbohydrates)).toThrowError(
452
- Errors.CarbohydrateLimitError(),
453
- );
454
- },
455
- );
456
-
457
- test.each`
458
- validCurrentBGL
459
- ${1.1}
460
- ${33.3}
461
- ${null}
462
- ${10}
463
- `(`Validation checking on $validCurrentBGL `, ({ validCurrentBGL }: { validCurrentBGL: number }): void => {
464
- expect((): void => Validations.checkCurrentBGL(validCurrentBGL)).not.toThrowError(Errors.CurrentBGLError());
465
- });
466
-
467
- test.each`
468
- invalidCurrentBGL
469
- ${1}
470
- ${33.31}
471
- ${undefined}
472
- ${0}
473
- `(
474
- `Validation checking on $invalidCurrentBGL throws error`,
475
- ({ invalidCurrentBGL }: { invalidCurrentBGL: number }): void => {
476
- expect((): void => Validations.checkCurrentBGL(invalidCurrentBGL)).toThrowError(Errors.CurrentBGLError());
477
- },
478
- );
479
-
480
- test.each`
481
- validRatio
482
- ${1}
483
- ${50}
484
- ${25}
485
- ${49.99}
486
- `(`Validation checking on IC $validRatio `, ({ validRatio }: { validRatio: number }): void => {
487
- expect((): void => Validations.checkInsulinToCarbRatio(validRatio)).not.toThrowError(
488
- Errors.InsulinToCarbsRatioError(),
489
- );
490
- });
491
-
492
- test.each`
493
- invalidRatio
494
- ${0}
495
- ${null}
496
- ${undefined}
497
- ${51}
498
- `(`Validation checking on IC $invalidRatio throws error`, ({ invalidRatio }: { invalidRatio: number }): void => {
499
- expect((): void => Validations.checkInsulinToCarbRatio(invalidRatio)).toThrowError(
500
- Errors.InsulinToCarbsRatioError(),
501
- );
502
- });
503
-
504
- test.each`
505
- validInsulinSensitivity
506
- ${0.3}
507
- ${10}
508
- ${5}
509
- ${4.44}
510
- `(
511
- `Validation checking on $validInsulinSensitivity `,
512
- ({ validInsulinSensitivity }: { validInsulinSensitivity: number }): void => {
513
- expect((): void => Validations.checkInsulinSensitivity(validInsulinSensitivity)).not.toThrowError(
514
- Errors.InsulinSensitivityError(),
515
- );
516
- },
517
- );
518
-
519
- test.each`
520
- invalidInsulinSensitivity
521
- ${0}
522
- ${null}
523
- ${undefined}
524
- ${10.01}
525
- `(`Validation checking on $invalidInsulinSensitivity throws error`, (invalidInsulinSensitivity: number): void => {
526
- expect((): void => Validations.checkInsulinSensitivity(invalidInsulinSensitivity)).toThrowError(
527
- Errors.InsulinSensitivityError(),
528
- );
529
- });
530
-
531
- const validBolus1: IRecentBolus = {
532
- insulinDose: 0,
533
- secondsPassed: 1,
534
- };
535
- const validBolus2: IRecentBolus = {
536
- insulinDose: 50,
537
- secondsPassed: FOUR_HOURS_SECONDS,
538
- };
539
- const invalidBolus1: IRecentBolus = {
540
- // @ts-ignore Forcefully incorrect.
541
- insulinDose: null,
542
- // @ts-ignore Forcefully incorrect.
543
- secondsPassed: null,
544
- };
545
- const invalidBolus2: IRecentBolus = {
546
- // @ts-ignore Forcefully incorrect.
547
- insulinDose: undefined,
548
- secondsPassed: FOUR_HOURS_SECONDS + 1,
549
- };
550
- const invalidBolus3: IRecentBolus = {
551
- insulinDose: 51,
552
- secondsPassed: -1,
553
- };
554
-
555
- test.each`
556
- validRecentBoluses
557
- ${[validBolus1, validBolus2]}
558
- ${[validBolus2]}
559
- ${[]}
560
- `(
561
- `Validation checking on Recent Boluses - insulin dose`,
562
- ({ validRecentBoluses }: { validRecentBoluses: Array<IRecentBolus> }): void => {
563
- expect((): void => Validations.checkRecentBolusesInsulinDose(validRecentBoluses)).not.toThrow();
564
- },
565
- );
566
-
567
- test.each`
568
- invalidRecentBoluses
569
- ${[validBolus1, invalidBolus1]}
570
- ${[invalidBolus2]}
571
- ${[validBolus2, invalidBolus3]}
572
- `(
573
- `Validation checking on Recent Boluses insulin - dose throws error`,
574
- ({ invalidRecentBoluses }: { invalidRecentBoluses: Array<IRecentBolus> }): void => {
575
- expect((): void => Validations.checkRecentBolusesInsulinDose(invalidRecentBoluses)).toThrowError(
576
- Errors.BolusInsulinDoseError(),
577
- );
578
- },
579
- );
580
-
581
- test.each`
582
- validRecentBoluses
583
- ${[validBolus1, validBolus2]}
584
- ${[validBolus2]}
585
- ${[]}
586
- `(
587
- `Validation checking on Recent Boluses seconds passed`,
588
- ({ validRecentBoluses }: { validRecentBoluses: Array<IRecentBolus> }): void => {
589
- expect((): void => Validations.checkRecentBolusesSecondsPassed(validRecentBoluses)).not.toThrowError(
590
- Errors.BolusInsulinSecondsPassedError(),
591
- );
592
- },
593
- );
594
-
595
- test.each`
596
- invalidRecentBoluses
597
- ${[validBolus1, invalidBolus1]}
598
- ${[validBolus2, invalidBolus2]}
599
- ${[validBolus2, invalidBolus3]}
600
- `(
601
- `Validation checking on Recent Boluses seconds passed throws error`,
602
- ({ invalidRecentBoluses }: { invalidRecentBoluses: Array<IRecentBolus> }): void => {
603
- expect((): void => Validations.checkRecentBolusesSecondsPassed(invalidRecentBoluses)).toThrowError(
604
- Errors.BolusInsulinSecondsPassedError(),
605
- );
606
- },
607
- );
608
-
609
- test.each`
610
- invalidRecentBoluses
611
- ${null}
612
- ${undefined}
613
- `(
614
- `Validation checking on Recent Boluses: null and undefined throws error`,
615
- ({ invalidRecentBoluses }: { invalidRecentBoluses: Array<IRecentBolus> }): void => {
616
- expect((): void => Validations.checkRecentBolus(invalidRecentBoluses)).toThrowError(
617
- Errors.RecentBolusError(),
618
- );
619
- },
620
- );
621
-
622
- test.each`
623
- validCurrentBKL
624
- ${0}
625
- ${8}
626
- ${null}
627
- ${5}
628
- `(`Validation checking on $validCurrentBKL `, ({ validCurrentBKL }: { validCurrentBKL: number }): void => {
629
- expect((): void => Validations.checkBloodKetoneLevel(validCurrentBKL)).not.toThrowError(
630
- Errors.CurrentBKLError(),
631
- );
632
- });
633
-
634
- test.each`
635
- invalidCurrentBKL
636
- ${-0.1}
637
- ${8.01}
638
- ${undefined}
639
- ${NaN}
640
- `(
641
- `Validation checking on $invalidCurrentBKL throws error`,
642
- ({ invalidCurrentBKL }: { invalidCurrentBKL: number }): void => {
643
- expect((): void => Validations.checkBloodKetoneLevel(invalidCurrentBKL)).toThrowError(
644
- Errors.CurrentBKLError(),
645
- );
646
- },
647
- );
648
- });