@hedia/recommendation-screen 2.1.3-beta.6 → 2.1.3-beta.7
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/coverage/clover.xml +2 -2
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov-report/src/RecommendationScreen.tsx.html +1 -1
- package/coverage/lcov-report/src/__tests__/index.html +1 -1
- package/coverage/lcov-report/src/__tests__/utils.tsx.html +1 -1
- package/coverage/lcov-report/src/components/Header.tsx.html +1 -1
- package/coverage/lcov-report/src/components/InfoBars.tsx.html +1 -1
- package/coverage/lcov-report/src/components/InvisibleNumberInput.tsx.html +1 -1
- package/coverage/lcov-report/src/components/LimitationMessage.tsx.html +1 -1
- package/coverage/lcov-report/src/components/LineSeparator.tsx.html +1 -1
- package/coverage/lcov-report/src/components/RecentInsulin.tsx.html +1 -1
- package/coverage/lcov-report/src/components/RecommendationModal.tsx.html +1 -1
- package/coverage/lcov-report/src/components/RecommendedCarbs.tsx.html +1 -1
- package/coverage/lcov-report/src/components/RecommendedInsulin.tsx.html +1 -1
- package/coverage/lcov-report/src/components/Remeasure.tsx.html +1 -1
- package/coverage/lcov-report/src/components/TransferToLogbook.tsx.html +1 -1
- package/coverage/lcov-report/src/components/TwoOptionModal.tsx.html +1 -1
- package/coverage/lcov-report/src/components/activity/Activity.tsx.html +1 -1
- package/coverage/lcov-report/src/components/activity/ActivityIcon.tsx.html +1 -1
- package/coverage/lcov-report/src/components/activity/ActivityIntensity.tsx.html +1 -1
- package/coverage/lcov-report/src/components/activity/index.html +1 -1
- package/coverage/lcov-report/src/components/index.html +1 -1
- package/coverage/lcov-report/src/components/mood/Emotion.tsx.html +1 -1
- package/coverage/lcov-report/src/components/mood/MoodIcon.tsx.html +1 -1
- package/coverage/lcov-report/src/components/mood/index.html +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/locale/i18nUtils.ts.html +1 -1
- package/coverage/lcov-report/src/locale/index.html +1 -1
- package/coverage/lcov-report/src/utils/AttentionMessages.tsx.html +1 -1
- package/coverage/lcov-report/src/utils/Constants.ts.html +1 -1
- package/coverage/lcov-report/src/utils/RecommendationError.tsx.html +1 -1
- package/coverage/lcov-report/src/utils/RecommendationUtils.ts.html +1 -1
- package/coverage/lcov-report/src/utils/Translations.ts.html +1 -1
- package/coverage/lcov-report/src/utils/Utils.ts.html +1 -1
- package/coverage/lcov-report/src/utils/Validations.ts.html +1 -1
- package/coverage/lcov-report/src/utils/index.html +1 -1
- package/index.js +5 -31
- package/package.json +2 -1
- package/src/RecommendationScreen.js +76 -101
- package/src/__tests__/RecommendationScreen.test.js +404 -409
- package/src/__tests__/RecommendationUtils.test.js +117 -119
- package/src/__tests__/Translate.test.js +14 -16
- package/src/__tests__/Utils.test.js +16 -18
- package/src/__tests__/Validations.test.js +30 -51
- package/src/__tests__/components/Activity.test.js +51 -56
- package/src/__tests__/components/Emotion.test.js +28 -33
- package/src/__tests__/components/Header.test.js +24 -29
- package/src/__tests__/components/InfoBars.test.js +59 -64
- package/src/__tests__/components/InvisibleNumberInput.test.js +22 -27
- package/src/__tests__/components/LimitationMessage.test.js +28 -33
- package/src/__tests__/components/MoodIcon.test.js +9 -14
- package/src/__tests__/components/RecommendationModal.test.js +56 -61
- package/src/__tests__/components/RecommendedCarbs.test.js +58 -63
- package/src/__tests__/components/RecommendedInsulin.test.js +60 -65
- package/src/__tests__/components/Remeasure.test.js +32 -37
- package/src/__tests__/components/TransferToLogbook.test.js +15 -20
- package/src/__tests__/components/TwoOptionModal.test.js +22 -27
- package/src/__tests__/utils.js +22 -38
- package/src/components/Header.js +34 -41
- package/src/components/Icon.js +2 -8
- package/src/components/InfoBars.js +36 -43
- package/src/components/InvisibleNumberInput.js +5 -11
- package/src/components/LimitationMessage.js +18 -40
- package/src/components/LineSeparator.js +7 -13
- package/src/components/RecentInsulin.js +33 -39
- package/src/components/RecommendationModal.js +59 -85
- package/src/components/RecommendedCarbs.js +93 -99
- package/src/components/RecommendedInsulin.js +46 -52
- package/src/components/Remeasure.js +36 -42
- package/src/components/TransferToLogbook.js +20 -26
- package/src/components/TwoOptionModal.js +39 -65
- package/src/components/activity/Activity.js +42 -48
- package/src/components/activity/ActivityIcon.js +15 -21
- package/src/components/activity/ActivityIntensity.js +19 -25
- package/src/components/mood/Emotion.js +17 -23
- package/src/components/mood/MoodIcon.js +11 -17
- package/src/locale/i18nUtils.js +17 -24
- package/src/types/enum.js +28 -31
- package/src/types/types.js +1 -2
- package/src/utils/AttentionMessages.js +24 -32
- package/src/utils/Constants.js +23 -26
- package/src/utils/RecommendationError.js +28 -54
- package/src/utils/RecommendationUtils.js +60 -72
- package/src/utils/Translations.js +6 -9
- package/src/utils/Utils.js +8 -12
- package/src/utils/Validations.js +77 -107
- package/tsconfig.json +3 -3
|
@@ -1,55 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const utils_1 = require("./utils");
|
|
9
|
-
const ActivityIntensity = types_1.Activity.Enums.ActivityIntensity;
|
|
1
|
+
import { Activity, Milliseconds } from "@hedia/types";
|
|
2
|
+
import { BgLevel, RecommendationReminders } from "../types/enum";
|
|
3
|
+
import { addPostponeActivityMessageUnder5MMOL, AttentionMessage, Messages } from "../utils/AttentionMessages";
|
|
4
|
+
import { CurrentBGLError } from "../utils/RecommendationError";
|
|
5
|
+
import { getAttentionMessage, getBGLevel, getLimitationMessage, getReminder, isActivityWithin15Minutes, isSevereHyperglycemia, } from "../utils/RecommendationUtils";
|
|
6
|
+
import { generateDefaultActivitySettings, generateDefaultLogbook } from "./utils";
|
|
7
|
+
const ActivityIntensity = Activity.Enums.ActivityIntensity;
|
|
10
8
|
const { moderate } = ActivityIntensity;
|
|
11
9
|
describe(`Actions based on the blood glucose level:: InsulinSettingsUtils `, () => {
|
|
12
10
|
const logbookUnder15MMOL = {
|
|
13
|
-
...
|
|
11
|
+
...generateDefaultLogbook(),
|
|
14
12
|
blood_glucose_millimolar: 14.9,
|
|
15
13
|
};
|
|
16
14
|
const logbookOver15MMOL = {
|
|
17
|
-
...
|
|
15
|
+
...generateDefaultLogbook(),
|
|
18
16
|
blood_glucose_millimolar: 15.1,
|
|
19
17
|
};
|
|
20
18
|
const logbookWithNullBloodGlucose = {
|
|
21
|
-
...
|
|
19
|
+
...generateDefaultLogbook(),
|
|
22
20
|
blood_glucose_millimolar: null,
|
|
23
21
|
};
|
|
24
|
-
const inactiveDate = new Date(Date.now() +
|
|
22
|
+
const inactiveDate = new Date(Date.now() + Milliseconds.Minute * 15.1);
|
|
25
23
|
const activeDate = new Date();
|
|
26
24
|
const activeActivity = {
|
|
27
25
|
activityDate: activeDate,
|
|
28
26
|
activityDuration: 10,
|
|
29
27
|
activityIntensity: moderate,
|
|
30
|
-
activitySettings:
|
|
28
|
+
activitySettings: generateDefaultActivitySettings(),
|
|
31
29
|
};
|
|
32
30
|
const inactiveActivity = { ...activeActivity, activityDate: inactiveDate };
|
|
33
31
|
it.each `
|
|
34
32
|
bloodGlucoseValue | latestLogbookFrom6Hours | bgLevel
|
|
35
|
-
${1} | ${null} | ${
|
|
36
|
-
${33.4} | ${logbookOver15MMOL} | ${
|
|
37
|
-
${1.1} | ${null} | ${
|
|
38
|
-
${2} | ${logbookOver15MMOL} | ${
|
|
39
|
-
${3.5} | ${logbookOver15MMOL} | ${
|
|
40
|
-
${3.6} | ${null} | ${
|
|
41
|
-
${4} | ${logbookOver15MMOL} | ${
|
|
42
|
-
${4.1} | ${null} | ${
|
|
43
|
-
${5} | ${logbookUnder15MMOL} | ${
|
|
44
|
-
${9} | ${null} | ${
|
|
45
|
-
${15} | ${logbookOver15MMOL} | ${
|
|
46
|
-
${15.1} | ${null} | ${
|
|
47
|
-
${15.1} | ${logbookUnder15MMOL} | ${
|
|
48
|
-
${27.2} | ${null} | ${
|
|
49
|
-
${15.1} | ${logbookOver15MMOL} | ${
|
|
50
|
-
${20} | ${logbookOver15MMOL} | ${
|
|
33
|
+
${1} | ${null} | ${BgLevel.UnsupportedBGLevel}
|
|
34
|
+
${33.4} | ${logbookOver15MMOL} | ${BgLevel.UnsupportedBGLevel}
|
|
35
|
+
${1.1} | ${null} | ${BgLevel.SevereHypoglycemia}
|
|
36
|
+
${2} | ${logbookOver15MMOL} | ${BgLevel.SevereHypoglycemia}
|
|
37
|
+
${3.5} | ${logbookOver15MMOL} | ${BgLevel.Hypoglycemia}
|
|
38
|
+
${3.6} | ${null} | ${BgLevel.MildHypoglycemia}
|
|
39
|
+
${4} | ${logbookOver15MMOL} | ${BgLevel.MildHypoglycemia}
|
|
40
|
+
${4.1} | ${null} | ${BgLevel.NormoglycemiaUnder5MMOL}
|
|
41
|
+
${5} | ${logbookUnder15MMOL} | ${BgLevel.Normoglycemia}
|
|
42
|
+
${9} | ${null} | ${BgLevel.MildHyperglycemia}
|
|
43
|
+
${15} | ${logbookOver15MMOL} | ${BgLevel.Hyperglycemia}
|
|
44
|
+
${15.1} | ${null} | ${BgLevel.Hyperglycemia}
|
|
45
|
+
${15.1} | ${logbookUnder15MMOL} | ${BgLevel.Hyperglycemia}
|
|
46
|
+
${27.2} | ${null} | ${BgLevel.Hyperglycemia}
|
|
47
|
+
${15.1} | ${logbookOver15MMOL} | ${BgLevel.SevereHyperglycemia}
|
|
48
|
+
${20} | ${logbookOver15MMOL} | ${BgLevel.SevereHyperglycemia}
|
|
51
49
|
`(`return the correct BG level for $bloodGlucoseValue`, ({ bloodGlucoseValue, bgLevel, latestLogbookFrom6Hours }) => {
|
|
52
|
-
expect(
|
|
50
|
+
expect(getBGLevel(bloodGlucoseValue, latestLogbookFrom6Hours)).toBe(bgLevel);
|
|
53
51
|
});
|
|
54
52
|
it.each `
|
|
55
53
|
latestLogbookFrom6Hours | severeHyperglycemia
|
|
@@ -60,7 +58,7 @@ describe(`Actions based on the blood glucose level:: InsulinSettingsUtils `, ()
|
|
|
60
58
|
${{}} | ${false}
|
|
61
59
|
${logbookWithNullBloodGlucose} | ${false}
|
|
62
60
|
`(`tests isSevereGlycemia method `, ({ latestLogbookFrom6Hours, severeHyperglycemia }) => {
|
|
63
|
-
expect(
|
|
61
|
+
expect(isSevereHyperglycemia(latestLogbookFrom6Hours)).toBe(severeHyperglycemia);
|
|
64
62
|
});
|
|
65
63
|
it.each `
|
|
66
64
|
activity | within15Minutes
|
|
@@ -70,149 +68,149 @@ describe(`Actions based on the blood glucose level:: InsulinSettingsUtils `, ()
|
|
|
70
68
|
${null} | ${false}
|
|
71
69
|
${undefined} | ${false}
|
|
72
70
|
`(`tests isActivityWithin15Minutes `, ({ activity, within15Minutes }) => {
|
|
73
|
-
expect(
|
|
71
|
+
expect(isActivityWithin15Minutes(activity)).toBe(within15Minutes);
|
|
74
72
|
});
|
|
75
73
|
it.each `
|
|
76
74
|
bgLevel | activity | attentionMessage
|
|
77
|
-
${
|
|
78
|
-
${
|
|
75
|
+
${BgLevel.UnsupportedBGLevel} | ${activeActivity} | ${CurrentBGLError()}
|
|
76
|
+
${BgLevel.UnsupportedBGLevel} | ${inactiveActivity} | ${CurrentBGLError()}
|
|
79
77
|
`(`Unsupported bg level throws error`, ({ bgLevel, activity, attentionMessage }) => {
|
|
80
|
-
expect(() =>
|
|
78
|
+
expect(() => getAttentionMessage(bgLevel, activity)).toThrowError(attentionMessage);
|
|
81
79
|
});
|
|
82
80
|
it.each `
|
|
83
81
|
bgLevel | activity | attentionMessage
|
|
84
|
-
${
|
|
85
|
-
${
|
|
86
|
-
${
|
|
87
|
-
${
|
|
88
|
-
${
|
|
89
|
-
${
|
|
90
|
-
${
|
|
91
|
-
${
|
|
92
|
-
${
|
|
82
|
+
${BgLevel.BGLevelNotProvided} | ${activeActivity} | ${null}
|
|
83
|
+
${BgLevel.SevereHypoglycemia} | ${activeActivity} | ${addPostponeActivityMessageUnder5MMOL(AttentionMessage.SevereHypoglycemia())}
|
|
84
|
+
${BgLevel.Hypoglycemia} | ${activeActivity} | ${addPostponeActivityMessageUnder5MMOL(AttentionMessage.Hypoglycemia())}
|
|
85
|
+
${BgLevel.MildHypoglycemia} | ${activeActivity} | ${addPostponeActivityMessageUnder5MMOL(AttentionMessage.MildHypoglycemia())}
|
|
86
|
+
${BgLevel.NormoglycemiaUnder5MMOL} | ${activeActivity} | ${AttentionMessage.NormoglycemiaActivityUnder5MMOL()}
|
|
87
|
+
${BgLevel.Normoglycemia} | ${activeActivity} | ${null}
|
|
88
|
+
${BgLevel.MildHyperglycemia} | ${activeActivity} | ${null}
|
|
89
|
+
${BgLevel.Hyperglycemia} | ${activeActivity} | ${AttentionMessage.HyperglycemiaActivity()}
|
|
90
|
+
${BgLevel.SevereHyperglycemia} | ${activeActivity} | ${AttentionMessage.SevereHyperglycemiaActivity()}
|
|
93
91
|
`(`return the correct attention message with an active activity for $bgLevel`, ({ bgLevel, activity, attentionMessage }) => {
|
|
94
|
-
expect(
|
|
92
|
+
expect(getAttentionMessage(bgLevel, activity)).toBe(attentionMessage);
|
|
95
93
|
});
|
|
96
94
|
it.each `
|
|
97
95
|
bgLevel | activity | attentionMessage
|
|
98
|
-
${
|
|
99
|
-
${
|
|
100
|
-
${
|
|
101
|
-
${
|
|
102
|
-
${
|
|
103
|
-
${
|
|
104
|
-
${
|
|
105
|
-
${
|
|
106
|
-
${
|
|
96
|
+
${BgLevel.BGLevelNotProvided} | ${inactiveActivity} | ${null}
|
|
97
|
+
${BgLevel.SevereHypoglycemia} | ${inactiveActivity} | ${AttentionMessage.SevereHypoglycemia()}
|
|
98
|
+
${BgLevel.Hypoglycemia} | ${inactiveActivity} | ${AttentionMessage.Hypoglycemia()}
|
|
99
|
+
${BgLevel.MildHypoglycemia} | ${inactiveActivity} | ${AttentionMessage.MildHypoglycemia()}
|
|
100
|
+
${BgLevel.NormoglycemiaUnder5MMOL} | ${inactiveActivity} | ${null}
|
|
101
|
+
${BgLevel.Normoglycemia} | ${inactiveActivity} | ${null}
|
|
102
|
+
${BgLevel.MildHyperglycemia} | ${inactiveActivity} | ${null}
|
|
103
|
+
${BgLevel.Hyperglycemia} | ${inactiveActivity} | ${null}
|
|
104
|
+
${BgLevel.SevereHyperglycemia} | ${inactiveActivity} | ${AttentionMessage.SevereHyperglycemia()}
|
|
107
105
|
`(`return the correct attention message with an inactive activity for $bgLevel`, ({ bgLevel, activity, attentionMessage }) => {
|
|
108
|
-
expect(
|
|
106
|
+
expect(getAttentionMessage(bgLevel, activity)).toBe(attentionMessage);
|
|
109
107
|
});
|
|
110
108
|
it.each `
|
|
111
109
|
bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
|
|
112
|
-
${
|
|
113
|
-
${
|
|
114
|
-
${
|
|
115
|
-
${
|
|
110
|
+
${BgLevel.UnsupportedBGLevel} | ${activeActivity} | ${0} | ${1} | ${CurrentBGLError()}
|
|
111
|
+
${BgLevel.UnsupportedBGLevel} | ${inactiveActivity} | ${1} | ${2} | ${CurrentBGLError()}
|
|
112
|
+
${BgLevel.UnsupportedBGLevel} | ${null} | ${0} | ${undefined} | ${CurrentBGLError()}
|
|
113
|
+
${BgLevel.UnsupportedBGLevel} | ${null} | ${1} | ${0} | ${CurrentBGLError()}
|
|
116
114
|
`(`Unsupported bg level throws error`, ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }) => {
|
|
117
|
-
expect(() =>
|
|
115
|
+
expect(() => getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toThrowError(expectedReminder);
|
|
118
116
|
});
|
|
119
117
|
it.each `
|
|
120
118
|
bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
|
|
121
|
-
${
|
|
122
|
-
${
|
|
123
|
-
${
|
|
119
|
+
${BgLevel.BGLevelNotProvided} | ${activeActivity} | ${0} | ${1} | ${1}
|
|
120
|
+
${BgLevel.BGLevelNotProvided} | ${inactiveActivity} | ${0} | ${2.5} | ${2.5}
|
|
121
|
+
${BgLevel.BGLevelNotProvided} | ${null} | ${0} | ${2} | ${RecommendationReminders.ReminderOff}
|
|
124
122
|
`(`return the correct BG reminder value for when the bgl is not provided`, ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }) => {
|
|
125
|
-
expect(
|
|
123
|
+
expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
|
|
126
124
|
});
|
|
127
125
|
it.each `
|
|
128
126
|
bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
|
|
129
|
-
${
|
|
130
|
-
${
|
|
131
|
-
${
|
|
132
|
-
${
|
|
127
|
+
${BgLevel.SevereHypoglycemia} | ${activeActivity} | ${0} | ${1} | ${RecommendationReminders.Reminder15Minutes}
|
|
128
|
+
${BgLevel.SevereHypoglycemia} | ${inactiveActivity} | ${0} | ${2} | ${RecommendationReminders.Reminder15Minutes}
|
|
129
|
+
${BgLevel.SevereHypoglycemia} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.Reminder15Minutes}
|
|
130
|
+
${BgLevel.SevereHypoglycemia} | ${null} | ${1} | ${0} | ${RecommendationReminders.Reminder15Minutes}
|
|
133
131
|
`(`return the correct BG reminder value for severe glycemia`, ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }) => {
|
|
134
|
-
expect(
|
|
132
|
+
expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
|
|
135
133
|
});
|
|
136
134
|
it.each `
|
|
137
135
|
bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
|
|
138
|
-
${
|
|
139
|
-
${
|
|
140
|
-
${
|
|
141
|
-
${
|
|
136
|
+
${BgLevel.Hypoglycemia} | ${activeActivity} | ${0} | ${1} | ${RecommendationReminders.Reminder15Minutes}
|
|
137
|
+
${BgLevel.Hypoglycemia} | ${inactiveActivity} | ${1} | ${2} | ${RecommendationReminders.Reminder15Minutes}
|
|
138
|
+
${BgLevel.Hypoglycemia} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.Reminder15Minutes}
|
|
139
|
+
${BgLevel.Hypoglycemia} | ${null} | ${1} | ${0} | ${RecommendationReminders.Reminder15Minutes}
|
|
142
140
|
`(`return the correct BG reminder value for hypoglycemia`, ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }) => {
|
|
143
|
-
expect(
|
|
141
|
+
expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
|
|
144
142
|
});
|
|
145
143
|
it.each `
|
|
146
144
|
bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
|
|
147
|
-
${
|
|
148
|
-
${
|
|
149
|
-
${
|
|
150
|
-
${
|
|
145
|
+
${BgLevel.MildHypoglycemia} | ${activeActivity} | ${0} | ${1} | ${RecommendationReminders.Reminder15Minutes}
|
|
146
|
+
${BgLevel.MildHypoglycemia} | ${activeActivity} | ${1} | ${2} | ${RecommendationReminders.Reminder15Minutes}
|
|
147
|
+
${BgLevel.MildHypoglycemia} | ${null} | ${0} | ${3} | ${RecommendationReminders.Reminder15Minutes}
|
|
148
|
+
${BgLevel.MildHypoglycemia} | ${null} | ${1} | ${4} | ${RecommendationReminders.Reminder15Minutes}
|
|
151
149
|
`(`return the correct BG reminder value for MildHypoglycemia`, ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }) => {
|
|
152
|
-
expect(
|
|
150
|
+
expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
|
|
153
151
|
});
|
|
154
152
|
it.each `
|
|
155
153
|
bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
|
|
156
|
-
${
|
|
157
|
-
${
|
|
158
|
-
${
|
|
159
|
-
${
|
|
160
|
-
${
|
|
161
|
-
${
|
|
162
|
-
${
|
|
154
|
+
${BgLevel.NormoglycemiaUnder5MMOL} | ${activeActivity} | ${0} | ${0.5} | ${0.5}
|
|
155
|
+
${BgLevel.NormoglycemiaUnder5MMOL} | ${inactiveActivity} | ${1} | ${2} | ${2}
|
|
156
|
+
${BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${1} | ${6} | ${6}
|
|
157
|
+
${BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.ReminderOff}
|
|
158
|
+
${BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${1} | ${undefined} | ${RecommendationReminders.HediaReminderDefault}
|
|
159
|
+
${BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${0} | ${1} | ${RecommendationReminders.ReminderOff}
|
|
160
|
+
${BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${0} | ${2} | ${RecommendationReminders.ReminderOff}
|
|
163
161
|
`(`return the correct BG reminder value for normoglycemia under 5 mmol/L`, ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }) => {
|
|
164
|
-
expect(
|
|
162
|
+
expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
|
|
165
163
|
});
|
|
166
164
|
it.each `
|
|
167
165
|
bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
|
|
168
|
-
${
|
|
169
|
-
${
|
|
170
|
-
${
|
|
171
|
-
${
|
|
172
|
-
${
|
|
173
|
-
${
|
|
174
|
-
${
|
|
166
|
+
${BgLevel.Normoglycemia} | ${activeActivity} | ${0} | ${0.5} | ${0.5}
|
|
167
|
+
${BgLevel.Normoglycemia} | ${inactiveActivity} | ${1} | ${2} | ${2}
|
|
168
|
+
${BgLevel.Normoglycemia} | ${null} | ${1} | ${6} | ${6}
|
|
169
|
+
${BgLevel.Normoglycemia} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.ReminderOff}
|
|
170
|
+
${BgLevel.Normoglycemia} | ${null} | ${1} | ${undefined} | ${RecommendationReminders.HediaReminderDefault}
|
|
171
|
+
${BgLevel.Normoglycemia} | ${null} | ${0} | ${1} | ${RecommendationReminders.ReminderOff}
|
|
172
|
+
${BgLevel.Normoglycemia} | ${null} | ${0} | ${2} | ${RecommendationReminders.ReminderOff}
|
|
175
173
|
`(`return the correct BG reminder value for normoglycemia`, ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }) => {
|
|
176
|
-
expect(
|
|
174
|
+
expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
|
|
177
175
|
});
|
|
178
176
|
it.each `
|
|
179
177
|
bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
|
|
180
|
-
${
|
|
181
|
-
${
|
|
182
|
-
${
|
|
183
|
-
${
|
|
184
|
-
${
|
|
185
|
-
${
|
|
186
|
-
${
|
|
178
|
+
${BgLevel.MildHyperglycemia} | ${activeActivity} | ${0} | ${3.5} | ${3.5}
|
|
179
|
+
${BgLevel.MildHyperglycemia} | ${inactiveActivity} | ${1} | ${2} | ${2}
|
|
180
|
+
${BgLevel.MildHyperglycemia} | ${null} | ${1} | ${2.5} | ${2.5}
|
|
181
|
+
${BgLevel.MildHyperglycemia} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.ReminderOff}
|
|
182
|
+
${BgLevel.MildHyperglycemia} | ${null} | ${1} | ${undefined} | ${RecommendationReminders.HediaReminderDefault}
|
|
183
|
+
${BgLevel.MildHyperglycemia} | ${null} | ${0} | ${1} | ${RecommendationReminders.ReminderOff}
|
|
184
|
+
${BgLevel.MildHyperglycemia} | ${null} | ${0} | ${2} | ${RecommendationReminders.ReminderOff}
|
|
187
185
|
`(`return the correct BG reminder value for mildglycemia`, ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }) => {
|
|
188
|
-
expect(
|
|
186
|
+
expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
|
|
189
187
|
});
|
|
190
188
|
it.each `
|
|
191
189
|
bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
|
|
192
|
-
${
|
|
193
|
-
${
|
|
194
|
-
${
|
|
195
|
-
${
|
|
196
|
-
${
|
|
197
|
-
${
|
|
190
|
+
${BgLevel.Hyperglycemia} | ${activeActivity} | ${0} | ${1} | ${RecommendationReminders.Reminder15Minutes}
|
|
191
|
+
${BgLevel.Hyperglycemia} | ${inactiveActivity} | ${1} | ${2} | ${RecommendationReminders.Reminder60Minutes}
|
|
192
|
+
${BgLevel.Hyperglycemia} | ${activeActivity} | ${0} | ${undefined} | ${RecommendationReminders.Reminder15Minutes}
|
|
193
|
+
${BgLevel.Hyperglycemia} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.Reminder60Minutes}
|
|
194
|
+
${BgLevel.Hyperglycemia} | ${activeActivity} | ${1} | ${1} | ${RecommendationReminders.Reminder15Minutes}
|
|
195
|
+
${BgLevel.Hyperglycemia} | ${null} | ${1} | ${2} | ${RecommendationReminders.Reminder60Minutes}
|
|
198
196
|
`(`return the correct BG reminder value for hyperglycemia`, ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }) => {
|
|
199
|
-
expect(
|
|
197
|
+
expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
|
|
200
198
|
});
|
|
201
199
|
it.each `
|
|
202
200
|
bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
|
|
203
|
-
${
|
|
204
|
-
${
|
|
205
|
-
${
|
|
206
|
-
${
|
|
201
|
+
${BgLevel.SevereHyperglycemia} | ${activeActivity} | ${0} | ${2} | ${RecommendationReminders.Reminder15Minutes}
|
|
202
|
+
${BgLevel.SevereHyperglycemia} | ${inactiveActivity} | ${1} | ${2} | ${RecommendationReminders.Reminder60Minutes}
|
|
203
|
+
${BgLevel.SevereHyperglycemia} | ${null} | ${1} | ${undefined} | ${RecommendationReminders.Reminder60Minutes}
|
|
204
|
+
${BgLevel.SevereHyperglycemia} | ${inactiveActivity} | ${1} | ${2} | ${RecommendationReminders.Reminder60Minutes}
|
|
207
205
|
`(`return the correct BG reminder value for severeglycemia `, ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }) => {
|
|
208
|
-
expect(
|
|
206
|
+
expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
|
|
209
207
|
});
|
|
210
208
|
it.each `
|
|
211
209
|
wasLimited | activityReduction | attentionMessage
|
|
212
|
-
${true} | ${0.25} | ${
|
|
213
|
-
${true} | ${0} | ${
|
|
210
|
+
${true} | ${0.25} | ${Messages.RecommendationWasLimitedActivity(0.25)}
|
|
211
|
+
${true} | ${0} | ${Messages.RecommendationWasLimited()}
|
|
214
212
|
${false} | ${0} | ${null}
|
|
215
213
|
`(`return the correct attention message for $bgLevel`, ({ wasLimited, activityReduction, attentionMessage }) => {
|
|
216
|
-
expect(
|
|
214
|
+
expect(getLimitationMessage(wasLimited, activityReduction)).toBe(attentionMessage);
|
|
217
215
|
});
|
|
218
216
|
});
|
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
// @ts-nocheck
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { Languages } from "@hedia/types";
|
|
3
|
+
import { changeLanguage, i18n } from "../locale/i18nUtils";
|
|
6
4
|
describe(`Translation Utils`, () => {
|
|
7
5
|
test(`Same instance`, () => {
|
|
8
|
-
expect(
|
|
6
|
+
expect(i18n).toBe(i18n);
|
|
9
7
|
});
|
|
10
8
|
test.each `
|
|
11
9
|
locale | text
|
|
12
|
-
${
|
|
13
|
-
${
|
|
14
|
-
${
|
|
15
|
-
${
|
|
16
|
-
${
|
|
17
|
-
${
|
|
10
|
+
${Languages.da} | ${`Dansk`}
|
|
11
|
+
${Languages.en} | ${`English`}
|
|
12
|
+
${Languages.de} | ${`Deutsch`}
|
|
13
|
+
${Languages.es} | ${`Español`}
|
|
14
|
+
${Languages.it} | ${`Italiano`}
|
|
15
|
+
${Languages.fr} | ${`Français`}
|
|
18
16
|
`(`Change to the right language; $locale`, ({ locale, text }) => {
|
|
19
|
-
expect(
|
|
17
|
+
expect(changeLanguage(locale).language).toBe(text);
|
|
20
18
|
});
|
|
21
19
|
test.each `
|
|
22
20
|
locale | text
|
|
23
|
-
${
|
|
24
|
-
${
|
|
25
|
-
${
|
|
21
|
+
${Languages.nl} | ${Languages.en}
|
|
22
|
+
${Languages.jp} | ${Languages.en}
|
|
23
|
+
${Languages.ro} | ${Languages.en}
|
|
26
24
|
`(`Unsupported language defaults to english; $locale`, ({ locale, text }) => {
|
|
27
|
-
expect(
|
|
25
|
+
expect(changeLanguage(locale).language).toBe(text);
|
|
28
26
|
});
|
|
29
27
|
});
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const Utils_1 = require("../utils/Utils");
|
|
6
|
-
const InjectionMethod = types_1.UserSettings.Enums.InjectionMethod;
|
|
1
|
+
import { UserSettings } from "@hedia/types";
|
|
2
|
+
import { ACTIVITY_DURATION_MINUTES_LIMITS } from "../utils/Constants";
|
|
3
|
+
import { Utils } from "../utils/Utils";
|
|
4
|
+
const InjectionMethod = UserSettings.Enums.InjectionMethod;
|
|
7
5
|
const { PenHalf, PenWhole, Pump } = InjectionMethod;
|
|
8
6
|
describe(`Utils helper functions`, () => {
|
|
9
7
|
test.each `
|
|
@@ -12,7 +10,7 @@ describe(`Utils helper functions`, () => {
|
|
|
12
10
|
${PenHalf} | ${2}
|
|
13
11
|
${Pump} | ${10}
|
|
14
12
|
`(`Get correct rounding for $method`, ({ expected, method }) => {
|
|
15
|
-
expect(
|
|
13
|
+
expect(Utils.getRounding(method)).toBe(expected);
|
|
16
14
|
});
|
|
17
15
|
test.each `
|
|
18
16
|
value | method | expected
|
|
@@ -29,23 +27,23 @@ describe(`Utils helper functions`, () => {
|
|
|
29
27
|
${-1.45} | ${PenHalf} | ${-1.5}
|
|
30
28
|
${-1.45} | ${Pump} | ${-1.4}
|
|
31
29
|
`(`Rounding $value using $method to $expected`, ({ expected, method, value, }) => {
|
|
32
|
-
expect(
|
|
30
|
+
expect(Utils.roundValue(value, method)).toBe(expected);
|
|
33
31
|
});
|
|
34
32
|
const customInterval = { min: 0, max: 75.5 };
|
|
35
33
|
test.each `
|
|
36
34
|
value | interval | expected
|
|
37
|
-
${null} | ${
|
|
38
|
-
${undefined} | ${
|
|
39
|
-
${
|
|
40
|
-
${34} | ${
|
|
41
|
-
${
|
|
35
|
+
${null} | ${ACTIVITY_DURATION_MINUTES_LIMITS} | ${false}
|
|
36
|
+
${undefined} | ${ACTIVITY_DURATION_MINUTES_LIMITS} | ${false}
|
|
37
|
+
${ACTIVITY_DURATION_MINUTES_LIMITS.max} | ${ACTIVITY_DURATION_MINUTES_LIMITS} | ${true}
|
|
38
|
+
${34} | ${ACTIVITY_DURATION_MINUTES_LIMITS} | ${true}
|
|
39
|
+
${ACTIVITY_DURATION_MINUTES_LIMITS.min} | ${ACTIVITY_DURATION_MINUTES_LIMITS} | ${true}
|
|
42
40
|
${0} | ${customInterval} | ${true}
|
|
43
41
|
${25.1} | ${customInterval} | ${true}
|
|
44
42
|
${75.6} | ${customInterval} | ${false}
|
|
45
|
-
${-1} | ${
|
|
46
|
-
${3601} | ${
|
|
43
|
+
${-1} | ${ACTIVITY_DURATION_MINUTES_LIMITS} | ${false}
|
|
44
|
+
${3601} | ${ACTIVITY_DURATION_MINUTES_LIMITS} | ${false}
|
|
47
45
|
`(`Check if a number is in the interval`, ({ value, interval, expected }) => {
|
|
48
|
-
expect(
|
|
46
|
+
expect(Utils.isInRange(value, interval)).toBe(expected);
|
|
49
47
|
});
|
|
50
48
|
test.each `
|
|
51
49
|
value | expected
|
|
@@ -54,7 +52,7 @@ describe(`Utils helper functions`, () => {
|
|
|
54
52
|
${1.11} | ${20}
|
|
55
53
|
${12.325} | ${222}
|
|
56
54
|
`(`Convert blood glucose from mmol/L to mg/dl`, ({ value, expected }) => {
|
|
57
|
-
expect(
|
|
55
|
+
expect(Utils.convertBGLToMGDL(value)).toBe(expected);
|
|
58
56
|
});
|
|
59
57
|
test.each `
|
|
60
58
|
value | expected
|
|
@@ -63,6 +61,6 @@ describe(`Utils helper functions`, () => {
|
|
|
63
61
|
${1.11} | ${12}
|
|
64
62
|
${12.325} | ${128}
|
|
65
63
|
`(`Convert from mmol/L to mg/dl`, ({ value, expected }) => {
|
|
66
|
-
expect(
|
|
64
|
+
expect(Utils.convertBKLToMGDL(value)).toBe(expected);
|
|
67
65
|
});
|
|
68
66
|
});
|
|
@@ -1,32 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const types_1 = require("@hedia/types");
|
|
23
|
-
const Constants_1 = require("../utils/Constants");
|
|
24
|
-
const Errors = __importStar(require("../utils/RecommendationError"));
|
|
25
|
-
const Validations = __importStar(require("../utils/Validations"));
|
|
26
|
-
const utils_1 = require("./utils");
|
|
27
|
-
const ActivityEnum = types_1.Activity.Enums.ActivityEnum;
|
|
28
|
-
const ActivityIntensity = types_1.Activity.Enums.ActivityIntensity;
|
|
29
|
-
const InjectionMethod = types_1.UserSettings.Enums.InjectionMethod;
|
|
1
|
+
import { Activity, BloodGlucoseUnit, BloodKetonesUnit, Languages, Milliseconds, UserSettings } from "@hedia/types";
|
|
2
|
+
import { FOUR_HOURS_SECONDS } from "../utils/Constants";
|
|
3
|
+
import * as Errors from "../utils/RecommendationError";
|
|
4
|
+
import * as Validations from "../utils/Validations";
|
|
5
|
+
import { generateDefaultActivitySettings, generateDefaultLogbook } from "./utils";
|
|
6
|
+
const ActivityEnum = Activity.Enums.ActivityEnum;
|
|
7
|
+
const ActivityIntensity = Activity.Enums.ActivityIntensity;
|
|
8
|
+
const InjectionMethod = UserSettings.Enums.InjectionMethod;
|
|
30
9
|
const { light, moderate, hard } = ActivityIntensity;
|
|
31
10
|
describe(`Test validations functions for the recommendation props`, () => {
|
|
32
11
|
test.each `
|
|
@@ -47,8 +26,8 @@ describe(`Test validations functions for the recommendation props`, () => {
|
|
|
47
26
|
});
|
|
48
27
|
test.each `
|
|
49
28
|
validUnit
|
|
50
|
-
${
|
|
51
|
-
${
|
|
29
|
+
${BloodGlucoseUnit.MG_DL}
|
|
30
|
+
${BloodGlucoseUnit.MMOL_L}
|
|
52
31
|
`(`Validation checking on blood glucose unit types $validUnit`, ({ validUnit }) => {
|
|
53
32
|
expect(() => Validations.checkBGLUnit(validUnit)).not.toThrowError(Errors.BloodGlucoseUnitError());
|
|
54
33
|
});
|
|
@@ -62,8 +41,8 @@ describe(`Test validations functions for the recommendation props`, () => {
|
|
|
62
41
|
});
|
|
63
42
|
test.each `
|
|
64
43
|
validKetoneProps
|
|
65
|
-
${{ bloodKetoneUnit:
|
|
66
|
-
${{ bloodKetoneUnit:
|
|
44
|
+
${{ bloodKetoneUnit: BloodKetonesUnit.MG_DL, currentBKL: 0 }}
|
|
45
|
+
${{ bloodKetoneUnit: BloodKetonesUnit.MMOL_L, currentBKL: null }}
|
|
67
46
|
${{ bloodKetoneUnit: null, currentBKL: null }}
|
|
68
47
|
`(`Validation checking on valid blood ketones props $validKetoneProps`, ({ validKetoneProps }) => {
|
|
69
48
|
const { bloodKetoneUnit, currentBKL } = validKetoneProps;
|
|
@@ -79,8 +58,8 @@ describe(`Test validations functions for the recommendation props`, () => {
|
|
|
79
58
|
});
|
|
80
59
|
test.each `
|
|
81
60
|
validUnit
|
|
82
|
-
${
|
|
83
|
-
${
|
|
61
|
+
${BloodKetonesUnit.MG_DL}
|
|
62
|
+
${BloodKetonesUnit.MMOL_L}
|
|
84
63
|
${null}
|
|
85
64
|
`(`Validation checking on blood ketones unit types $validUnit`, ({ validUnit }) => {
|
|
86
65
|
expect(() => Validations.checkBKLUnit(validUnit)).not.toThrowError(Errors.BloodKetoneUnitError());
|
|
@@ -95,12 +74,12 @@ describe(`Test validations functions for the recommendation props`, () => {
|
|
|
95
74
|
});
|
|
96
75
|
test.each `
|
|
97
76
|
validLanguage
|
|
98
|
-
${
|
|
99
|
-
${
|
|
100
|
-
${
|
|
101
|
-
${
|
|
102
|
-
${
|
|
103
|
-
${
|
|
77
|
+
${Languages.da}
|
|
78
|
+
${Languages.en}
|
|
79
|
+
${Languages.de}
|
|
80
|
+
${Languages.es}
|
|
81
|
+
${Languages.it}
|
|
82
|
+
${Languages.fr}
|
|
104
83
|
`(`Validation checking on supported languages types $validLanguage`, ({ validLanguage }) => {
|
|
105
84
|
expect(() => Validations.checkLanguage(validLanguage)).not.toThrowError(Errors.LanguageError());
|
|
106
85
|
});
|
|
@@ -115,7 +94,7 @@ describe(`Test validations functions for the recommendation props`, () => {
|
|
|
115
94
|
});
|
|
116
95
|
it.each `
|
|
117
96
|
validLatestLogbookFrom6Hours
|
|
118
|
-
${
|
|
97
|
+
${generateDefaultLogbook()}
|
|
119
98
|
${null}
|
|
120
99
|
`(`Validation checking on the latest logbook from the latest 6 hours with a valid logbook`, ({ validLatestLogbookFrom6Hours }) => {
|
|
121
100
|
expect(() => Validations.checkLatestLogbook6Hours(validLatestLogbookFrom6Hours)).not.toThrowError(Errors.LatestLogbook6HoursBGLError());
|
|
@@ -125,8 +104,8 @@ describe(`Test validations functions for the recommendation props`, () => {
|
|
|
125
104
|
${undefined}
|
|
126
105
|
${{}}
|
|
127
106
|
${[]}
|
|
128
|
-
${{ ...
|
|
129
|
-
${{ ...
|
|
107
|
+
${{ ...generateDefaultLogbook(), blood_glucose_millimolar: 1 }}
|
|
108
|
+
${{ ...generateDefaultLogbook(), blood_glucose_millimolar: 33.4 }}
|
|
130
109
|
`(`Validation checking on the latest logbook from the latest 6 hours with an invalid logbook `, ({ invalidLatestLogbookFrom6Hours }) => {
|
|
131
110
|
expect(() => Validations.checkLatestLogbook6Hours(invalidLatestLogbookFrom6Hours)).toThrowError(Errors.LatestLogbook6HoursBGLError());
|
|
132
111
|
});
|
|
@@ -205,7 +184,7 @@ describe(`Test validations for the calculator parameters`, () => {
|
|
|
205
184
|
`(`Validation checking on activity $invalidIntensity throws error`, ({ invalidIntensity }) => {
|
|
206
185
|
expect(() => Validations.checkActivityIntensity(invalidIntensity)).toThrowError(Errors.ActivityIntensityError());
|
|
207
186
|
});
|
|
208
|
-
const validActivitySettings1 =
|
|
187
|
+
const validActivitySettings1 = generateDefaultActivitySettings();
|
|
209
188
|
const validActivitySettings2 = {
|
|
210
189
|
...validActivitySettings1,
|
|
211
190
|
hard: { fromZero: 1, fromThirty: 0.99, fromFortysix: null },
|
|
@@ -229,24 +208,24 @@ describe(`Test validations for the calculator parameters`, () => {
|
|
|
229
208
|
hard: { fromZero: 1, fromThirty: 0.99, fromFortysix: 1.1 },
|
|
230
209
|
};
|
|
231
210
|
const validActivity1 = {
|
|
232
|
-
activityDate: new Date(Date.now() -
|
|
211
|
+
activityDate: new Date(Date.now() - Milliseconds.Hour * 5 - Milliseconds.Minute * 9.9),
|
|
233
212
|
activityDuration: 60,
|
|
234
213
|
activityIntensity: moderate,
|
|
235
214
|
activitySettings: validActivitySettings1,
|
|
236
215
|
};
|
|
237
216
|
const validActivity2 = {
|
|
238
217
|
...validActivity1,
|
|
239
|
-
activityDate: new Date(Date.now() -
|
|
218
|
+
activityDate: new Date(Date.now() - Milliseconds.Hour * 4.5 - Milliseconds.Minute * 9.9),
|
|
240
219
|
activityDuration: 30,
|
|
241
220
|
};
|
|
242
221
|
const invalidActivity1 = {
|
|
243
222
|
...validActivity1,
|
|
244
|
-
activityDate: new Date(Date.now() -
|
|
223
|
+
activityDate: new Date(Date.now() - Milliseconds.Hour * 4.5 - Milliseconds.Minute * 10),
|
|
245
224
|
activityDuration: 30,
|
|
246
225
|
};
|
|
247
226
|
const invalidActivity2 = {
|
|
248
227
|
...validActivity1,
|
|
249
|
-
activityDate: new Date(Date.now() -
|
|
228
|
+
activityDate: new Date(Date.now() - Milliseconds.Hour * 4.25 - Milliseconds.Minute * 10),
|
|
250
229
|
activityDuration: 15,
|
|
251
230
|
};
|
|
252
231
|
test(`Can call checkActivity with a valid activity`, () => {
|
|
@@ -399,7 +378,7 @@ describe(`Test validations for the calculator parameters`, () => {
|
|
|
399
378
|
};
|
|
400
379
|
const validBolus2 = {
|
|
401
380
|
insulinDose: 50,
|
|
402
|
-
secondsPassed:
|
|
381
|
+
secondsPassed: FOUR_HOURS_SECONDS,
|
|
403
382
|
};
|
|
404
383
|
const invalidBolus1 = {
|
|
405
384
|
// @ts-ignore Forcefully incorrect.
|
|
@@ -410,7 +389,7 @@ describe(`Test validations for the calculator parameters`, () => {
|
|
|
410
389
|
const invalidBolus2 = {
|
|
411
390
|
// @ts-ignore Forcefully incorrect.
|
|
412
391
|
insulinDose: undefined,
|
|
413
|
-
secondsPassed:
|
|
392
|
+
secondsPassed: FOUR_HOURS_SECONDS + 1,
|
|
414
393
|
};
|
|
415
394
|
const invalidBolus3 = {
|
|
416
395
|
insulinDose: 51,
|