@hedia/recommendation-screen 2.0.1 → 2.1.0

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