@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,356 +0,0 @@
1
- import { Activity, Milliseconds } from "@hedia/types";
2
- import { BgLevel, RecommendationReminders } from "../types/enum";
3
- import { IActivityParams, logbookEntry } from "../types/types";
4
- import { addPostponeActivityMessageUnder5MMOL, AttentionMessage, Messages } from "../utils/AttentionMessages";
5
- import { CurrentBGLError } from "../utils/RecommendationError";
6
- import {
7
- getAttentionMessage,
8
- getBGLevel,
9
- getLimitationMessage,
10
- getReminder,
11
- isActivityWithin15Minutes,
12
- isSevereHyperglycemia,
13
- } from "../utils/RecommendationUtils";
14
-
15
- const ActivityIntensity = Activity.Enums.ActivityIntensity;
16
- const { moderate } = ActivityIntensity;
17
-
18
- describe(`Actions based on the blood glucose level:: InsulinSettingsUtils `, (): void => {
19
- const logbookUnder15MMOL: logbookEntry = {
20
- blood_glucose_millimolar: 10,
21
- carbohydrates_entered_grams: 25,
22
- carbohydrates_suggested_grams: 25,
23
- client_timestamp: `25`,
24
- client_version: `25`,
25
- entry_timestamp: `25`,
26
- event_uuid: null,
27
- insulin_entered_units: 25,
28
- insulin_suggested_units: 25,
29
- is_deleted: null,
30
- mood: 2,
31
- settings_uuid: `25`,
32
- uuid: `aaa`,
33
- device_and_os: `ios 12.1.2`,
34
- overwritten_by_id: null,
35
- server_timestamp: null,
36
- server_version: null,
37
- utc_timezone_offset: null,
38
- blood_ketones_millimolar: null,
39
- carbohydrates_modified_suggested_grams: null,
40
- };
41
-
42
- const logbookOver15MMOL: logbookEntry = {
43
- ...logbookUnder15MMOL,
44
- blood_glucose_millimolar: 15.1,
45
- };
46
-
47
- const logbookWithNullBloodGlucose: logbookEntry = {
48
- ...logbookUnder15MMOL,
49
- blood_glucose_millimolar: null,
50
- };
51
-
52
- const inactiveDate = new Date(Date.now() + Milliseconds.Minute * 15.1);
53
- const activeDate = new Date();
54
- const activeActivity: IActivityParams = {
55
- activityDate: activeDate,
56
- activityDuration: 10,
57
- activityIntensity: moderate,
58
- activitySettings: {
59
- hard: { fromFortysix: 0.25, fromThirty: 0.99, fromZero: 0.25 },
60
- light: { fromFortysix: 0.25, fromThirty: 0.25, fromZero: 0.25 },
61
- post: { fromFortysix: 0.25, fromThirty: 0.25, fromZero: 0.25 },
62
- moderate: { fromZero: 0.7, fromThirty: 0.9, fromFortysix: 0.7 },
63
- target: 8.3,
64
- },
65
- };
66
- const inactiveActivity: IActivityParams = { ...activeActivity, activityDate: inactiveDate };
67
-
68
- interface IGetBGLevel {
69
- bloodGlucoseValue: number;
70
- bgLevel: BgLevel;
71
- latestLogbookFrom6Hours: logbookEntry;
72
- }
73
- it.each`
74
- bloodGlucoseValue | latestLogbookFrom6Hours | bgLevel
75
- ${1} | ${null} | ${BgLevel.UnsupportedBGLevel}
76
- ${33.4} | ${logbookOver15MMOL} | ${BgLevel.UnsupportedBGLevel}
77
- ${1.1} | ${null} | ${BgLevel.SevereHypoglycemia}
78
- ${2} | ${logbookOver15MMOL} | ${BgLevel.SevereHypoglycemia}
79
- ${3.5} | ${logbookOver15MMOL} | ${BgLevel.Hypoglycemia}
80
- ${3.6} | ${null} | ${BgLevel.MildHypoglycemia}
81
- ${4} | ${logbookOver15MMOL} | ${BgLevel.MildHypoglycemia}
82
- ${4.1} | ${null} | ${BgLevel.NormoglycemiaUnder5MMOL}
83
- ${5} | ${logbookUnder15MMOL} | ${BgLevel.Normoglycemia}
84
- ${9} | ${null} | ${BgLevel.MildHyperglycemia}
85
- ${15} | ${logbookOver15MMOL} | ${BgLevel.Hyperglycemia}
86
- ${15.1} | ${null} | ${BgLevel.Hyperglycemia}
87
- ${15.1} | ${logbookUnder15MMOL} | ${BgLevel.Hyperglycemia}
88
- ${27.2} | ${null} | ${BgLevel.Hyperglycemia}
89
- ${15.1} | ${logbookOver15MMOL} | ${BgLevel.SevereHyperglycemia}
90
- ${20} | ${logbookOver15MMOL} | ${BgLevel.SevereHyperglycemia}
91
- `(
92
- `return the correct BG level for $bloodGlucoseValue`,
93
- ({ bloodGlucoseValue, bgLevel, latestLogbookFrom6Hours }: IGetBGLevel): void => {
94
- expect(getBGLevel(bloodGlucoseValue, latestLogbookFrom6Hours)).toBe(bgLevel);
95
- },
96
- );
97
-
98
- interface IIsSevereGlycemia {
99
- severeHyperglycemia: boolean;
100
- latestLogbookFrom6Hours: logbookEntry | null;
101
- }
102
- it.each`
103
- latestLogbookFrom6Hours | severeHyperglycemia
104
- ${null} | ${false}
105
- ${logbookOver15MMOL} | ${true}
106
- ${logbookUnder15MMOL} | ${false}
107
- ${undefined} | ${false}
108
- ${{}} | ${false}
109
- ${logbookWithNullBloodGlucose} | ${false}
110
- `(`tests isSevereGlycemia method `, ({ latestLogbookFrom6Hours, severeHyperglycemia }: IIsSevereGlycemia): void => {
111
- expect(isSevereHyperglycemia(latestLogbookFrom6Hours)).toBe(severeHyperglycemia);
112
- });
113
-
114
- interface IIsActivityWithin15Minutes {
115
- activity: IActivityParams;
116
- within15Minutes: boolean;
117
- }
118
- it.each`
119
- activity | within15Minutes
120
- ${activeActivity} | ${true}
121
- ${inactiveActivity} | ${false}
122
- ${activeActivity} | ${true}
123
- ${null} | ${false}
124
- ${undefined} | ${false}
125
- `(`tests isActivityWithin15Minutes `, ({ activity, within15Minutes }: IIsActivityWithin15Minutes): void => {
126
- expect(isActivityWithin15Minutes(activity)).toBe(within15Minutes);
127
- });
128
-
129
- interface IGetAttentionMessage {
130
- bgLevel: BgLevel;
131
- activity: IActivityParams;
132
- attentionMessage: AttentionMessage;
133
- }
134
- interface IGetAttentionMessageError {
135
- bgLevel: BgLevel;
136
- activity: IActivityParams;
137
- attentionMessage: Error;
138
- }
139
- it.each`
140
- bgLevel | activity | attentionMessage
141
- ${BgLevel.UnsupportedBGLevel} | ${activeActivity} | ${CurrentBGLError()}
142
- ${BgLevel.UnsupportedBGLevel} | ${inactiveActivity} | ${CurrentBGLError()}
143
- `(
144
- `Unsupported bg level throws error`,
145
- ({ bgLevel, activity, attentionMessage }: IGetAttentionMessageError): void => {
146
- expect((): AttentionMessage | null => getAttentionMessage(bgLevel, activity)).toThrowError(
147
- attentionMessage,
148
- );
149
- },
150
- );
151
-
152
- it.each`
153
- bgLevel | activity | attentionMessage
154
- ${BgLevel.BGLevelNotProvided} | ${activeActivity} | ${null}
155
- ${BgLevel.SevereHypoglycemia} | ${activeActivity} | ${addPostponeActivityMessageUnder5MMOL(AttentionMessage.SevereHypoglycemia())}
156
- ${BgLevel.Hypoglycemia} | ${activeActivity} | ${addPostponeActivityMessageUnder5MMOL(AttentionMessage.Hypoglycemia())}
157
- ${BgLevel.MildHypoglycemia} | ${activeActivity} | ${addPostponeActivityMessageUnder5MMOL(AttentionMessage.MildHypoglycemia())}
158
- ${BgLevel.NormoglycemiaUnder5MMOL} | ${activeActivity} | ${AttentionMessage.NormoglycemiaActivityUnder5MMOL()}
159
- ${BgLevel.Normoglycemia} | ${activeActivity} | ${null}
160
- ${BgLevel.MildHyperglycemia} | ${activeActivity} | ${null}
161
- ${BgLevel.Hyperglycemia} | ${activeActivity} | ${AttentionMessage.HyperglycemiaActivity()}
162
- ${BgLevel.SevereHyperglycemia} | ${activeActivity} | ${AttentionMessage.SevereHyperglycemiaActivity()}
163
- `(
164
- `return the correct attention message with an active activity for $bgLevel`,
165
- ({ bgLevel, activity, attentionMessage }: IGetAttentionMessage): void => {
166
- expect(getAttentionMessage(bgLevel, activity)).toBe(attentionMessage);
167
- },
168
- );
169
- it.each`
170
- bgLevel | activity | attentionMessage
171
- ${BgLevel.BGLevelNotProvided} | ${inactiveActivity} | ${null}
172
- ${BgLevel.SevereHypoglycemia} | ${inactiveActivity} | ${AttentionMessage.SevereHypoglycemia()}
173
- ${BgLevel.Hypoglycemia} | ${inactiveActivity} | ${AttentionMessage.Hypoglycemia()}
174
- ${BgLevel.MildHypoglycemia} | ${inactiveActivity} | ${AttentionMessage.MildHypoglycemia()}
175
- ${BgLevel.NormoglycemiaUnder5MMOL} | ${inactiveActivity} | ${null}
176
- ${BgLevel.Normoglycemia} | ${inactiveActivity} | ${null}
177
- ${BgLevel.MildHyperglycemia} | ${inactiveActivity} | ${null}
178
- ${BgLevel.Hyperglycemia} | ${inactiveActivity} | ${null}
179
- ${BgLevel.SevereHyperglycemia} | ${inactiveActivity} | ${AttentionMessage.SevereHyperglycemia()}
180
- `(
181
- `return the correct attention message with an inactive activity for $bgLevel`,
182
- ({ bgLevel, activity, attentionMessage }: IGetAttentionMessage): void => {
183
- expect(getAttentionMessage(bgLevel, activity)).toBe(attentionMessage);
184
- },
185
- );
186
-
187
- interface IGetReminder {
188
- bgLevel: BgLevel;
189
- activity: IActivityParams;
190
- carbohydrates: number;
191
- remeasureTime: number;
192
- expectedReminder: number;
193
- }
194
- interface IGetReminderError {
195
- bgLevel: BgLevel;
196
- activity: IActivityParams;
197
- carbohydrates: number;
198
- remeasureTime: number;
199
- expectedReminder: Error;
200
- }
201
-
202
- it.each`
203
- bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
204
- ${BgLevel.UnsupportedBGLevel} | ${activeActivity} | ${0} | ${1} | ${CurrentBGLError()}
205
- ${BgLevel.UnsupportedBGLevel} | ${inactiveActivity} | ${1} | ${2} | ${CurrentBGLError()}
206
- ${BgLevel.UnsupportedBGLevel} | ${null} | ${0} | ${undefined} | ${CurrentBGLError()}
207
- ${BgLevel.UnsupportedBGLevel} | ${null} | ${1} | ${0} | ${CurrentBGLError()}
208
- `(
209
- `Unsupported bg level throws error`,
210
- ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }: IGetReminderError): void => {
211
- expect((): number => getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toThrowError(
212
- expectedReminder,
213
- );
214
- },
215
- );
216
- it.each`
217
- bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
218
- ${BgLevel.BGLevelNotProvided} | ${activeActivity} | ${0} | ${1} | ${1}
219
- ${BgLevel.BGLevelNotProvided} | ${inactiveActivity} | ${0} | ${2.5} | ${2.5}
220
- ${BgLevel.BGLevelNotProvided} | ${null} | ${0} | ${2} | ${RecommendationReminders.ReminderOff}
221
- `(
222
- `return the correct BG reminder value for when the bgl is not provided`,
223
- ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }: IGetReminder): void => {
224
- expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
225
- },
226
- );
227
-
228
- it.each`
229
- bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
230
- ${BgLevel.SevereHypoglycemia} | ${activeActivity} | ${0} | ${1} | ${RecommendationReminders.Reminder15Minutes}
231
- ${BgLevel.SevereHypoglycemia} | ${inactiveActivity} | ${0} | ${2} | ${RecommendationReminders.Reminder15Minutes}
232
- ${BgLevel.SevereHypoglycemia} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.Reminder15Minutes}
233
- ${BgLevel.SevereHypoglycemia} | ${null} | ${1} | ${0} | ${RecommendationReminders.Reminder15Minutes}
234
- `(
235
- `return the correct BG reminder value for severe glycemia`,
236
- ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }: IGetReminder): void => {
237
- expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
238
- },
239
- );
240
-
241
- it.each`
242
- bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
243
- ${BgLevel.Hypoglycemia} | ${activeActivity} | ${0} | ${1} | ${RecommendationReminders.Reminder15Minutes}
244
- ${BgLevel.Hypoglycemia} | ${inactiveActivity} | ${1} | ${2} | ${RecommendationReminders.Reminder15Minutes}
245
- ${BgLevel.Hypoglycemia} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.Reminder15Minutes}
246
- ${BgLevel.Hypoglycemia} | ${null} | ${1} | ${0} | ${RecommendationReminders.Reminder15Minutes}
247
- `(
248
- `return the correct BG reminder value for hypoglycemia`,
249
- ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }: IGetReminder): void => {
250
- expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
251
- },
252
- );
253
-
254
- it.each`
255
- bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
256
- ${BgLevel.MildHypoglycemia} | ${activeActivity} | ${0} | ${1} | ${RecommendationReminders.Reminder15Minutes}
257
- ${BgLevel.MildHypoglycemia} | ${activeActivity} | ${1} | ${2} | ${RecommendationReminders.Reminder15Minutes}
258
- ${BgLevel.MildHypoglycemia} | ${null} | ${0} | ${3} | ${RecommendationReminders.Reminder15Minutes}
259
- ${BgLevel.MildHypoglycemia} | ${null} | ${1} | ${4} | ${RecommendationReminders.Reminder15Minutes}
260
- `(
261
- `return the correct BG reminder value for MildHypoglycemia`,
262
- ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }: IGetReminder): void => {
263
- expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
264
- },
265
- );
266
- it.each`
267
- bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
268
- ${BgLevel.NormoglycemiaUnder5MMOL} | ${activeActivity} | ${0} | ${0.5} | ${0.5}
269
- ${BgLevel.NormoglycemiaUnder5MMOL} | ${inactiveActivity} | ${1} | ${2} | ${2}
270
- ${BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${1} | ${6} | ${6}
271
- ${BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.ReminderOff}
272
- ${BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${1} | ${undefined} | ${RecommendationReminders.HediaReminderDefault}
273
- ${BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${0} | ${1} | ${RecommendationReminders.ReminderOff}
274
- ${BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${0} | ${2} | ${RecommendationReminders.ReminderOff}
275
- `(
276
- `return the correct BG reminder value for normoglycemia under 5 mmol/L`,
277
- ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }: IGetReminder): void => {
278
- expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
279
- },
280
- );
281
-
282
- it.each`
283
- bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
284
- ${BgLevel.Normoglycemia} | ${activeActivity} | ${0} | ${0.5} | ${0.5}
285
- ${BgLevel.Normoglycemia} | ${inactiveActivity} | ${1} | ${2} | ${2}
286
- ${BgLevel.Normoglycemia} | ${null} | ${1} | ${6} | ${6}
287
- ${BgLevel.Normoglycemia} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.ReminderOff}
288
- ${BgLevel.Normoglycemia} | ${null} | ${1} | ${undefined} | ${RecommendationReminders.HediaReminderDefault}
289
- ${BgLevel.Normoglycemia} | ${null} | ${0} | ${1} | ${RecommendationReminders.ReminderOff}
290
- ${BgLevel.Normoglycemia} | ${null} | ${0} | ${2} | ${RecommendationReminders.ReminderOff}
291
- `(
292
- `return the correct BG reminder value for normoglycemia`,
293
- ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }: IGetReminder): void => {
294
- expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
295
- },
296
- );
297
- it.each`
298
- bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
299
- ${BgLevel.MildHyperglycemia} | ${activeActivity} | ${0} | ${3.5} | ${3.5}
300
- ${BgLevel.MildHyperglycemia} | ${inactiveActivity} | ${1} | ${2} | ${2}
301
- ${BgLevel.MildHyperglycemia} | ${null} | ${1} | ${2.5} | ${2.5}
302
- ${BgLevel.MildHyperglycemia} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.ReminderOff}
303
- ${BgLevel.MildHyperglycemia} | ${null} | ${1} | ${undefined} | ${RecommendationReminders.HediaReminderDefault}
304
- ${BgLevel.MildHyperglycemia} | ${null} | ${0} | ${1} | ${RecommendationReminders.ReminderOff}
305
- ${BgLevel.MildHyperglycemia} | ${null} | ${0} | ${2} | ${RecommendationReminders.ReminderOff}
306
- `(
307
- `return the correct BG reminder value for mildglycemia`,
308
- ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }: IGetReminder): void => {
309
- expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
310
- },
311
- );
312
- it.each`
313
- bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
314
- ${BgLevel.Hyperglycemia} | ${activeActivity} | ${0} | ${1} | ${RecommendationReminders.Reminder15Minutes}
315
- ${BgLevel.Hyperglycemia} | ${inactiveActivity} | ${1} | ${2} | ${RecommendationReminders.Reminder60Minutes}
316
- ${BgLevel.Hyperglycemia} | ${activeActivity} | ${0} | ${undefined} | ${RecommendationReminders.Reminder15Minutes}
317
- ${BgLevel.Hyperglycemia} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.Reminder60Minutes}
318
- ${BgLevel.Hyperglycemia} | ${activeActivity} | ${1} | ${1} | ${RecommendationReminders.Reminder15Minutes}
319
- ${BgLevel.Hyperglycemia} | ${null} | ${1} | ${2} | ${RecommendationReminders.Reminder60Minutes}
320
- `(
321
- `return the correct BG reminder value for hyperglycemia`,
322
- ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }: IGetReminder): void => {
323
- expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
324
- },
325
- );
326
- it.each`
327
- bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
328
- ${BgLevel.SevereHyperglycemia} | ${activeActivity} | ${0} | ${2} | ${RecommendationReminders.Reminder15Minutes}
329
- ${BgLevel.SevereHyperglycemia} | ${inactiveActivity} | ${1} | ${2} | ${RecommendationReminders.Reminder60Minutes}
330
- ${BgLevel.SevereHyperglycemia} | ${null} | ${1} | ${undefined} | ${RecommendationReminders.Reminder60Minutes}
331
- ${BgLevel.SevereHyperglycemia} | ${inactiveActivity} | ${1} | ${2} | ${RecommendationReminders.Reminder60Minutes}
332
- `(
333
- `return the correct BG reminder value for severeglycemia `,
334
- ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }: IGetReminder): void => {
335
- expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
336
- },
337
- );
338
-
339
- interface ILimitationMessage {
340
- wasLimited: boolean;
341
- activityReduction: number;
342
- attentionMessage: AttentionMessage;
343
- }
344
-
345
- it.each`
346
- wasLimited | activityReduction | attentionMessage
347
- ${true} | ${0.25} | ${Messages.RecommendationWasLimitedActivity(0.25)}
348
- ${true} | ${0} | ${Messages.RecommendationWasLimited()}
349
- ${false} | ${0} | ${null}
350
- `(
351
- `return the correct attention message for $bgLevel`,
352
- ({ wasLimited, activityReduction, attentionMessage }: ILimitationMessage): void => {
353
- expect(getLimitationMessage(wasLimited, activityReduction)).toBe(attentionMessage);
354
- },
355
- );
356
- });
@@ -1,31 +0,0 @@
1
- // @ts-nocheck
2
- import { Languages } from "@hedia/types";
3
- import { changeLanguage, i18n } from "../locale/i18nUtils";
4
-
5
- describe(`Translation Utils`, (): void => {
6
- test(`Same instance`, (): void => {
7
- expect(i18n).toBe(i18n);
8
- });
9
- test.each`
10
- locale | text
11
- ${Languages.da} | ${`Dansk`}
12
- ${Languages.en} | ${`English`}
13
- ${Languages.de} | ${`Deutsch`}
14
- ${Languages.es} | ${`Español`}
15
- ${Languages.it} | ${`Italiano`}
16
- ${Languages.fr} | ${`Français`}
17
- `(`Change to the right language; $locale`, ({ locale, text }: { locale: Languages; text: string }): void => {
18
- expect(changeLanguage(locale).language).toBe(text);
19
- });
20
- test.each`
21
- locale | text
22
- ${Languages.nl} | ${Languages.en}
23
- ${Languages.jp} | ${Languages.en}
24
- ${Languages.ro} | ${Languages.en}
25
- `(
26
- `Unsupported language defaults to english; $locale`,
27
- ({ locale, text }: { locale: Languages; text: string }): void => {
28
- expect(changeLanguage(locale).language).toBe(text);
29
- },
30
- );
31
- });
@@ -1,91 +0,0 @@
1
- import { UserSettings } from "@hedia/types";
2
- import { IInterval } from "../types/types";
3
- import { ACTIVITY_DURATION_MINUTES_LIMITS } from "../utils/Constants";
4
- import { Utils } from "../utils/Utils";
5
-
6
- const InjectionMethod = UserSettings.Enums.InjectionMethod;
7
- const { PenHalf, PenWhole, Pump } = InjectionMethod;
8
-
9
- describe(`Utils helper functions`, (): void => {
10
- test.each`
11
- method | expected
12
- ${PenWhole} | ${1}
13
- ${PenHalf} | ${2}
14
- ${Pump} | ${10}
15
- `(
16
- `Get correct rounding for $method`,
17
- ({ expected, method }: { method: UserSettings.Enums.InjectionMethod; expected: number }): void => {
18
- expect(Utils.getRounding(method)).toBe(expected);
19
- },
20
- );
21
-
22
- test.each`
23
- value | method | expected
24
- ${1.99} | ${PenWhole} | ${2}
25
- ${1.99} | ${PenHalf} | ${2}
26
- ${1.99} | ${Pump} | ${2}
27
- ${1.74} | ${PenWhole} | ${2}
28
- ${1.74} | ${PenHalf} | ${1.5}
29
- ${1.74} | ${Pump} | ${1.7}
30
- ${1.75} | ${PenWhole} | ${2}
31
- ${1.75} | ${PenHalf} | ${2}
32
- ${1.75} | ${Pump} | ${1.8}
33
- ${-1.45} | ${PenWhole} | ${-1}
34
- ${-1.45} | ${PenHalf} | ${-1.5}
35
- ${-1.45} | ${Pump} | ${-1.4}
36
- `(
37
- `Rounding $value using $method to $expected`,
38
- ({
39
- expected,
40
- method,
41
- value,
42
- }: {
43
- value: number;
44
- method: UserSettings.Enums.InjectionMethod;
45
- expected: number;
46
- }): void => {
47
- expect(Utils.roundValue(value, method)).toBe(expected);
48
- },
49
- );
50
- const customInterval: IInterval = { min: 0, max: 75.5 };
51
- test.each`
52
- value | interval | expected
53
- ${null} | ${ACTIVITY_DURATION_MINUTES_LIMITS} | ${false}
54
- ${undefined} | ${ACTIVITY_DURATION_MINUTES_LIMITS} | ${false}
55
- ${ACTIVITY_DURATION_MINUTES_LIMITS.max} | ${ACTIVITY_DURATION_MINUTES_LIMITS} | ${true}
56
- ${34} | ${ACTIVITY_DURATION_MINUTES_LIMITS} | ${true}
57
- ${ACTIVITY_DURATION_MINUTES_LIMITS.min} | ${ACTIVITY_DURATION_MINUTES_LIMITS} | ${true}
58
- ${0} | ${customInterval} | ${true}
59
- ${25.1} | ${customInterval} | ${true}
60
- ${75.6} | ${customInterval} | ${false}
61
- ${-1} | ${ACTIVITY_DURATION_MINUTES_LIMITS} | ${false}
62
- ${3601} | ${ACTIVITY_DURATION_MINUTES_LIMITS} | ${false}
63
- `(
64
- `Check if a number is in the interval`,
65
- ({ value, interval, expected }: { value: number; interval: IInterval; expected: number }): void => {
66
- expect(Utils.isInClosedInterval(value, interval)).toBe(expected);
67
- },
68
- );
69
-
70
- test.each`
71
- value | expected
72
- ${5.5} | ${99}
73
- ${11} | ${198}
74
- ${1.11} | ${20}
75
- ${12.325} | ${222}
76
- `(
77
- `Convert blood glucose from mmol/L to mg/dl`,
78
- ({ value, expected }: { value: number; expected: number }): void => {
79
- expect(Utils.convertBGLToMGDL(value)).toBe(expected);
80
- },
81
- );
82
- test.each`
83
- value | expected
84
- ${5.5} | ${57}
85
- ${11} | ${115}
86
- ${1.11} | ${12}
87
- ${12.325} | ${128}
88
- `(`Convert from mmol/L to mg/dl`, ({ value, expected }: { value: number; expected: number }): void => {
89
- expect(Utils.convertBKLToMGDL(value)).toBe(expected);
90
- });
91
- });