@hedia/recommendation-screen 2.0.2 → 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.
- package/App.d.ts +2 -2
- package/coverage/clover.xml +700 -0
- package/coverage/coverage-final.json +28 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +79 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +201 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +170 -0
- package/coverage/lcov-report/src/RecommendationScreen.tsx.html +1460 -0
- package/coverage/lcov-report/src/__tests__/index.html +111 -0
- package/coverage/lcov-report/src/__tests__/utils.tsx.html +512 -0
- package/coverage/lcov-report/src/components/Header.tsx.html +347 -0
- package/coverage/lcov-report/src/components/InfoBars.tsx.html +404 -0
- package/coverage/lcov-report/src/components/InvisibleNumberInput.tsx.html +374 -0
- package/coverage/lcov-report/src/components/LimitationMessage.tsx.html +191 -0
- package/coverage/lcov-report/src/components/LineSeparator.tsx.html +152 -0
- package/coverage/lcov-report/src/components/RecentInsulin.tsx.html +383 -0
- package/coverage/lcov-report/src/components/RecommendationModal.tsx.html +737 -0
- package/coverage/lcov-report/src/components/RecommendedCarbs.tsx.html +857 -0
- package/coverage/lcov-report/src/components/RecommendedInsulin.tsx.html +605 -0
- package/coverage/lcov-report/src/components/Remeasure.tsx.html +440 -0
- package/coverage/lcov-report/src/components/TransferToLogbook.tsx.html +380 -0
- package/coverage/lcov-report/src/components/TwoOptionModal.tsx.html +635 -0
- package/coverage/lcov-report/src/components/activity/Activity.tsx.html +311 -0
- package/coverage/lcov-report/src/components/activity/ActivityIcon.tsx.html +242 -0
- package/coverage/lcov-report/src/components/activity/ActivityIntensity.tsx.html +257 -0
- package/coverage/lcov-report/src/components/activity/index.html +141 -0
- package/coverage/lcov-report/src/components/index.html +276 -0
- package/coverage/lcov-report/src/components/mood/Emotion.tsx.html +278 -0
- package/coverage/lcov-report/src/components/mood/MoodIcon.tsx.html +260 -0
- package/coverage/lcov-report/src/components/mood/index.html +126 -0
- package/coverage/lcov-report/src/index.html +111 -0
- package/coverage/lcov-report/src/locale/i18nUtils.ts.html +161 -0
- package/coverage/lcov-report/src/locale/index.html +111 -0
- package/coverage/lcov-report/src/utils/AttentionMessages.tsx.html +326 -0
- package/coverage/lcov-report/src/utils/Constants.ts.html +176 -0
- package/coverage/lcov-report/src/utils/RecommendationError.tsx.html +500 -0
- package/coverage/lcov-report/src/utils/RecommendationUtils.ts.html +467 -0
- package/coverage/lcov-report/src/utils/Translations.ts.html +107 -0
- package/coverage/lcov-report/src/utils/Utils.ts.html +263 -0
- package/coverage/lcov-report/src/utils/Validations.ts.html +815 -0
- package/coverage/lcov-report/src/utils/index.html +201 -0
- package/coverage/lcov.info +1581 -0
- package/jest.config.js +2 -1
- package/package.json +2 -2
- package/src/RecommendationScreen.d.ts +2 -3
- package/src/__tests__/components/Emotion.test.jsx +7 -8
- package/src/components/Icon.d.ts +13 -0
- package/src/components/Icon.jsx +42 -0
- package/src/components/LimitationMessage.d.ts +1 -2
- package/src/components/RecommendationModal.d.ts +2 -3
- package/src/components/RecommendationModal.jsx +2 -1
- package/src/components/activity/ActivityIntensity.jsx +4 -3
- package/src/utils/AttentionMessages.d.ts +16 -10
- package/src/utils/AttentionMessages.jsx +15 -10
- package/src/utils/RecommendationUtils.d.ts +2 -3
- package/src/utils/RecommendationUtils.js +10 -6
- package/src/utils/Utils.d.ts +1 -0
- package/src/utils/Utils.js +4 -0
- package/tsconfig.json +7 -5
- package/App.tsx +0 -140
- package/index.ts +0 -6
- package/src/RecommendationScreen.tsx +0 -461
- package/src/__tests__/RecommendationScreen.test.tsx +0 -1231
- package/src/__tests__/RecommendationUtils.test.ts +0 -332
- package/src/__tests__/Translate.test.tsx +0 -31
- package/src/__tests__/Utils.test.ts +0 -91
- package/src/__tests__/Validations.test.ts +0 -648
- package/src/__tests__/components/Activity.test.tsx +0 -163
- package/src/__tests__/components/Emotion.test.tsx +0 -110
- package/src/__tests__/components/Header.test.tsx +0 -44
- package/src/__tests__/components/InfoBars.test.tsx +0 -152
- package/src/__tests__/components/InvisibleNumberInput.test.tsx +0 -294
- package/src/__tests__/components/LimitationMessage.test.tsx +0 -58
- package/src/__tests__/components/MoodIcon.test.tsx +0 -45
- package/src/__tests__/components/RecommendationModal.test.tsx +0 -169
- package/src/__tests__/components/RecommendedCarbs.test.tsx +0 -234
- package/src/__tests__/components/RecommendedInsulin.test.tsx +0 -241
- package/src/__tests__/components/Remeasure.test.tsx +0 -97
- package/src/__tests__/components/TransferToLogbook.test.tsx +0 -38
- package/src/__tests__/components/TwoOptionModal.test.tsx +0 -72
- package/src/__tests__/utils.tsx +0 -144
- package/src/components/Header.tsx +0 -89
- package/src/components/Icon.js +0 -41
- package/src/components/InfoBars.tsx +0 -108
- package/src/components/InvisibleNumberInput.tsx +0 -98
- package/src/components/LimitationMessage.tsx +0 -38
- package/src/components/LineSeparator.tsx +0 -24
- package/src/components/RecentInsulin.tsx +0 -101
- package/src/components/RecommendationModal.tsx +0 -224
- package/src/components/RecommendedCarbs.tsx +0 -259
- package/src/components/RecommendedInsulin.tsx +0 -175
- package/src/components/Remeasure.tsx +0 -120
- package/src/components/TransferToLogbook.tsx +0 -100
- package/src/components/TwoOptionModal.tsx +0 -185
- package/src/components/activity/Activity.tsx +0 -77
- package/src/components/activity/ActivityIcon.tsx +0 -54
- package/src/components/activity/ActivityIntensity.tsx +0 -58
- package/src/components/mood/Emotion.tsx +0 -66
- package/src/components/mood/MoodIcon.tsx +0 -60
- package/src/locale/CleanLanguage.ts +0 -13
- package/src/locale/i18nUtils.ts +0 -27
- package/src/types/enum.ts +0 -108
- package/src/types/types.ts +0 -16
- package/src/utils/AttentionMessages.tsx +0 -75
- package/src/utils/Constants.ts +0 -32
- package/src/utils/RecommendationError.tsx +0 -140
- package/src/utils/RecommendationUtils.ts +0 -125
- package/src/utils/Translations.ts +0 -9
- package/src/utils/Utils.ts +0 -57
- package/src/utils/Validations.ts +0 -245
|
@@ -1,332 +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
|
-
import { generateDefaultActivitySettings, generateDefaultLogbook } from "./utils";
|
|
15
|
-
|
|
16
|
-
const ActivityIntensity = Activity.Enums.ActivityIntensity;
|
|
17
|
-
const { moderate } = ActivityIntensity;
|
|
18
|
-
|
|
19
|
-
describe(`Actions based on the blood glucose level:: InsulinSettingsUtils `, (): void => {
|
|
20
|
-
const logbookUnder15MMOL: logbookEntry = {
|
|
21
|
-
...generateDefaultLogbook(),
|
|
22
|
-
blood_glucose_millimolar: 14.9,
|
|
23
|
-
};
|
|
24
|
-
const logbookOver15MMOL: logbookEntry = {
|
|
25
|
-
...generateDefaultLogbook(),
|
|
26
|
-
blood_glucose_millimolar: 15.1,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const logbookWithNullBloodGlucose: logbookEntry = {
|
|
30
|
-
...generateDefaultLogbook(),
|
|
31
|
-
blood_glucose_millimolar: null,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const inactiveDate = new Date(Date.now() + Milliseconds.Minute * 15.1);
|
|
35
|
-
const activeDate = new Date();
|
|
36
|
-
const activeActivity: IActivityParams = {
|
|
37
|
-
activityDate: activeDate,
|
|
38
|
-
activityDuration: 10,
|
|
39
|
-
activityIntensity: moderate,
|
|
40
|
-
activitySettings: generateDefaultActivitySettings(),
|
|
41
|
-
};
|
|
42
|
-
const inactiveActivity: IActivityParams = { ...activeActivity, activityDate: inactiveDate };
|
|
43
|
-
|
|
44
|
-
interface IGetBGLevel {
|
|
45
|
-
bloodGlucoseValue: number;
|
|
46
|
-
bgLevel: BgLevel;
|
|
47
|
-
latestLogbookFrom6Hours: logbookEntry;
|
|
48
|
-
}
|
|
49
|
-
it.each`
|
|
50
|
-
bloodGlucoseValue | latestLogbookFrom6Hours | bgLevel
|
|
51
|
-
${1} | ${null} | ${BgLevel.UnsupportedBGLevel}
|
|
52
|
-
${33.4} | ${logbookOver15MMOL} | ${BgLevel.UnsupportedBGLevel}
|
|
53
|
-
${1.1} | ${null} | ${BgLevel.SevereHypoglycemia}
|
|
54
|
-
${2} | ${logbookOver15MMOL} | ${BgLevel.SevereHypoglycemia}
|
|
55
|
-
${3.5} | ${logbookOver15MMOL} | ${BgLevel.Hypoglycemia}
|
|
56
|
-
${3.6} | ${null} | ${BgLevel.MildHypoglycemia}
|
|
57
|
-
${4} | ${logbookOver15MMOL} | ${BgLevel.MildHypoglycemia}
|
|
58
|
-
${4.1} | ${null} | ${BgLevel.NormoglycemiaUnder5MMOL}
|
|
59
|
-
${5} | ${logbookUnder15MMOL} | ${BgLevel.Normoglycemia}
|
|
60
|
-
${9} | ${null} | ${BgLevel.MildHyperglycemia}
|
|
61
|
-
${15} | ${logbookOver15MMOL} | ${BgLevel.Hyperglycemia}
|
|
62
|
-
${15.1} | ${null} | ${BgLevel.Hyperglycemia}
|
|
63
|
-
${15.1} | ${logbookUnder15MMOL} | ${BgLevel.Hyperglycemia}
|
|
64
|
-
${27.2} | ${null} | ${BgLevel.Hyperglycemia}
|
|
65
|
-
${15.1} | ${logbookOver15MMOL} | ${BgLevel.SevereHyperglycemia}
|
|
66
|
-
${20} | ${logbookOver15MMOL} | ${BgLevel.SevereHyperglycemia}
|
|
67
|
-
`(
|
|
68
|
-
`return the correct BG level for $bloodGlucoseValue`,
|
|
69
|
-
({ bloodGlucoseValue, bgLevel, latestLogbookFrom6Hours }: IGetBGLevel): void => {
|
|
70
|
-
expect(getBGLevel(bloodGlucoseValue, latestLogbookFrom6Hours)).toBe(bgLevel);
|
|
71
|
-
},
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
interface IIsSevereGlycemia {
|
|
75
|
-
severeHyperglycemia: boolean;
|
|
76
|
-
latestLogbookFrom6Hours: logbookEntry | null;
|
|
77
|
-
}
|
|
78
|
-
it.each`
|
|
79
|
-
latestLogbookFrom6Hours | severeHyperglycemia
|
|
80
|
-
${null} | ${false}
|
|
81
|
-
${logbookOver15MMOL} | ${true}
|
|
82
|
-
${logbookUnder15MMOL} | ${false}
|
|
83
|
-
${undefined} | ${false}
|
|
84
|
-
${{}} | ${false}
|
|
85
|
-
${logbookWithNullBloodGlucose} | ${false}
|
|
86
|
-
`(`tests isSevereGlycemia method `, ({ latestLogbookFrom6Hours, severeHyperglycemia }: IIsSevereGlycemia): void => {
|
|
87
|
-
expect(isSevereHyperglycemia(latestLogbookFrom6Hours)).toBe(severeHyperglycemia);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
interface IIsActivityWithin15Minutes {
|
|
91
|
-
activity: IActivityParams;
|
|
92
|
-
within15Minutes: boolean;
|
|
93
|
-
}
|
|
94
|
-
it.each`
|
|
95
|
-
activity | within15Minutes
|
|
96
|
-
${activeActivity} | ${true}
|
|
97
|
-
${inactiveActivity} | ${false}
|
|
98
|
-
${activeActivity} | ${true}
|
|
99
|
-
${null} | ${false}
|
|
100
|
-
${undefined} | ${false}
|
|
101
|
-
`(`tests isActivityWithin15Minutes `, ({ activity, within15Minutes }: IIsActivityWithin15Minutes): void => {
|
|
102
|
-
expect(isActivityWithin15Minutes(activity)).toBe(within15Minutes);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
interface IGetAttentionMessage {
|
|
106
|
-
bgLevel: BgLevel;
|
|
107
|
-
activity: IActivityParams;
|
|
108
|
-
attentionMessage: AttentionMessage;
|
|
109
|
-
}
|
|
110
|
-
interface IGetAttentionMessageError {
|
|
111
|
-
bgLevel: BgLevel;
|
|
112
|
-
activity: IActivityParams;
|
|
113
|
-
attentionMessage: Error;
|
|
114
|
-
}
|
|
115
|
-
it.each`
|
|
116
|
-
bgLevel | activity | attentionMessage
|
|
117
|
-
${BgLevel.UnsupportedBGLevel} | ${activeActivity} | ${CurrentBGLError()}
|
|
118
|
-
${BgLevel.UnsupportedBGLevel} | ${inactiveActivity} | ${CurrentBGLError()}
|
|
119
|
-
`(
|
|
120
|
-
`Unsupported bg level throws error`,
|
|
121
|
-
({ bgLevel, activity, attentionMessage }: IGetAttentionMessageError): void => {
|
|
122
|
-
expect((): AttentionMessage | null => getAttentionMessage(bgLevel, activity)).toThrowError(
|
|
123
|
-
attentionMessage,
|
|
124
|
-
);
|
|
125
|
-
},
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
it.each`
|
|
129
|
-
bgLevel | activity | attentionMessage
|
|
130
|
-
${BgLevel.BGLevelNotProvided} | ${activeActivity} | ${null}
|
|
131
|
-
${BgLevel.SevereHypoglycemia} | ${activeActivity} | ${addPostponeActivityMessageUnder5MMOL(AttentionMessage.SevereHypoglycemia())}
|
|
132
|
-
${BgLevel.Hypoglycemia} | ${activeActivity} | ${addPostponeActivityMessageUnder5MMOL(AttentionMessage.Hypoglycemia())}
|
|
133
|
-
${BgLevel.MildHypoglycemia} | ${activeActivity} | ${addPostponeActivityMessageUnder5MMOL(AttentionMessage.MildHypoglycemia())}
|
|
134
|
-
${BgLevel.NormoglycemiaUnder5MMOL} | ${activeActivity} | ${AttentionMessage.NormoglycemiaActivityUnder5MMOL()}
|
|
135
|
-
${BgLevel.Normoglycemia} | ${activeActivity} | ${null}
|
|
136
|
-
${BgLevel.MildHyperglycemia} | ${activeActivity} | ${null}
|
|
137
|
-
${BgLevel.Hyperglycemia} | ${activeActivity} | ${AttentionMessage.HyperglycemiaActivity()}
|
|
138
|
-
${BgLevel.SevereHyperglycemia} | ${activeActivity} | ${AttentionMessage.SevereHyperglycemiaActivity()}
|
|
139
|
-
`(
|
|
140
|
-
`return the correct attention message with an active activity for $bgLevel`,
|
|
141
|
-
({ bgLevel, activity, attentionMessage }: IGetAttentionMessage): void => {
|
|
142
|
-
expect(getAttentionMessage(bgLevel, activity)).toBe(attentionMessage);
|
|
143
|
-
},
|
|
144
|
-
);
|
|
145
|
-
it.each`
|
|
146
|
-
bgLevel | activity | attentionMessage
|
|
147
|
-
${BgLevel.BGLevelNotProvided} | ${inactiveActivity} | ${null}
|
|
148
|
-
${BgLevel.SevereHypoglycemia} | ${inactiveActivity} | ${AttentionMessage.SevereHypoglycemia()}
|
|
149
|
-
${BgLevel.Hypoglycemia} | ${inactiveActivity} | ${AttentionMessage.Hypoglycemia()}
|
|
150
|
-
${BgLevel.MildHypoglycemia} | ${inactiveActivity} | ${AttentionMessage.MildHypoglycemia()}
|
|
151
|
-
${BgLevel.NormoglycemiaUnder5MMOL} | ${inactiveActivity} | ${null}
|
|
152
|
-
${BgLevel.Normoglycemia} | ${inactiveActivity} | ${null}
|
|
153
|
-
${BgLevel.MildHyperglycemia} | ${inactiveActivity} | ${null}
|
|
154
|
-
${BgLevel.Hyperglycemia} | ${inactiveActivity} | ${null}
|
|
155
|
-
${BgLevel.SevereHyperglycemia} | ${inactiveActivity} | ${AttentionMessage.SevereHyperglycemia()}
|
|
156
|
-
`(
|
|
157
|
-
`return the correct attention message with an inactive activity for $bgLevel`,
|
|
158
|
-
({ bgLevel, activity, attentionMessage }: IGetAttentionMessage): void => {
|
|
159
|
-
expect(getAttentionMessage(bgLevel, activity)).toBe(attentionMessage);
|
|
160
|
-
},
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
interface IGetReminder {
|
|
164
|
-
bgLevel: BgLevel;
|
|
165
|
-
activity: IActivityParams;
|
|
166
|
-
carbohydrates: number;
|
|
167
|
-
remeasureTime: number;
|
|
168
|
-
expectedReminder: number;
|
|
169
|
-
}
|
|
170
|
-
interface IGetReminderError {
|
|
171
|
-
bgLevel: BgLevel;
|
|
172
|
-
activity: IActivityParams;
|
|
173
|
-
carbohydrates: number;
|
|
174
|
-
remeasureTime: number;
|
|
175
|
-
expectedReminder: Error;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
it.each`
|
|
179
|
-
bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
|
|
180
|
-
${BgLevel.UnsupportedBGLevel} | ${activeActivity} | ${0} | ${1} | ${CurrentBGLError()}
|
|
181
|
-
${BgLevel.UnsupportedBGLevel} | ${inactiveActivity} | ${1} | ${2} | ${CurrentBGLError()}
|
|
182
|
-
${BgLevel.UnsupportedBGLevel} | ${null} | ${0} | ${undefined} | ${CurrentBGLError()}
|
|
183
|
-
${BgLevel.UnsupportedBGLevel} | ${null} | ${1} | ${0} | ${CurrentBGLError()}
|
|
184
|
-
`(
|
|
185
|
-
`Unsupported bg level throws error`,
|
|
186
|
-
({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }: IGetReminderError): void => {
|
|
187
|
-
expect((): number => getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toThrowError(
|
|
188
|
-
expectedReminder,
|
|
189
|
-
);
|
|
190
|
-
},
|
|
191
|
-
);
|
|
192
|
-
it.each`
|
|
193
|
-
bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
|
|
194
|
-
${BgLevel.BGLevelNotProvided} | ${activeActivity} | ${0} | ${1} | ${1}
|
|
195
|
-
${BgLevel.BGLevelNotProvided} | ${inactiveActivity} | ${0} | ${2.5} | ${2.5}
|
|
196
|
-
${BgLevel.BGLevelNotProvided} | ${null} | ${0} | ${2} | ${RecommendationReminders.ReminderOff}
|
|
197
|
-
`(
|
|
198
|
-
`return the correct BG reminder value for when the bgl is not provided`,
|
|
199
|
-
({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }: IGetReminder): void => {
|
|
200
|
-
expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
|
|
201
|
-
},
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
it.each`
|
|
205
|
-
bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
|
|
206
|
-
${BgLevel.SevereHypoglycemia} | ${activeActivity} | ${0} | ${1} | ${RecommendationReminders.Reminder15Minutes}
|
|
207
|
-
${BgLevel.SevereHypoglycemia} | ${inactiveActivity} | ${0} | ${2} | ${RecommendationReminders.Reminder15Minutes}
|
|
208
|
-
${BgLevel.SevereHypoglycemia} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.Reminder15Minutes}
|
|
209
|
-
${BgLevel.SevereHypoglycemia} | ${null} | ${1} | ${0} | ${RecommendationReminders.Reminder15Minutes}
|
|
210
|
-
`(
|
|
211
|
-
`return the correct BG reminder value for severe glycemia`,
|
|
212
|
-
({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }: IGetReminder): void => {
|
|
213
|
-
expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
|
|
214
|
-
},
|
|
215
|
-
);
|
|
216
|
-
|
|
217
|
-
it.each`
|
|
218
|
-
bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
|
|
219
|
-
${BgLevel.Hypoglycemia} | ${activeActivity} | ${0} | ${1} | ${RecommendationReminders.Reminder15Minutes}
|
|
220
|
-
${BgLevel.Hypoglycemia} | ${inactiveActivity} | ${1} | ${2} | ${RecommendationReminders.Reminder15Minutes}
|
|
221
|
-
${BgLevel.Hypoglycemia} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.Reminder15Minutes}
|
|
222
|
-
${BgLevel.Hypoglycemia} | ${null} | ${1} | ${0} | ${RecommendationReminders.Reminder15Minutes}
|
|
223
|
-
`(
|
|
224
|
-
`return the correct BG reminder value for hypoglycemia`,
|
|
225
|
-
({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }: IGetReminder): void => {
|
|
226
|
-
expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
|
|
227
|
-
},
|
|
228
|
-
);
|
|
229
|
-
|
|
230
|
-
it.each`
|
|
231
|
-
bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
|
|
232
|
-
${BgLevel.MildHypoglycemia} | ${activeActivity} | ${0} | ${1} | ${RecommendationReminders.Reminder15Minutes}
|
|
233
|
-
${BgLevel.MildHypoglycemia} | ${activeActivity} | ${1} | ${2} | ${RecommendationReminders.Reminder15Minutes}
|
|
234
|
-
${BgLevel.MildHypoglycemia} | ${null} | ${0} | ${3} | ${RecommendationReminders.Reminder15Minutes}
|
|
235
|
-
${BgLevel.MildHypoglycemia} | ${null} | ${1} | ${4} | ${RecommendationReminders.Reminder15Minutes}
|
|
236
|
-
`(
|
|
237
|
-
`return the correct BG reminder value for MildHypoglycemia`,
|
|
238
|
-
({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }: IGetReminder): void => {
|
|
239
|
-
expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
|
|
240
|
-
},
|
|
241
|
-
);
|
|
242
|
-
it.each`
|
|
243
|
-
bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
|
|
244
|
-
${BgLevel.NormoglycemiaUnder5MMOL} | ${activeActivity} | ${0} | ${0.5} | ${0.5}
|
|
245
|
-
${BgLevel.NormoglycemiaUnder5MMOL} | ${inactiveActivity} | ${1} | ${2} | ${2}
|
|
246
|
-
${BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${1} | ${6} | ${6}
|
|
247
|
-
${BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.ReminderOff}
|
|
248
|
-
${BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${1} | ${undefined} | ${RecommendationReminders.HediaReminderDefault}
|
|
249
|
-
${BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${0} | ${1} | ${RecommendationReminders.ReminderOff}
|
|
250
|
-
${BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${0} | ${2} | ${RecommendationReminders.ReminderOff}
|
|
251
|
-
`(
|
|
252
|
-
`return the correct BG reminder value for normoglycemia under 5 mmol/L`,
|
|
253
|
-
({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }: IGetReminder): void => {
|
|
254
|
-
expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
|
|
255
|
-
},
|
|
256
|
-
);
|
|
257
|
-
|
|
258
|
-
it.each`
|
|
259
|
-
bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
|
|
260
|
-
${BgLevel.Normoglycemia} | ${activeActivity} | ${0} | ${0.5} | ${0.5}
|
|
261
|
-
${BgLevel.Normoglycemia} | ${inactiveActivity} | ${1} | ${2} | ${2}
|
|
262
|
-
${BgLevel.Normoglycemia} | ${null} | ${1} | ${6} | ${6}
|
|
263
|
-
${BgLevel.Normoglycemia} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.ReminderOff}
|
|
264
|
-
${BgLevel.Normoglycemia} | ${null} | ${1} | ${undefined} | ${RecommendationReminders.HediaReminderDefault}
|
|
265
|
-
${BgLevel.Normoglycemia} | ${null} | ${0} | ${1} | ${RecommendationReminders.ReminderOff}
|
|
266
|
-
${BgLevel.Normoglycemia} | ${null} | ${0} | ${2} | ${RecommendationReminders.ReminderOff}
|
|
267
|
-
`(
|
|
268
|
-
`return the correct BG reminder value for normoglycemia`,
|
|
269
|
-
({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }: IGetReminder): void => {
|
|
270
|
-
expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
|
|
271
|
-
},
|
|
272
|
-
);
|
|
273
|
-
it.each`
|
|
274
|
-
bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
|
|
275
|
-
${BgLevel.MildHyperglycemia} | ${activeActivity} | ${0} | ${3.5} | ${3.5}
|
|
276
|
-
${BgLevel.MildHyperglycemia} | ${inactiveActivity} | ${1} | ${2} | ${2}
|
|
277
|
-
${BgLevel.MildHyperglycemia} | ${null} | ${1} | ${2.5} | ${2.5}
|
|
278
|
-
${BgLevel.MildHyperglycemia} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.ReminderOff}
|
|
279
|
-
${BgLevel.MildHyperglycemia} | ${null} | ${1} | ${undefined} | ${RecommendationReminders.HediaReminderDefault}
|
|
280
|
-
${BgLevel.MildHyperglycemia} | ${null} | ${0} | ${1} | ${RecommendationReminders.ReminderOff}
|
|
281
|
-
${BgLevel.MildHyperglycemia} | ${null} | ${0} | ${2} | ${RecommendationReminders.ReminderOff}
|
|
282
|
-
`(
|
|
283
|
-
`return the correct BG reminder value for mildglycemia`,
|
|
284
|
-
({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }: IGetReminder): void => {
|
|
285
|
-
expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
|
|
286
|
-
},
|
|
287
|
-
);
|
|
288
|
-
it.each`
|
|
289
|
-
bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
|
|
290
|
-
${BgLevel.Hyperglycemia} | ${activeActivity} | ${0} | ${1} | ${RecommendationReminders.Reminder15Minutes}
|
|
291
|
-
${BgLevel.Hyperglycemia} | ${inactiveActivity} | ${1} | ${2} | ${RecommendationReminders.Reminder60Minutes}
|
|
292
|
-
${BgLevel.Hyperglycemia} | ${activeActivity} | ${0} | ${undefined} | ${RecommendationReminders.Reminder15Minutes}
|
|
293
|
-
${BgLevel.Hyperglycemia} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.Reminder60Minutes}
|
|
294
|
-
${BgLevel.Hyperglycemia} | ${activeActivity} | ${1} | ${1} | ${RecommendationReminders.Reminder15Minutes}
|
|
295
|
-
${BgLevel.Hyperglycemia} | ${null} | ${1} | ${2} | ${RecommendationReminders.Reminder60Minutes}
|
|
296
|
-
`(
|
|
297
|
-
`return the correct BG reminder value for hyperglycemia`,
|
|
298
|
-
({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }: IGetReminder): void => {
|
|
299
|
-
expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
|
|
300
|
-
},
|
|
301
|
-
);
|
|
302
|
-
it.each`
|
|
303
|
-
bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
|
|
304
|
-
${BgLevel.SevereHyperglycemia} | ${activeActivity} | ${0} | ${2} | ${RecommendationReminders.Reminder15Minutes}
|
|
305
|
-
${BgLevel.SevereHyperglycemia} | ${inactiveActivity} | ${1} | ${2} | ${RecommendationReminders.Reminder60Minutes}
|
|
306
|
-
${BgLevel.SevereHyperglycemia} | ${null} | ${1} | ${undefined} | ${RecommendationReminders.Reminder60Minutes}
|
|
307
|
-
${BgLevel.SevereHyperglycemia} | ${inactiveActivity} | ${1} | ${2} | ${RecommendationReminders.Reminder60Minutes}
|
|
308
|
-
`(
|
|
309
|
-
`return the correct BG reminder value for severeglycemia `,
|
|
310
|
-
({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }: IGetReminder): void => {
|
|
311
|
-
expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
|
|
312
|
-
},
|
|
313
|
-
);
|
|
314
|
-
|
|
315
|
-
interface ILimitationMessage {
|
|
316
|
-
wasLimited: boolean;
|
|
317
|
-
activityReduction: number;
|
|
318
|
-
attentionMessage: AttentionMessage;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
it.each`
|
|
322
|
-
wasLimited | activityReduction | attentionMessage
|
|
323
|
-
${true} | ${0.25} | ${Messages.RecommendationWasLimitedActivity(0.25)}
|
|
324
|
-
${true} | ${0} | ${Messages.RecommendationWasLimited()}
|
|
325
|
-
${false} | ${0} | ${null}
|
|
326
|
-
`(
|
|
327
|
-
`return the correct attention message for $bgLevel`,
|
|
328
|
-
({ wasLimited, activityReduction, attentionMessage }: ILimitationMessage): void => {
|
|
329
|
-
expect(getLimitationMessage(wasLimited, activityReduction)).toBe(attentionMessage);
|
|
330
|
-
},
|
|
331
|
-
);
|
|
332
|
-
});
|
|
@@ -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.isInRange(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
|
-
});
|