@hedia/recommendation-screen 1.8.2 → 2.0.2
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/.github/workflows/ci.yml +0 -0
- package/.github/workflows/publish.yml +48 -0
- package/.github/workflows/version-check.yml +45 -0
- package/.linguirc +0 -0
- package/.npmpackagejsonlintrc.json +0 -0
- package/.prettierignore +0 -0
- package/.prettierrc +0 -0
- package/App.d.ts +4 -5
- package/App.jsx +23 -34
- package/App.tsx +36 -41
- package/Changelog.md +0 -0
- package/README.md +0 -0
- package/android/app/BUCK +0 -0
- package/android/app/build.gradle +0 -0
- package/android/app/build_defs.bzl +0 -0
- package/android/app/debug.keystore +0 -0
- package/android/app/proguard-rules.pro +0 -0
- package/android/app/src/debug/AndroidManifest.xml +0 -0
- package/android/app/src/debug/java/com/hediarecommendationscreen/ReactNativeFlipper.java +0 -0
- package/android/app/src/main/AndroidManifest.xml +0 -0
- package/android/app/src/main/assets/fonts/AntDesign.ttf +0 -0
- package/android/app/src/main/assets/fonts/Entypo.ttf +0 -0
- package/android/app/src/main/assets/fonts/EvilIcons.ttf +0 -0
- package/android/app/src/main/assets/fonts/Feather.ttf +0 -0
- package/android/app/src/main/assets/fonts/FontAwesome.ttf +0 -0
- package/android/app/src/main/assets/fonts/FontAwesome5_Brands.ttf +0 -0
- package/android/app/src/main/assets/fonts/FontAwesome5_Regular.ttf +0 -0
- package/android/app/src/main/assets/fonts/FontAwesome5_Solid.ttf +0 -0
- package/android/app/src/main/assets/fonts/Foundation.ttf +0 -0
- package/android/app/src/main/assets/fonts/Ionicons.ttf +0 -0
- package/android/app/src/main/assets/fonts/MaterialCommunityIcons.ttf +0 -0
- package/android/app/src/main/assets/fonts/MaterialIcons.ttf +0 -0
- package/android/app/src/main/assets/fonts/Octicons.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-Black.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-BlackItalic.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-Bold.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-BoldItalic.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-Italic.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-Light.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-LightItalic.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-Medium.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-MediumItalic.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-Regular.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-Thin.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-ThinItalic.ttf +0 -0
- package/android/app/src/main/assets/fonts/SimpleLineIcons.ttf +0 -0
- package/android/app/src/main/assets/fonts/Zocial.ttf +0 -0
- package/android/app/src/main/java/com/hediarecommendationscreen/MainActivity.java +0 -0
- package/android/app/src/main/java/com/hediarecommendationscreen/MainApplication.java +0 -0
- package/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/values/color.xml +0 -0
- package/android/app/src/main/res/values/strings.xml +0 -0
- package/android/app/src/main/res/values/styles.xml +0 -0
- package/android/build.gradle +0 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -0
- package/android/gradle.properties +0 -0
- package/android/gradlew.bat +0 -0
- package/android/settings.gradle +0 -0
- package/app.json +0 -0
- package/assets/fonts/Roboto/LICENSE.txt +0 -0
- package/assets/fonts/Roboto/Roboto-Black.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-BlackItalic.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-Bold.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-BoldItalic.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-Italic.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-Light.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-LightItalic.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-Medium.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-MediumItalic.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-Regular.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-Thin.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-ThinItalic.ttf +0 -0
- package/babel.config.js +0 -0
- package/ignore-git.sh +1 -1
- package/ignore-publish.sh +2 -1
- package/index.d.ts +2 -2
- package/index.js +2 -3
- package/index.ts +2 -2
- package/ios/HediaRecommendationScreen/AppDelegate.h +0 -0
- package/ios/HediaRecommendationScreen/AppDelegate.m +0 -0
- package/ios/HediaRecommendationScreen/Base.lproj/LaunchScreen.xib +0 -0
- package/ios/HediaRecommendationScreen/Images.xcassets/AppIcon.appiconset/Contents.json +0 -0
- package/ios/HediaRecommendationScreen/Images.xcassets/Contents.json +0 -0
- package/ios/HediaRecommendationScreen/Info.plist +0 -0
- package/ios/HediaRecommendationScreen/main.m +0 -0
- package/ios/HediaRecommendationScreen-tvOS/Info.plist +0 -0
- package/ios/HediaRecommendationScreen-tvOSTests/Info.plist +0 -0
- package/ios/HediaRecommendationScreen.xcodeproj/project.pbxproj +0 -0
- package/ios/HediaRecommendationScreen.xcodeproj/xcshareddata/xcschemes/HediaRecommendationScreen-tvOS.xcscheme +0 -0
- package/ios/HediaRecommendationScreen.xcodeproj/xcshareddata/xcschemes/HediaRecommendationScreen.xcscheme +0 -0
- package/ios/HediaRecommendationScreen.xcworkspace/contents.xcworkspacedata +0 -0
- package/ios/HediaRecommendationScreen.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
- package/ios/HediaRecommendationScreenTests/HediaRecommendationScreenTests.m +0 -0
- package/ios/HediaRecommendationScreenTests/Info.plist +0 -0
- package/ios/Podfile +0 -0
- package/ios/Podfile.lock +0 -0
- package/jest.config.js +0 -0
- package/jest.mock.js +0 -0
- package/metro.config.js +0 -0
- package/package.json +8 -10
- package/react-native.config.js +0 -0
- package/src/RecommendationScreen.d.ts +18 -20
- package/src/RecommendationScreen.jsx +26 -15
- package/src/RecommendationScreen.tsx +60 -37
- package/src/__tests__/RecommendationScreen.test.d.ts +0 -0
- package/src/__tests__/RecommendationScreen.test.jsx +163 -138
- package/src/__tests__/RecommendationScreen.test.tsx +256 -159
- package/src/__tests__/RecommendationUtils.test.d.ts +0 -0
- package/src/__tests__/RecommendationUtils.test.js +30 -39
- package/src/__tests__/RecommendationUtils.test.ts +38 -43
- package/src/__tests__/Translate.test.d.ts +0 -0
- package/src/__tests__/Translate.test.jsx +13 -12
- package/src/__tests__/Translate.test.tsx +15 -14
- package/src/__tests__/Utils.test.d.ts +0 -0
- package/src/__tests__/Utils.test.js +22 -20
- package/src/__tests__/Utils.test.ts +32 -21
- package/src/__tests__/Validations.test.d.ts +0 -0
- package/src/__tests__/Validations.test.js +59 -33
- package/src/__tests__/Validations.test.ts +83 -41
- package/src/__tests__/components/Activity.test.d.ts +0 -0
- package/src/__tests__/components/Activity.test.jsx +39 -18
- package/src/__tests__/components/Activity.test.tsx +99 -45
- package/src/__tests__/components/Emotion.test.d.ts +0 -0
- package/src/__tests__/components/Emotion.test.jsx +34 -25
- package/src/__tests__/components/Emotion.test.tsx +41 -24
- package/src/__tests__/components/Header.test.d.ts +0 -0
- package/src/__tests__/components/Header.test.jsx +10 -9
- package/src/__tests__/components/Header.test.tsx +12 -11
- package/src/__tests__/components/InfoBars.test.d.ts +0 -0
- package/src/__tests__/components/InfoBars.test.jsx +1 -0
- package/src/__tests__/components/InfoBars.test.tsx +7 -6
- package/src/__tests__/components/InvisibleNumberInput.test.d.ts +0 -0
- package/src/__tests__/components/InvisibleNumberInput.test.jsx +40 -24
- package/src/__tests__/components/InvisibleNumberInput.test.tsx +41 -17
- package/src/__tests__/components/LimitationMessage.test.d.ts +0 -0
- package/src/__tests__/components/LimitationMessage.test.jsx +11 -30
- package/src/__tests__/components/LimitationMessage.test.tsx +15 -13
- package/src/__tests__/components/MoodIcon.test.d.ts +0 -0
- package/src/__tests__/components/MoodIcon.test.jsx +12 -8
- package/src/__tests__/components/MoodIcon.test.tsx +13 -5
- package/src/__tests__/components/RecommendationModal.test.d.ts +0 -0
- package/src/__tests__/components/RecommendationModal.test.jsx +22 -21
- package/src/__tests__/components/RecommendationModal.test.tsx +29 -27
- package/src/__tests__/components/RecommendedCarbs.test.d.ts +0 -0
- package/src/__tests__/components/RecommendedCarbs.test.jsx +7 -10
- package/src/__tests__/components/RecommendedCarbs.test.tsx +9 -10
- package/src/__tests__/components/RecommendedInsulin.test.d.ts +0 -0
- package/src/__tests__/components/RecommendedInsulin.test.jsx +57 -41
- package/src/__tests__/components/RecommendedInsulin.test.tsx +57 -31
- package/src/__tests__/components/Remeasure.test.d.ts +0 -0
- package/src/__tests__/components/Remeasure.test.jsx +7 -3
- package/src/__tests__/components/Remeasure.test.tsx +11 -3
- package/src/__tests__/components/TransferToLogbook.test.d.ts +0 -0
- package/src/__tests__/components/TransferToLogbook.test.jsx +2 -2
- package/src/__tests__/components/TransferToLogbook.test.tsx +2 -2
- package/src/__tests__/components/TwoOptionModal.test.d.ts +0 -0
- package/src/__tests__/components/TwoOptionModal.test.jsx +5 -4
- package/src/__tests__/components/TwoOptionModal.test.tsx +6 -4
- package/src/__tests__/utils.d.ts +7 -2
- package/src/__tests__/utils.jsx +59 -15
- package/src/__tests__/utils.tsx +63 -16
- package/src/assets/activity/Cyclist.png +0 -0
- package/src/assets/activity/Other.png +0 -0
- package/src/assets/activity/Runner.png +0 -0
- package/src/assets/activity/Swimmer.png +0 -0
- package/src/assets/activity/Walk.png +0 -0
- package/src/assets/mood/happy.png +0 -0
- package/src/assets/mood/happy_active.png +0 -0
- package/src/assets/mood/neutral.png +0 -0
- package/src/assets/mood/neutral_active.png +0 -0
- package/src/assets/mood/sad.png +0 -0
- package/src/assets/mood/sad_active.png +0 -0
- package/src/assets/mood/semi_happy.png +0 -0
- package/src/assets/mood/semi_happy_active.png +0 -0
- package/src/assets/mood/semi_sad.png +0 -0
- package/src/assets/mood/semi_sad_active.png +0 -0
- package/src/components/Header.d.ts +0 -0
- package/src/components/Header.jsx +2 -1
- package/src/components/Header.tsx +2 -1
- package/src/components/Icon.js +0 -0
- package/src/components/InfoBars.d.ts +1 -1
- package/src/components/InfoBars.jsx +0 -0
- package/src/components/InfoBars.tsx +1 -1
- package/src/components/InvisibleNumberInput.d.ts +2 -1
- package/src/components/InvisibleNumberInput.jsx +7 -2
- package/src/components/InvisibleNumberInput.tsx +10 -3
- package/src/components/LimitationMessage.d.ts +1 -1
- package/src/components/LimitationMessage.jsx +3 -2
- package/src/components/LimitationMessage.tsx +3 -1
- package/src/components/LineSeparator.d.ts +0 -0
- package/src/components/LineSeparator.jsx +0 -0
- package/src/components/LineSeparator.tsx +0 -0
- package/src/components/RecentInsulin.d.ts +0 -0
- package/src/components/RecentInsulin.jsx +3 -2
- package/src/components/RecentInsulin.tsx +3 -0
- package/src/components/RecommendationModal.d.ts +4 -4
- package/src/components/RecommendationModal.jsx +10 -9
- package/src/components/RecommendationModal.tsx +19 -8
- package/src/components/RecommendedCarbs.d.ts +4 -3
- package/src/components/RecommendedCarbs.jsx +12 -9
- package/src/components/RecommendedCarbs.tsx +31 -16
- package/src/components/RecommendedInsulin.d.ts +7 -7
- package/src/components/RecommendedInsulin.jsx +11 -7
- package/src/components/RecommendedInsulin.tsx +24 -12
- package/src/components/Remeasure.d.ts +2 -2
- package/src/components/Remeasure.jsx +7 -2
- package/src/components/Remeasure.tsx +10 -4
- package/src/components/TransferToLogbook.d.ts +0 -0
- package/src/components/TransferToLogbook.jsx +2 -1
- package/src/components/TransferToLogbook.tsx +2 -0
- package/src/components/TwoOptionModal.d.ts +5 -3
- package/src/components/TwoOptionModal.jsx +44 -13
- package/src/components/TwoOptionModal.tsx +50 -14
- package/src/components/activity/Activity.d.ts +2 -3
- package/src/components/activity/Activity.jsx +5 -2
- package/src/components/activity/Activity.tsx +7 -5
- package/src/components/activity/ActivityIcon.d.ts +1 -1
- package/src/components/activity/ActivityIcon.jsx +9 -8
- package/src/components/activity/ActivityIcon.tsx +12 -10
- package/src/components/activity/ActivityIntensity.d.ts +1 -1
- package/src/components/activity/ActivityIntensity.jsx +2 -8
- package/src/components/activity/ActivityIntensity.tsx +3 -12
- package/src/components/mood/Emotion.d.ts +5 -4
- package/src/components/mood/Emotion.jsx +4 -3
- package/src/components/mood/Emotion.tsx +9 -7
- package/src/components/mood/MoodIcon.d.ts +2 -2
- package/src/components/mood/MoodIcon.jsx +3 -2
- package/src/components/mood/MoodIcon.tsx +4 -2
- package/src/locale/CleanLanguage.ts +0 -0
- package/src/locale/da/messages.js +1 -1
- package/src/locale/da/messages.po +115 -107
- package/src/locale/de/messages.js +1 -1
- package/src/locale/de/messages.po +115 -107
- package/src/locale/en/messages.js +1 -1
- package/src/locale/en/messages.po +118 -110
- package/src/locale/es/messages.js +1 -1
- package/src/locale/es/messages.po +112 -104
- package/src/locale/fr/messages.js +1 -1
- package/src/locale/fr/messages.po +111 -103
- package/src/locale/i18nUtils.d.ts +3 -4
- package/src/locale/i18nUtils.js +13 -12
- package/src/locale/i18nUtils.ts +14 -14
- package/src/locale/it/messages.js +1 -1
- package/src/locale/it/messages.po +113 -105
- package/src/types/enum.d.ts +52 -44
- package/src/types/enum.js +67 -56
- package/src/types/enum.ts +58 -34
- package/src/types/types.d.ts +9 -23
- package/src/types/types.js +0 -0
- package/src/types/types.ts +9 -25
- package/src/utils/AttentionMessages.d.ts +1 -4
- package/src/utils/AttentionMessages.jsx +8 -30
- package/src/utils/AttentionMessages.tsx +11 -16
- package/src/utils/Constants.d.ts +0 -0
- package/src/utils/Constants.js +0 -0
- package/src/utils/Constants.ts +0 -0
- package/src/utils/RecommendationError.d.ts +2 -0
- package/src/utils/RecommendationError.jsx +45 -40
- package/src/utils/RecommendationError.tsx +17 -4
- package/src/utils/RecommendationUtils.d.ts +7 -8
- package/src/utils/RecommendationUtils.js +15 -7
- package/src/utils/RecommendationUtils.ts +24 -14
- package/src/utils/Translations.d.ts +2 -0
- package/src/utils/Translations.js +10 -0
- package/src/utils/Translations.ts +9 -0
- package/src/utils/Utils.d.ts +4 -5
- package/src/utils/Utils.js +6 -5
- package/src/utils/Utils.ts +10 -8
- package/src/utils/Validations.d.ts +10 -9
- package/src/utils/Validations.js +61 -65
- package/src/utils/Validations.ts +76 -81
- package/tsconfig.json +2 -2
- package/tslint.json +0 -0
|
File without changes
|
|
@@ -1,43 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const types_1 = require("@hedia/types");
|
|
4
4
|
const enum_1 = require("../types/enum");
|
|
5
5
|
const AttentionMessages_1 = require("../utils/AttentionMessages");
|
|
6
6
|
const RecommendationError_1 = require("../utils/RecommendationError");
|
|
7
7
|
const RecommendationUtils_1 = require("../utils/RecommendationUtils");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
|
+
const ActivityIntensity = types_1.Activity.Enums.ActivityIntensity;
|
|
10
|
+
const { moderate } = ActivityIntensity;
|
|
8
11
|
describe(`Actions based on the blood glucose level:: InsulinSettingsUtils `, () => {
|
|
9
12
|
const logbookUnder15MMOL = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
carbohydrates_suggested_grams: 25,
|
|
13
|
-
client_timestamp: `25`,
|
|
14
|
-
client_version: 25,
|
|
15
|
-
entry_timestamp: `25`,
|
|
16
|
-
event_uuid: null,
|
|
17
|
-
insulin_entered_units: 25,
|
|
18
|
-
insulin_suggested_units: 25,
|
|
19
|
-
is_deleted: null,
|
|
20
|
-
mood: 2,
|
|
21
|
-
settings_uuid: `25`,
|
|
22
|
-
uuid: `aaa`,
|
|
13
|
+
...utils_1.generateDefaultLogbook(),
|
|
14
|
+
blood_glucose_millimolar: 14.9,
|
|
23
15
|
};
|
|
24
16
|
const logbookOver15MMOL = {
|
|
25
|
-
...
|
|
17
|
+
...utils_1.generateDefaultLogbook(),
|
|
26
18
|
blood_glucose_millimolar: 15.1,
|
|
27
19
|
};
|
|
28
|
-
const
|
|
20
|
+
const logbookWithNullBloodGlucose = {
|
|
21
|
+
...utils_1.generateDefaultLogbook(),
|
|
22
|
+
blood_glucose_millimolar: null,
|
|
23
|
+
};
|
|
24
|
+
const inactiveDate = new Date(Date.now() + types_1.Milliseconds.Minute * 15.1);
|
|
29
25
|
const activeDate = new Date();
|
|
30
26
|
const activeActivity = {
|
|
31
27
|
activityDate: activeDate,
|
|
32
28
|
activityDuration: 10,
|
|
33
|
-
activityIntensity:
|
|
34
|
-
activitySettings:
|
|
35
|
-
hard: { fromFortysix: 0.25, fromThirty: 0.99, fromZero: 0.25 },
|
|
36
|
-
light: { fromFortysix: 0.25, fromThirty: 0.25, fromZero: 0.25 },
|
|
37
|
-
post: { fromFortysix: 0.25, fromThirty: 0.25, fromZero: 0.25 },
|
|
38
|
-
moderate: { fromZero: 0.7, fromThirty: 0.9, fromFortysix: 0.7 },
|
|
39
|
-
target: 8.3,
|
|
40
|
-
},
|
|
29
|
+
activityIntensity: moderate,
|
|
30
|
+
activitySettings: utils_1.generateDefaultActivitySettings(),
|
|
41
31
|
};
|
|
42
32
|
const inactiveActivity = { ...activeActivity, activityDate: inactiveDate };
|
|
43
33
|
it.each `
|
|
@@ -62,12 +52,13 @@ describe(`Actions based on the blood glucose level:: InsulinSettingsUtils `, ()
|
|
|
62
52
|
expect(RecommendationUtils_1.getBGLevel(bloodGlucoseValue, latestLogbookFrom6Hours)).toBe(bgLevel);
|
|
63
53
|
});
|
|
64
54
|
it.each `
|
|
65
|
-
latestLogbookFrom6Hours
|
|
66
|
-
${null}
|
|
67
|
-
${logbookOver15MMOL}
|
|
68
|
-
${logbookUnder15MMOL}
|
|
69
|
-
${undefined}
|
|
70
|
-
${{}}
|
|
55
|
+
latestLogbookFrom6Hours | severeHyperglycemia
|
|
56
|
+
${null} | ${false}
|
|
57
|
+
${logbookOver15MMOL} | ${true}
|
|
58
|
+
${logbookUnder15MMOL} | ${false}
|
|
59
|
+
${undefined} | ${false}
|
|
60
|
+
${{}} | ${false}
|
|
61
|
+
${logbookWithNullBloodGlucose} | ${false}
|
|
71
62
|
`(`tests isSevereGlycemia method `, ({ latestLogbookFrom6Hours, severeHyperglycemia }) => {
|
|
72
63
|
expect(RecommendationUtils_1.isSevereHyperglycemia(latestLogbookFrom6Hours)).toBe(severeHyperglycemia);
|
|
73
64
|
});
|
|
@@ -90,13 +81,13 @@ describe(`Actions based on the blood glucose level:: InsulinSettingsUtils `, ()
|
|
|
90
81
|
});
|
|
91
82
|
it.each `
|
|
92
83
|
bgLevel | activity | attentionMessage
|
|
93
|
-
${enum_1.BgLevel.BGLevelNotProvided} | ${activeActivity} | ${
|
|
84
|
+
${enum_1.BgLevel.BGLevelNotProvided} | ${activeActivity} | ${null}
|
|
94
85
|
${enum_1.BgLevel.SevereHypoglycemia} | ${activeActivity} | ${AttentionMessages_1.addPostponeActivityMessageUnder5MMOL(AttentionMessages_1.AttentionMessage.SevereHypoglycemia())}
|
|
95
86
|
${enum_1.BgLevel.Hypoglycemia} | ${activeActivity} | ${AttentionMessages_1.addPostponeActivityMessageUnder5MMOL(AttentionMessages_1.AttentionMessage.Hypoglycemia())}
|
|
96
87
|
${enum_1.BgLevel.MildHypoglycemia} | ${activeActivity} | ${AttentionMessages_1.addPostponeActivityMessageUnder5MMOL(AttentionMessages_1.AttentionMessage.MildHypoglycemia())}
|
|
97
88
|
${enum_1.BgLevel.NormoglycemiaUnder5MMOL} | ${activeActivity} | ${AttentionMessages_1.AttentionMessage.NormoglycemiaActivityUnder5MMOL()}
|
|
98
|
-
${enum_1.BgLevel.Normoglycemia} | ${activeActivity} | ${
|
|
99
|
-
${enum_1.BgLevel.MildHyperglycemia} | ${activeActivity} | ${
|
|
89
|
+
${enum_1.BgLevel.Normoglycemia} | ${activeActivity} | ${null}
|
|
90
|
+
${enum_1.BgLevel.MildHyperglycemia} | ${activeActivity} | ${null}
|
|
100
91
|
${enum_1.BgLevel.Hyperglycemia} | ${activeActivity} | ${AttentionMessages_1.AttentionMessage.HyperglycemiaActivity()}
|
|
101
92
|
${enum_1.BgLevel.SevereHyperglycemia} | ${activeActivity} | ${AttentionMessages_1.AttentionMessage.SevereHyperglycemiaActivity()}
|
|
102
93
|
`(`return the correct attention message with an active activity for $bgLevel`, ({ bgLevel, activity, attentionMessage }) => {
|
|
@@ -104,14 +95,14 @@ describe(`Actions based on the blood glucose level:: InsulinSettingsUtils `, ()
|
|
|
104
95
|
});
|
|
105
96
|
it.each `
|
|
106
97
|
bgLevel | activity | attentionMessage
|
|
107
|
-
${enum_1.BgLevel.BGLevelNotProvided} | ${inactiveActivity} | ${
|
|
98
|
+
${enum_1.BgLevel.BGLevelNotProvided} | ${inactiveActivity} | ${null}
|
|
108
99
|
${enum_1.BgLevel.SevereHypoglycemia} | ${inactiveActivity} | ${AttentionMessages_1.AttentionMessage.SevereHypoglycemia()}
|
|
109
100
|
${enum_1.BgLevel.Hypoglycemia} | ${inactiveActivity} | ${AttentionMessages_1.AttentionMessage.Hypoglycemia()}
|
|
110
101
|
${enum_1.BgLevel.MildHypoglycemia} | ${inactiveActivity} | ${AttentionMessages_1.AttentionMessage.MildHypoglycemia()}
|
|
111
|
-
${enum_1.BgLevel.NormoglycemiaUnder5MMOL} | ${inactiveActivity} | ${
|
|
112
|
-
${enum_1.BgLevel.Normoglycemia} | ${inactiveActivity} | ${
|
|
113
|
-
${enum_1.BgLevel.MildHyperglycemia} | ${inactiveActivity} | ${
|
|
114
|
-
${enum_1.BgLevel.Hyperglycemia} | ${inactiveActivity} | ${
|
|
102
|
+
${enum_1.BgLevel.NormoglycemiaUnder5MMOL} | ${inactiveActivity} | ${null}
|
|
103
|
+
${enum_1.BgLevel.Normoglycemia} | ${inactiveActivity} | ${null}
|
|
104
|
+
${enum_1.BgLevel.MildHyperglycemia} | ${inactiveActivity} | ${null}
|
|
105
|
+
${enum_1.BgLevel.Hyperglycemia} | ${inactiveActivity} | ${null}
|
|
115
106
|
${enum_1.BgLevel.SevereHyperglycemia} | ${inactiveActivity} | ${AttentionMessages_1.AttentionMessage.SevereHyperglycemia()}
|
|
116
107
|
`(`return the correct attention message with an inactive activity for $bgLevel`, ({ bgLevel, activity, attentionMessage }) => {
|
|
117
108
|
expect(RecommendationUtils_1.getAttentionMessage(bgLevel, activity)).toBe(attentionMessage);
|
|
@@ -220,7 +211,7 @@ describe(`Actions based on the blood glucose level:: InsulinSettingsUtils `, ()
|
|
|
220
211
|
wasLimited | activityReduction | attentionMessage
|
|
221
212
|
${true} | ${0.25} | ${AttentionMessages_1.Messages.RecommendationWasLimitedActivity(0.25)}
|
|
222
213
|
${true} | ${0} | ${AttentionMessages_1.Messages.RecommendationWasLimited()}
|
|
223
|
-
${false} | ${0} | ${
|
|
214
|
+
${false} | ${0} | ${null}
|
|
224
215
|
`(`return the correct attention message for $bgLevel`, ({ wasLimited, activityReduction, attentionMessage }) => {
|
|
225
216
|
expect(RecommendationUtils_1.getLimitationMessage(wasLimited, activityReduction)).toBe(attentionMessage);
|
|
226
217
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BgLevel,
|
|
3
|
-
import { logbookEntry } from "../types/types";
|
|
1
|
+
import { Activity, Milliseconds } from "@hedia/types";
|
|
2
|
+
import { BgLevel, RecommendationReminders } from "../types/enum";
|
|
3
|
+
import { IActivityParams, logbookEntry } from "../types/types";
|
|
4
4
|
import { addPostponeActivityMessageUnder5MMOL, AttentionMessage, Messages } from "../utils/AttentionMessages";
|
|
5
5
|
import { CurrentBGLError } from "../utils/RecommendationError";
|
|
6
6
|
import {
|
|
@@ -11,41 +11,33 @@ import {
|
|
|
11
11
|
isActivityWithin15Minutes,
|
|
12
12
|
isSevereHyperglycemia,
|
|
13
13
|
} from "../utils/RecommendationUtils";
|
|
14
|
+
import { generateDefaultActivitySettings, generateDefaultLogbook } from "./utils";
|
|
15
|
+
|
|
16
|
+
const ActivityIntensity = Activity.Enums.ActivityIntensity;
|
|
17
|
+
const { moderate } = ActivityIntensity;
|
|
14
18
|
|
|
15
19
|
describe(`Actions based on the blood glucose level:: InsulinSettingsUtils `, (): void => {
|
|
16
20
|
const logbookUnder15MMOL: logbookEntry = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
carbohydrates_suggested_grams: 25,
|
|
20
|
-
client_timestamp: `25`,
|
|
21
|
-
client_version: 25,
|
|
22
|
-
entry_timestamp: `25`,
|
|
23
|
-
event_uuid: null,
|
|
24
|
-
insulin_entered_units: 25,
|
|
25
|
-
insulin_suggested_units: 25,
|
|
26
|
-
is_deleted: null,
|
|
27
|
-
mood: 2,
|
|
28
|
-
settings_uuid: `25`,
|
|
29
|
-
uuid: `aaa`,
|
|
21
|
+
...generateDefaultLogbook(),
|
|
22
|
+
blood_glucose_millimolar: 14.9,
|
|
30
23
|
};
|
|
31
|
-
|
|
32
24
|
const logbookOver15MMOL: logbookEntry = {
|
|
33
|
-
...
|
|
25
|
+
...generateDefaultLogbook(),
|
|
34
26
|
blood_glucose_millimolar: 15.1,
|
|
35
27
|
};
|
|
28
|
+
|
|
29
|
+
const logbookWithNullBloodGlucose: logbookEntry = {
|
|
30
|
+
...generateDefaultLogbook(),
|
|
31
|
+
blood_glucose_millimolar: null,
|
|
32
|
+
};
|
|
33
|
+
|
|
36
34
|
const inactiveDate = new Date(Date.now() + Milliseconds.Minute * 15.1);
|
|
37
35
|
const activeDate = new Date();
|
|
38
36
|
const activeActivity: IActivityParams = {
|
|
39
37
|
activityDate: activeDate,
|
|
40
38
|
activityDuration: 10,
|
|
41
|
-
activityIntensity:
|
|
42
|
-
activitySettings:
|
|
43
|
-
hard: { fromFortysix: 0.25, fromThirty: 0.99, fromZero: 0.25 },
|
|
44
|
-
light: { fromFortysix: 0.25, fromThirty: 0.25, fromZero: 0.25 },
|
|
45
|
-
post: { fromFortysix: 0.25, fromThirty: 0.25, fromZero: 0.25 },
|
|
46
|
-
moderate: { fromZero: 0.7, fromThirty: 0.9, fromFortysix: 0.7 },
|
|
47
|
-
target: 8.3,
|
|
48
|
-
},
|
|
39
|
+
activityIntensity: moderate,
|
|
40
|
+
activitySettings: generateDefaultActivitySettings(),
|
|
49
41
|
};
|
|
50
42
|
const inactiveActivity: IActivityParams = { ...activeActivity, activityDate: inactiveDate };
|
|
51
43
|
|
|
@@ -81,15 +73,16 @@ describe(`Actions based on the blood glucose level:: InsulinSettingsUtils `, ():
|
|
|
81
73
|
|
|
82
74
|
interface IIsSevereGlycemia {
|
|
83
75
|
severeHyperglycemia: boolean;
|
|
84
|
-
latestLogbookFrom6Hours: logbookEntry;
|
|
76
|
+
latestLogbookFrom6Hours: logbookEntry | null;
|
|
85
77
|
}
|
|
86
78
|
it.each`
|
|
87
|
-
latestLogbookFrom6Hours
|
|
88
|
-
${null}
|
|
89
|
-
${logbookOver15MMOL}
|
|
90
|
-
${logbookUnder15MMOL}
|
|
91
|
-
${undefined}
|
|
92
|
-
${{}}
|
|
79
|
+
latestLogbookFrom6Hours | severeHyperglycemia
|
|
80
|
+
${null} | ${false}
|
|
81
|
+
${logbookOver15MMOL} | ${true}
|
|
82
|
+
${logbookUnder15MMOL} | ${false}
|
|
83
|
+
${undefined} | ${false}
|
|
84
|
+
${{}} | ${false}
|
|
85
|
+
${logbookWithNullBloodGlucose} | ${false}
|
|
93
86
|
`(`tests isSevereGlycemia method `, ({ latestLogbookFrom6Hours, severeHyperglycemia }: IIsSevereGlycemia): void => {
|
|
94
87
|
expect(isSevereHyperglycemia(latestLogbookFrom6Hours)).toBe(severeHyperglycemia);
|
|
95
88
|
});
|
|
@@ -126,19 +119,21 @@ describe(`Actions based on the blood glucose level:: InsulinSettingsUtils `, ():
|
|
|
126
119
|
`(
|
|
127
120
|
`Unsupported bg level throws error`,
|
|
128
121
|
({ bgLevel, activity, attentionMessage }: IGetAttentionMessageError): void => {
|
|
129
|
-
expect((): AttentionMessage => getAttentionMessage(bgLevel, activity)).toThrowError(
|
|
122
|
+
expect((): AttentionMessage | null => getAttentionMessage(bgLevel, activity)).toThrowError(
|
|
123
|
+
attentionMessage,
|
|
124
|
+
);
|
|
130
125
|
},
|
|
131
126
|
);
|
|
132
127
|
|
|
133
128
|
it.each`
|
|
134
129
|
bgLevel | activity | attentionMessage
|
|
135
|
-
${BgLevel.BGLevelNotProvided} | ${activeActivity} | ${
|
|
130
|
+
${BgLevel.BGLevelNotProvided} | ${activeActivity} | ${null}
|
|
136
131
|
${BgLevel.SevereHypoglycemia} | ${activeActivity} | ${addPostponeActivityMessageUnder5MMOL(AttentionMessage.SevereHypoglycemia())}
|
|
137
132
|
${BgLevel.Hypoglycemia} | ${activeActivity} | ${addPostponeActivityMessageUnder5MMOL(AttentionMessage.Hypoglycemia())}
|
|
138
133
|
${BgLevel.MildHypoglycemia} | ${activeActivity} | ${addPostponeActivityMessageUnder5MMOL(AttentionMessage.MildHypoglycemia())}
|
|
139
134
|
${BgLevel.NormoglycemiaUnder5MMOL} | ${activeActivity} | ${AttentionMessage.NormoglycemiaActivityUnder5MMOL()}
|
|
140
|
-
${BgLevel.Normoglycemia} | ${activeActivity} | ${
|
|
141
|
-
${BgLevel.MildHyperglycemia} | ${activeActivity} | ${
|
|
135
|
+
${BgLevel.Normoglycemia} | ${activeActivity} | ${null}
|
|
136
|
+
${BgLevel.MildHyperglycemia} | ${activeActivity} | ${null}
|
|
142
137
|
${BgLevel.Hyperglycemia} | ${activeActivity} | ${AttentionMessage.HyperglycemiaActivity()}
|
|
143
138
|
${BgLevel.SevereHyperglycemia} | ${activeActivity} | ${AttentionMessage.SevereHyperglycemiaActivity()}
|
|
144
139
|
`(
|
|
@@ -149,14 +144,14 @@ describe(`Actions based on the blood glucose level:: InsulinSettingsUtils `, ():
|
|
|
149
144
|
);
|
|
150
145
|
it.each`
|
|
151
146
|
bgLevel | activity | attentionMessage
|
|
152
|
-
${BgLevel.BGLevelNotProvided} | ${inactiveActivity} | ${
|
|
147
|
+
${BgLevel.BGLevelNotProvided} | ${inactiveActivity} | ${null}
|
|
153
148
|
${BgLevel.SevereHypoglycemia} | ${inactiveActivity} | ${AttentionMessage.SevereHypoglycemia()}
|
|
154
149
|
${BgLevel.Hypoglycemia} | ${inactiveActivity} | ${AttentionMessage.Hypoglycemia()}
|
|
155
150
|
${BgLevel.MildHypoglycemia} | ${inactiveActivity} | ${AttentionMessage.MildHypoglycemia()}
|
|
156
|
-
${BgLevel.NormoglycemiaUnder5MMOL} | ${inactiveActivity} | ${
|
|
157
|
-
${BgLevel.Normoglycemia} | ${inactiveActivity} | ${
|
|
158
|
-
${BgLevel.MildHyperglycemia} | ${inactiveActivity} | ${
|
|
159
|
-
${BgLevel.Hyperglycemia} | ${inactiveActivity} | ${
|
|
151
|
+
${BgLevel.NormoglycemiaUnder5MMOL} | ${inactiveActivity} | ${null}
|
|
152
|
+
${BgLevel.Normoglycemia} | ${inactiveActivity} | ${null}
|
|
153
|
+
${BgLevel.MildHyperglycemia} | ${inactiveActivity} | ${null}
|
|
154
|
+
${BgLevel.Hyperglycemia} | ${inactiveActivity} | ${null}
|
|
160
155
|
${BgLevel.SevereHyperglycemia} | ${inactiveActivity} | ${AttentionMessage.SevereHyperglycemia()}
|
|
161
156
|
`(
|
|
162
157
|
`return the correct attention message with an inactive activity for $bgLevel`,
|
|
@@ -327,7 +322,7 @@ describe(`Actions based on the blood glucose level:: InsulinSettingsUtils `, ():
|
|
|
327
322
|
wasLimited | activityReduction | attentionMessage
|
|
328
323
|
${true} | ${0.25} | ${Messages.RecommendationWasLimitedActivity(0.25)}
|
|
329
324
|
${true} | ${0} | ${Messages.RecommendationWasLimited()}
|
|
330
|
-
${false} | ${0} | ${
|
|
325
|
+
${false} | ${0} | ${null}
|
|
331
326
|
`(
|
|
332
327
|
`return the correct attention message for $bgLevel`,
|
|
333
328
|
({ wasLimited, activityReduction, attentionMessage }: ILimitationMessage): void => {
|
|
File without changes
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
const types_1 = require("@hedia/types");
|
|
3
5
|
const i18nUtils_1 = require("../locale/i18nUtils");
|
|
4
|
-
const enum_1 = require("../types/enum");
|
|
5
6
|
describe(`Translation Utils`, () => {
|
|
6
7
|
test(`Same instance`, () => {
|
|
7
8
|
expect(i18nUtils_1.i18n).toBe(i18nUtils_1.i18n);
|
|
8
9
|
});
|
|
9
10
|
test.each `
|
|
10
|
-
locale
|
|
11
|
-
${
|
|
12
|
-
${
|
|
13
|
-
${
|
|
14
|
-
${
|
|
15
|
-
${
|
|
16
|
-
${
|
|
11
|
+
locale | text
|
|
12
|
+
${types_1.Languages.da} | ${`Dansk`}
|
|
13
|
+
${types_1.Languages.en} | ${`English`}
|
|
14
|
+
${types_1.Languages.de} | ${`Deutsch`}
|
|
15
|
+
${types_1.Languages.es} | ${`Español`}
|
|
16
|
+
${types_1.Languages.it} | ${`Italiano`}
|
|
17
|
+
${types_1.Languages.fr} | ${`Français`}
|
|
17
18
|
`(`Change to the right language; $locale`, ({ locale, text }) => {
|
|
18
19
|
expect(i18nUtils_1.changeLanguage(locale).language).toBe(text);
|
|
19
20
|
});
|
|
20
21
|
test.each `
|
|
21
|
-
locale
|
|
22
|
-
${
|
|
23
|
-
${
|
|
24
|
-
${
|
|
22
|
+
locale | text
|
|
23
|
+
${types_1.Languages.nl} | ${types_1.Languages.en}
|
|
24
|
+
${types_1.Languages.jp} | ${types_1.Languages.en}
|
|
25
|
+
${types_1.Languages.ro} | ${types_1.Languages.en}
|
|
25
26
|
`(`Unsupported language defaults to english; $locale`, ({ locale, text }) => {
|
|
26
27
|
expect(i18nUtils_1.changeLanguage(locale).language).toBe(text);
|
|
27
28
|
});
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { Languages } from "@hedia/types";
|
|
1
3
|
import { changeLanguage, i18n } from "../locale/i18nUtils";
|
|
2
|
-
import { Language } from "../types/enum";
|
|
3
4
|
|
|
4
5
|
describe(`Translation Utils`, (): void => {
|
|
5
6
|
test(`Same instance`, (): void => {
|
|
6
7
|
expect(i18n).toBe(i18n);
|
|
7
8
|
});
|
|
8
9
|
test.each`
|
|
9
|
-
locale
|
|
10
|
-
${
|
|
11
|
-
${
|
|
12
|
-
${
|
|
13
|
-
${
|
|
14
|
-
${
|
|
15
|
-
${
|
|
16
|
-
`(`Change to the right language; $locale`, ({ locale, text }: { locale:
|
|
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 => {
|
|
17
18
|
expect(changeLanguage(locale).language).toBe(text);
|
|
18
19
|
});
|
|
19
20
|
test.each`
|
|
20
|
-
locale
|
|
21
|
-
${
|
|
22
|
-
${
|
|
23
|
-
${
|
|
21
|
+
locale | text
|
|
22
|
+
${Languages.nl} | ${Languages.en}
|
|
23
|
+
${Languages.jp} | ${Languages.en}
|
|
24
|
+
${Languages.ro} | ${Languages.en}
|
|
24
25
|
`(
|
|
25
26
|
`Unsupported language defaults to english; $locale`,
|
|
26
|
-
({ locale, text }: { locale:
|
|
27
|
+
({ locale, text }: { locale: Languages; text: string }): void => {
|
|
27
28
|
expect(changeLanguage(locale).language).toBe(text);
|
|
28
29
|
},
|
|
29
30
|
);
|
|
File without changes
|
|
@@ -1,32 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const types_1 = require("@hedia/types");
|
|
4
4
|
const Constants_1 = require("../utils/Constants");
|
|
5
5
|
const Utils_1 = require("../utils/Utils");
|
|
6
|
+
const InjectionMethod = types_1.UserSettings.Enums.InjectionMethod;
|
|
7
|
+
const { PenHalf, PenWhole, Pump } = InjectionMethod;
|
|
6
8
|
describe(`Utils helper functions`, () => {
|
|
7
9
|
test.each `
|
|
8
|
-
method
|
|
9
|
-
${
|
|
10
|
-
${
|
|
11
|
-
${
|
|
10
|
+
method | expected
|
|
11
|
+
${PenWhole} | ${1}
|
|
12
|
+
${PenHalf} | ${2}
|
|
13
|
+
${Pump} | ${10}
|
|
12
14
|
`(`Get correct rounding for $method`, ({ expected, method }) => {
|
|
13
15
|
expect(Utils_1.Utils.getRounding(method)).toBe(expected);
|
|
14
16
|
});
|
|
15
17
|
test.each `
|
|
16
|
-
value | method
|
|
17
|
-
${1.99} | ${
|
|
18
|
-
${1.99} | ${
|
|
19
|
-
${1.99} | ${
|
|
20
|
-
${1.74} | ${
|
|
21
|
-
${1.74} | ${
|
|
22
|
-
${1.74} | ${
|
|
23
|
-
${1.75} | ${
|
|
24
|
-
${1.75} | ${
|
|
25
|
-
${1.75} | ${
|
|
26
|
-
${-1.45} | ${
|
|
27
|
-
${-1.45} | ${
|
|
28
|
-
${-1.45} | ${
|
|
29
|
-
`(`Rounding $value using $method to $expected`, ({ expected, method, value }) => {
|
|
18
|
+
value | method | expected
|
|
19
|
+
${1.99} | ${PenWhole} | ${2}
|
|
20
|
+
${1.99} | ${PenHalf} | ${2}
|
|
21
|
+
${1.99} | ${Pump} | ${2}
|
|
22
|
+
${1.74} | ${PenWhole} | ${2}
|
|
23
|
+
${1.74} | ${PenHalf} | ${1.5}
|
|
24
|
+
${1.74} | ${Pump} | ${1.7}
|
|
25
|
+
${1.75} | ${PenWhole} | ${2}
|
|
26
|
+
${1.75} | ${PenHalf} | ${2}
|
|
27
|
+
${1.75} | ${Pump} | ${1.8}
|
|
28
|
+
${-1.45} | ${PenWhole} | ${-1}
|
|
29
|
+
${-1.45} | ${PenHalf} | ${-1.5}
|
|
30
|
+
${-1.45} | ${Pump} | ${-1.4}
|
|
31
|
+
`(`Rounding $value using $method to $expected`, ({ expected, method, value, }) => {
|
|
30
32
|
expect(Utils_1.Utils.roundValue(value, method)).toBe(expected);
|
|
31
33
|
});
|
|
32
34
|
const customInterval = { min: 0, max: 75.5 };
|
|
@@ -43,7 +45,7 @@ describe(`Utils helper functions`, () => {
|
|
|
43
45
|
${-1} | ${Constants_1.ACTIVITY_DURATION_MINUTES_LIMITS} | ${false}
|
|
44
46
|
${3601} | ${Constants_1.ACTIVITY_DURATION_MINUTES_LIMITS} | ${false}
|
|
45
47
|
`(`Check if a number is in the interval`, ({ value, interval, expected }) => {
|
|
46
|
-
expect(Utils_1.Utils.
|
|
48
|
+
expect(Utils_1.Utils.isInRange(value, interval)).toBe(expected);
|
|
47
49
|
});
|
|
48
50
|
test.each `
|
|
49
51
|
value | expected
|
|
@@ -1,38 +1,49 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UserSettings } from "@hedia/types";
|
|
2
2
|
import { IInterval } from "../types/types";
|
|
3
3
|
import { ACTIVITY_DURATION_MINUTES_LIMITS } from "../utils/Constants";
|
|
4
4
|
import { Utils } from "../utils/Utils";
|
|
5
5
|
|
|
6
|
+
const InjectionMethod = UserSettings.Enums.InjectionMethod;
|
|
7
|
+
const { PenHalf, PenWhole, Pump } = InjectionMethod;
|
|
8
|
+
|
|
6
9
|
describe(`Utils helper functions`, (): void => {
|
|
7
10
|
test.each`
|
|
8
|
-
method
|
|
9
|
-
${
|
|
10
|
-
${
|
|
11
|
-
${
|
|
11
|
+
method | expected
|
|
12
|
+
${PenWhole} | ${1}
|
|
13
|
+
${PenHalf} | ${2}
|
|
14
|
+
${Pump} | ${10}
|
|
12
15
|
`(
|
|
13
16
|
`Get correct rounding for $method`,
|
|
14
|
-
({ expected, method }: { method: InjectionMethod; expected: number }): void => {
|
|
17
|
+
({ expected, method }: { method: UserSettings.Enums.InjectionMethod; expected: number }): void => {
|
|
15
18
|
expect(Utils.getRounding(method)).toBe(expected);
|
|
16
19
|
},
|
|
17
20
|
);
|
|
18
21
|
|
|
19
22
|
test.each`
|
|
20
|
-
value | method
|
|
21
|
-
${1.99} | ${
|
|
22
|
-
${1.99} | ${
|
|
23
|
-
${1.99} | ${
|
|
24
|
-
${1.74} | ${
|
|
25
|
-
${1.74} | ${
|
|
26
|
-
${1.74} | ${
|
|
27
|
-
${1.75} | ${
|
|
28
|
-
${1.75} | ${
|
|
29
|
-
${1.75} | ${
|
|
30
|
-
${-1.45} | ${
|
|
31
|
-
${-1.45} | ${
|
|
32
|
-
${-1.45} | ${
|
|
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}
|
|
33
36
|
`(
|
|
34
37
|
`Rounding $value using $method to $expected`,
|
|
35
|
-
({
|
|
38
|
+
({
|
|
39
|
+
expected,
|
|
40
|
+
method,
|
|
41
|
+
value,
|
|
42
|
+
}: {
|
|
43
|
+
value: number;
|
|
44
|
+
method: UserSettings.Enums.InjectionMethod;
|
|
45
|
+
expected: number;
|
|
46
|
+
}): void => {
|
|
36
47
|
expect(Utils.roundValue(value, method)).toBe(expected);
|
|
37
48
|
},
|
|
38
49
|
);
|
|
@@ -52,7 +63,7 @@ describe(`Utils helper functions`, (): void => {
|
|
|
52
63
|
`(
|
|
53
64
|
`Check if a number is in the interval`,
|
|
54
65
|
({ value, interval, expected }: { value: number; interval: IInterval; expected: number }): void => {
|
|
55
|
-
expect(Utils.
|
|
66
|
+
expect(Utils.isInRange(value, interval)).toBe(expected);
|
|
56
67
|
},
|
|
57
68
|
);
|
|
58
69
|
|
|
File without changes
|