@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
|
@@ -1,31 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
Activity,
|
|
3
|
+
BloodGlucoseUnit,
|
|
4
|
+
BloodKetonesUnit,
|
|
5
|
+
BolusCalculator,
|
|
6
|
+
Languages,
|
|
7
|
+
Logbook,
|
|
8
|
+
Milliseconds,
|
|
9
|
+
UserSettings,
|
|
10
|
+
} from "@hedia/types";
|
|
4
11
|
import React from "react";
|
|
5
12
|
import { AppStateEvent, AppStateStatus } from "react-native";
|
|
6
13
|
import { cleanup, fireEvent, render } from "react-native-testing-library";
|
|
7
|
-
import InvisibleNumberInput from "../components/InvisibleNumberInput";
|
|
8
14
|
import { i18n } from "../locale/i18nUtils";
|
|
9
|
-
import RecommendationScreen from "../RecommendationScreen";
|
|
15
|
+
import RecommendationScreen, { IRecommendationProps } from "../RecommendationScreen";
|
|
10
16
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
MoodEnum,
|
|
17
|
+
HeaderTestIds,
|
|
18
|
+
LimitationMessageTestIds,
|
|
19
|
+
RecentInsulinTestIds,
|
|
20
|
+
RecommendationModalTestIds,
|
|
16
21
|
RecommendationReminders,
|
|
22
|
+
RecommendedCarbsTestIds,
|
|
23
|
+
RecommendedInsulinTestIds,
|
|
24
|
+
RemeasureTestIds,
|
|
25
|
+
TransferToLogbookTestIds,
|
|
26
|
+
TwoOptionModalTestIds,
|
|
17
27
|
} from "../types/enum";
|
|
28
|
+
import { IRecommendationParams } from "../types/types";
|
|
18
29
|
import { Messages } from "../utils/AttentionMessages";
|
|
19
30
|
import { LanguageError } from "../utils/RecommendationError";
|
|
31
|
+
import { ActivityIntensityTranslations } from "../utils/Translations";
|
|
20
32
|
import { Utils } from "../utils/Utils";
|
|
21
33
|
import {
|
|
22
34
|
expectTextExists,
|
|
23
35
|
expectTextNotExists,
|
|
24
36
|
generateActivityProps,
|
|
25
37
|
generateDefaultCalculatorParams,
|
|
38
|
+
getIcon,
|
|
26
39
|
getRecommendationProps,
|
|
40
|
+
queryTextFromComponent,
|
|
27
41
|
} from "./utils";
|
|
28
42
|
|
|
43
|
+
const ActivityIntensity = Activity.Enums.ActivityIntensity;
|
|
44
|
+
const ActivityEnum = Activity.Enums.ActivityEnum;
|
|
45
|
+
const InjectionMethod = UserSettings.Enums.InjectionMethod;
|
|
46
|
+
const MoodEnum = Logbook.Enums.MoodEnum;
|
|
47
|
+
|
|
48
|
+
const { light, moderate, hard } = ActivityIntensity;
|
|
49
|
+
|
|
29
50
|
interface IMockAppState {
|
|
30
51
|
addEventListener: jest.Mock;
|
|
31
52
|
removeEventListener(): void;
|
|
@@ -35,7 +56,7 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
35
56
|
jest.useFakeTimers();
|
|
36
57
|
|
|
37
58
|
beforeEach((): void => {
|
|
38
|
-
i18n.activate(
|
|
59
|
+
i18n.activate(Languages.en);
|
|
39
60
|
global.Date.now = (): number => 1;
|
|
40
61
|
});
|
|
41
62
|
|
|
@@ -53,11 +74,13 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
53
74
|
insulinSensitivity: 5,
|
|
54
75
|
targetBGL: 7,
|
|
55
76
|
recentBoluses: [],
|
|
77
|
+
activity: null,
|
|
56
78
|
},
|
|
57
79
|
userReminder: 5,
|
|
58
80
|
});
|
|
59
81
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
60
|
-
const okButton = wrapper.
|
|
82
|
+
const okButton = wrapper.getByTestId(RecommendationModalTestIds.AcceptCarbs);
|
|
83
|
+
|
|
61
84
|
fireEvent(okButton, `onPress`);
|
|
62
85
|
|
|
63
86
|
expectTextExists(wrapper, `Food`);
|
|
@@ -76,7 +99,8 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
76
99
|
},
|
|
77
100
|
});
|
|
78
101
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
79
|
-
const okButton = wrapper.
|
|
102
|
+
const okButton = wrapper.getByTestId(RecommendationModalTestIds.AcceptCarbs);
|
|
103
|
+
|
|
80
104
|
fireEvent(okButton, `onPress`);
|
|
81
105
|
|
|
82
106
|
expectTextExists(wrapper, `Food`);
|
|
@@ -85,7 +109,8 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
85
109
|
expectTextExists(wrapper, `Remind me to remeasure in`);
|
|
86
110
|
expectTextExists(wrapper, `0.25`);
|
|
87
111
|
|
|
88
|
-
const textInput = wrapper.
|
|
112
|
+
const textInput = wrapper.getByTestId(RecommendedCarbsTestIds.InvisibleCarbInput);
|
|
113
|
+
|
|
89
114
|
fireEvent(textInput, `onChangeText`, `85`);
|
|
90
115
|
|
|
91
116
|
expectTextNotExists(wrapper, `6`);
|
|
@@ -101,11 +126,13 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
101
126
|
insulinSensitivity: 5,
|
|
102
127
|
targetBGL: 7,
|
|
103
128
|
recentBoluses: [],
|
|
129
|
+
activity: null,
|
|
104
130
|
},
|
|
105
131
|
userReminder: 6,
|
|
106
132
|
});
|
|
107
133
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
108
|
-
const okayButton = wrapper.
|
|
134
|
+
const okayButton = wrapper.getByTestId(RecommendationModalTestIds.OkButton);
|
|
135
|
+
|
|
109
136
|
fireEvent(okayButton, `onPress`);
|
|
110
137
|
|
|
111
138
|
expectTextExists(wrapper, `Food`);
|
|
@@ -123,6 +150,7 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
123
150
|
insulinSensitivity: 5,
|
|
124
151
|
targetBGL: 7,
|
|
125
152
|
recentBoluses: [],
|
|
153
|
+
activity: null,
|
|
126
154
|
},
|
|
127
155
|
});
|
|
128
156
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
@@ -141,18 +169,20 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
141
169
|
insulinSensitivity: 5,
|
|
142
170
|
targetBGL: 7,
|
|
143
171
|
recentBoluses: [],
|
|
172
|
+
activity: null,
|
|
144
173
|
},
|
|
145
174
|
});
|
|
146
175
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
147
176
|
|
|
148
|
-
const okButton = wrapper.
|
|
177
|
+
const okButton = wrapper.getByTestId(RecommendationModalTestIds.AcceptCarbs);
|
|
178
|
+
|
|
149
179
|
fireEvent(okButton, `onPress`);
|
|
150
180
|
|
|
151
181
|
expectTextExists(wrapper, `Food`);
|
|
152
182
|
expectTextExists(wrapper, `Additional`);
|
|
153
183
|
expectTextExists(wrapper, `1`);
|
|
154
184
|
|
|
155
|
-
const removeButton = wrapper.
|
|
185
|
+
const removeButton = wrapper.getByTestId(RecommendedCarbsTestIds.RemoveRecommendation);
|
|
156
186
|
|
|
157
187
|
fireEvent(removeButton, `onPress`);
|
|
158
188
|
|
|
@@ -165,7 +195,8 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
165
195
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
166
196
|
|
|
167
197
|
expectTextExists(wrapper, `hours`);
|
|
168
|
-
const slider = wrapper.
|
|
198
|
+
const slider = wrapper.getByTestId(RemeasureTestIds.RemeasureSlider);
|
|
199
|
+
|
|
169
200
|
fireEvent(slider, `onValueChange`, 3.2);
|
|
170
201
|
expectTextExists(wrapper, `3.2`);
|
|
171
202
|
expectTextExists(wrapper, `hours`);
|
|
@@ -176,7 +207,8 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
176
207
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
177
208
|
|
|
178
209
|
expectTextExists(wrapper, `hours`);
|
|
179
|
-
const slider = wrapper.
|
|
210
|
+
const slider = wrapper.getByTestId(RemeasureTestIds.RemeasureSlider);
|
|
211
|
+
|
|
180
212
|
fireEvent(slider, `onValueChange`, 0);
|
|
181
213
|
expectTextExists(wrapper, `OFF`);
|
|
182
214
|
expectTextNotExists(wrapper, `hours`);
|
|
@@ -193,7 +225,8 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
193
225
|
|
|
194
226
|
expect(props.onRecentInsulinYes).not.toBeCalled();
|
|
195
227
|
expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
196
|
-
const button = wrapper.
|
|
228
|
+
const button = wrapper.getByTestId(RecentInsulinTestIds.Yes);
|
|
229
|
+
|
|
197
230
|
fireEvent(button, `onPress`);
|
|
198
231
|
expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
199
232
|
expect(props.onRecentInsulinYes).toBeCalled();
|
|
@@ -209,7 +242,8 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
209
242
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
210
243
|
|
|
211
244
|
expectTextExists(wrapper, `Have you taken insulin within the last 4 hours?`);
|
|
212
|
-
const button = wrapper.
|
|
245
|
+
const button = wrapper.getByTestId(RecentInsulinTestIds.No);
|
|
246
|
+
|
|
213
247
|
fireEvent(button, `onPress`);
|
|
214
248
|
|
|
215
249
|
expectTextNotExists(wrapper, `Have you taken insulin within the last 4 hours?`);
|
|
@@ -221,33 +255,32 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
221
255
|
const props = getRecommendationProps();
|
|
222
256
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
223
257
|
|
|
224
|
-
const getIcon = (name: string, active: boolean): void => wrapper.queryByA11yLabel(`${name}_${active}`);
|
|
225
|
-
|
|
226
258
|
const neutral = MoodEnum[MoodEnum.Neutral];
|
|
227
259
|
|
|
228
|
-
|
|
229
|
-
|
|
260
|
+
const icon = getIcon(wrapper, neutral, false);
|
|
261
|
+
|
|
262
|
+
if (icon === null) {
|
|
263
|
+
return fail(`No icon found for queryByA11yLabel: ${neutral}_${false}`);
|
|
264
|
+
}
|
|
230
265
|
|
|
231
|
-
|
|
232
|
-
|
|
266
|
+
fireEvent(icon, `onPress`);
|
|
267
|
+
|
|
268
|
+
expect(getIcon(wrapper, neutral, false)).toBeNull();
|
|
269
|
+
expect(getIcon(wrapper, neutral, true)).not.toBeNull();
|
|
233
270
|
});
|
|
234
271
|
|
|
235
272
|
test(`Updating carb recommendation & transfer`, (): void => {
|
|
236
273
|
const result: {
|
|
237
|
-
carbs
|
|
238
|
-
entered
|
|
274
|
+
carbs?: {
|
|
275
|
+
entered: number | null;
|
|
239
276
|
suggested: number;
|
|
240
277
|
};
|
|
241
|
-
insulin
|
|
242
|
-
entered?: number;
|
|
278
|
+
insulin?: {
|
|
279
|
+
entered?: number | null;
|
|
243
280
|
suggested: number;
|
|
244
281
|
};
|
|
245
|
-
reminder
|
|
246
|
-
} = {
|
|
247
|
-
carbs: null,
|
|
248
|
-
insulin: null,
|
|
249
|
-
reminder: null,
|
|
250
|
-
};
|
|
282
|
+
reminder?: number;
|
|
283
|
+
} = {};
|
|
251
284
|
|
|
252
285
|
const props = getRecommendationProps({
|
|
253
286
|
calculatorParams: {
|
|
@@ -257,6 +290,7 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
257
290
|
insulinSensitivity: 5,
|
|
258
291
|
targetBGL: 7,
|
|
259
292
|
recentBoluses: [],
|
|
293
|
+
activity: null,
|
|
260
294
|
},
|
|
261
295
|
transferToLogbook: jest.fn((carbs, insulin, reminder): void => {
|
|
262
296
|
result.carbs = carbs;
|
|
@@ -270,63 +304,59 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
270
304
|
suggested: 1,
|
|
271
305
|
};
|
|
272
306
|
const insulinExpected = {
|
|
273
|
-
entered:
|
|
307
|
+
entered: null,
|
|
274
308
|
suggested: 0,
|
|
275
309
|
};
|
|
276
310
|
|
|
277
311
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
278
312
|
|
|
313
|
+
expect(queryTextFromComponent(wrapper, RecommendedCarbsTestIds.EnteredCarbs)).toBe(`25`);
|
|
314
|
+
expect(queryTextFromComponent(wrapper, RecommendedCarbsTestIds.RecommendedCarbs)).toBe(`1`);
|
|
315
|
+
expect(queryTextFromComponent(wrapper, RecommendedCarbsTestIds.TotalCarbs)).toBe(`26`);
|
|
279
316
|
// Expect text from carbs -> change -> Expect text updated -> Transfer -> Expect callback
|
|
280
|
-
expectTextExists(wrapper, `1`);
|
|
281
317
|
|
|
282
|
-
const carbInput = wrapper.
|
|
283
|
-
expect(carbInput).not.toBeNull();
|
|
318
|
+
const carbInput = wrapper.getByTestId(RecommendedCarbsTestIds.InvisibleCarbInput);
|
|
284
319
|
|
|
285
320
|
// Input 3 into the carbs field
|
|
286
321
|
fireEvent(carbInput, `onEnd`, carbsExpected.entered);
|
|
287
322
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
323
|
+
expect(queryTextFromComponent(wrapper, RecommendedCarbsTestIds.EnteredCarbs)).toBe(`25`);
|
|
324
|
+
expect(queryTextFromComponent(wrapper, RecommendedCarbsTestIds.RecommendedCarbs)).toBe(`3`);
|
|
325
|
+
expect(queryTextFromComponent(wrapper, RecommendedCarbsTestIds.TotalCarbs)).toBe(`28`);
|
|
291
326
|
|
|
292
327
|
// To make the transfer button visible we need to press the "no" option
|
|
293
328
|
expectTextNotExists(wrapper, `Transfer to logbook`);
|
|
294
|
-
const noButton = wrapper.
|
|
295
|
-
expect(noButton).not.toBeNull();
|
|
329
|
+
const noButton = wrapper.getByTestId(RecentInsulinTestIds.No);
|
|
296
330
|
|
|
297
331
|
fireEvent(noButton, `onPress`);
|
|
332
|
+
|
|
298
333
|
expectTextExists(wrapper, `Transfer to logbook`);
|
|
299
334
|
|
|
300
|
-
const transfer = wrapper.
|
|
301
|
-
expect(transfer).not.toBeNull();
|
|
335
|
+
const transfer = wrapper.getByTestId(TransferToLogbookTestIds.TransferButton);
|
|
302
336
|
|
|
303
337
|
// Press transfer
|
|
304
338
|
fireEvent(transfer, `onPress`);
|
|
305
339
|
|
|
306
340
|
expect(props.transferToLogbook).toBeCalled();
|
|
307
|
-
expect(result.carbs
|
|
308
|
-
expect(result.carbs
|
|
309
|
-
expect(result.insulin
|
|
310
|
-
expect(result.insulin
|
|
341
|
+
expect(result.carbs?.entered).toBeCloseTo(carbsExpected.entered, 1);
|
|
342
|
+
expect(result.carbs?.suggested).toBeCloseTo(carbsExpected.suggested, 1);
|
|
343
|
+
expect(result.insulin?.entered).toBe(insulinExpected.entered);
|
|
344
|
+
expect(result.insulin?.suggested).toBeCloseTo(insulinExpected.suggested, 1);
|
|
311
345
|
expect(result.reminder).toBe(RecommendationReminders.Reminder15Minutes);
|
|
312
346
|
});
|
|
313
347
|
|
|
314
348
|
test(`Removing carb recommendation still returns suggested in transfer`, (): void => {
|
|
315
349
|
const result: {
|
|
316
|
-
carbs
|
|
317
|
-
entered
|
|
350
|
+
carbs?: {
|
|
351
|
+
entered: number | null;
|
|
318
352
|
suggested: number;
|
|
319
353
|
};
|
|
320
|
-
insulin
|
|
321
|
-
entered
|
|
354
|
+
insulin?: {
|
|
355
|
+
entered: number | null;
|
|
322
356
|
suggested: number;
|
|
323
357
|
};
|
|
324
|
-
reminder
|
|
325
|
-
} = {
|
|
326
|
-
carbs: null,
|
|
327
|
-
insulin: null,
|
|
328
|
-
reminder: null,
|
|
329
|
-
};
|
|
358
|
+
reminder?: number;
|
|
359
|
+
} = {};
|
|
330
360
|
|
|
331
361
|
const props = getRecommendationProps({
|
|
332
362
|
calculatorParams: {
|
|
@@ -336,6 +366,7 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
336
366
|
insulinSensitivity: 5,
|
|
337
367
|
targetBGL: 7,
|
|
338
368
|
recentBoluses: [],
|
|
369
|
+
activity: null,
|
|
339
370
|
},
|
|
340
371
|
transferToLogbook: jest.fn((carbs, insulin, reminder): void => {
|
|
341
372
|
result.carbs = carbs;
|
|
@@ -349,7 +380,7 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
349
380
|
suggested: 1,
|
|
350
381
|
};
|
|
351
382
|
const insulinExpected = {
|
|
352
|
-
entered:
|
|
383
|
+
entered: null,
|
|
353
384
|
suggested: 0,
|
|
354
385
|
};
|
|
355
386
|
|
|
@@ -358,8 +389,7 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
358
389
|
// Expect text from carbs -> change -> Expect text updated -> Transfer -> Expect callback
|
|
359
390
|
expectTextExists(wrapper, `1`);
|
|
360
391
|
|
|
361
|
-
const removeButton = wrapper.
|
|
362
|
-
expect(removeButton).not.toBeNull();
|
|
392
|
+
const removeButton = wrapper.getByTestId(RecommendedCarbsTestIds.RemoveRecommendation);
|
|
363
393
|
|
|
364
394
|
// Input 3 into the carbs field
|
|
365
395
|
fireEvent(removeButton, `onPress`);
|
|
@@ -369,23 +399,21 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
369
399
|
|
|
370
400
|
// To make the transfer button visible we need to press the "no" option
|
|
371
401
|
expectTextNotExists(wrapper, `Transfer to logbook`);
|
|
372
|
-
const noButton = wrapper.
|
|
373
|
-
expect(noButton).not.toBeNull();
|
|
402
|
+
const noButton = wrapper.getByTestId(RecentInsulinTestIds.No);
|
|
374
403
|
|
|
375
404
|
fireEvent(noButton, `onPress`);
|
|
376
405
|
expectTextExists(wrapper, `Transfer to logbook`);
|
|
377
406
|
|
|
378
|
-
const transfer = wrapper.
|
|
379
|
-
expect(transfer).not.toBeNull();
|
|
407
|
+
const transfer = wrapper.getByTestId(TransferToLogbookTestIds.TransferButton);
|
|
380
408
|
|
|
381
409
|
// Press transfer
|
|
382
410
|
fireEvent(transfer, `onPress`);
|
|
383
411
|
|
|
384
412
|
expect(props.transferToLogbook).toBeCalled();
|
|
385
|
-
expect(result.carbs
|
|
386
|
-
expect(result.carbs
|
|
387
|
-
expect(result.insulin
|
|
388
|
-
expect(result.insulin
|
|
413
|
+
expect(result.carbs!.entered).toBe(carbsExpected.entered);
|
|
414
|
+
expect(result.carbs!.suggested).toBeCloseTo(carbsExpected.suggested, 1);
|
|
415
|
+
expect(result.insulin!.entered).toBe(insulinExpected.entered);
|
|
416
|
+
expect(result.insulin!.suggested).toBeCloseTo(insulinExpected.suggested, 1);
|
|
389
417
|
expect(result.reminder).toBe(RecommendationReminders.Reminder15Minutes);
|
|
390
418
|
});
|
|
391
419
|
|
|
@@ -420,13 +448,14 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
420
448
|
insulinSensitivity: 5,
|
|
421
449
|
targetBGL: 7,
|
|
422
450
|
recentBoluses: [],
|
|
451
|
+
activity: null,
|
|
423
452
|
},
|
|
424
453
|
userReminder: 3,
|
|
425
454
|
injectionMethod: InjectionMethod.Pump,
|
|
426
455
|
});
|
|
427
456
|
|
|
428
457
|
const carbsExpected = {
|
|
429
|
-
entered:
|
|
458
|
+
entered: null,
|
|
430
459
|
suggested: 0,
|
|
431
460
|
};
|
|
432
461
|
const insulinExpected = {
|
|
@@ -441,13 +470,12 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
441
470
|
|
|
442
471
|
expectTextNotExists(wrapper, `Transfer to logbook`);
|
|
443
472
|
|
|
444
|
-
const noButton = wrapper.
|
|
445
|
-
expect(noButton).not.toBeNull();
|
|
473
|
+
const noButton = wrapper.getByTestId(RecentInsulinTestIds.No);
|
|
446
474
|
|
|
447
475
|
fireEvent(noButton, `onPress`);
|
|
448
476
|
expectTextExists(wrapper, `Transfer to logbook`);
|
|
449
477
|
|
|
450
|
-
const insulinInput = wrapper.
|
|
478
|
+
const insulinInput = wrapper.getByTestId(RecommendedInsulinTestIds.InvisibleInsulinInput);
|
|
451
479
|
|
|
452
480
|
// Input 7 into the insulin field
|
|
453
481
|
fireEvent(insulinInput, `onEnd`, insulinExpected.entered);
|
|
@@ -457,8 +485,7 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
457
485
|
|
|
458
486
|
expectTextExists(wrapper, `${insulinExpected.entered}`);
|
|
459
487
|
|
|
460
|
-
const transfer = wrapper.
|
|
461
|
-
expect(transfer).not.toBeNull();
|
|
488
|
+
const transfer = wrapper.getByTestId(TransferToLogbookTestIds.TransferButton);
|
|
462
489
|
|
|
463
490
|
// Press transfer
|
|
464
491
|
fireEvent(transfer, `onPress`);
|
|
@@ -481,13 +508,14 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
481
508
|
insulinSensitivity: 5,
|
|
482
509
|
targetBGL: 7,
|
|
483
510
|
recentBoluses: [],
|
|
511
|
+
activity: null,
|
|
484
512
|
},
|
|
485
513
|
userReminder: 3,
|
|
486
514
|
injectionMethod: InjectionMethod.Pump,
|
|
487
515
|
});
|
|
488
516
|
|
|
489
517
|
const carbsExpected = {
|
|
490
|
-
entered:
|
|
518
|
+
entered: null,
|
|
491
519
|
suggested: 0,
|
|
492
520
|
};
|
|
493
521
|
const insulinExpected = {
|
|
@@ -499,15 +527,17 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
499
527
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
500
528
|
|
|
501
529
|
// Answer "No" to recent insulin
|
|
502
|
-
const noButton = wrapper.
|
|
503
|
-
|
|
530
|
+
const noButton = wrapper.getByTestId(RecentInsulinTestIds.No);
|
|
531
|
+
|
|
504
532
|
fireEvent(noButton, `onPress`);
|
|
505
533
|
|
|
506
534
|
// Verify initial insulin suggestion matches expected
|
|
507
535
|
expectTextExists(wrapper, `${insulinExpected.suggested}`);
|
|
508
536
|
|
|
509
537
|
// Type invalid value - 300 - on insulinInput
|
|
510
|
-
|
|
538
|
+
|
|
539
|
+
const insulinInput = wrapper.getByTestId(RecommendedInsulinTestIds.InvisibleInsulinInput);
|
|
540
|
+
|
|
511
541
|
fireEvent(insulinInput, `onEnd`, invalidInsulin);
|
|
512
542
|
|
|
513
543
|
// After onEnd event, verify the invalid entered value doesn't exist.
|
|
@@ -517,8 +547,8 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
517
547
|
expectTextExists(wrapper, `${insulinExpected.suggested}`);
|
|
518
548
|
|
|
519
549
|
// Press transfer to logbook button
|
|
520
|
-
const transfer = wrapper.
|
|
521
|
-
|
|
550
|
+
const transfer = wrapper.getByTestId(TransferToLogbookTestIds.TransferButton);
|
|
551
|
+
|
|
522
552
|
fireEvent(transfer, `onPress`);
|
|
523
553
|
|
|
524
554
|
// Verify the transferred data
|
|
@@ -540,20 +570,19 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
540
570
|
insulinSensitivity: 5,
|
|
541
571
|
targetBGL: 7,
|
|
542
572
|
recentBoluses: [],
|
|
573
|
+
activity: null,
|
|
543
574
|
},
|
|
544
575
|
});
|
|
545
576
|
|
|
546
577
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
547
578
|
|
|
548
579
|
// Expect text from insulin -> change -> Expect text updated -> Transfer -> Expect callback
|
|
549
|
-
const noButton = wrapper.
|
|
550
|
-
expect(noButton).not.toBeNull();
|
|
580
|
+
const noButton = wrapper.getByTestId(RecentInsulinTestIds.No);
|
|
551
581
|
|
|
552
582
|
fireEvent(noButton, `onPress`);
|
|
553
583
|
expectTextExists(wrapper, `Transfer to logbook`);
|
|
554
584
|
|
|
555
|
-
const slider = wrapper.
|
|
556
|
-
expect(slider).not.toBeNull();
|
|
585
|
+
const slider = wrapper.getByTestId(RemeasureTestIds.RemeasureSlider);
|
|
557
586
|
|
|
558
587
|
// Input 2.5 in remeasure slider
|
|
559
588
|
fireEvent(slider, `onValueChange`, 2.5);
|
|
@@ -562,23 +591,27 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
562
591
|
expectTextNotExists(wrapper, `1.5`);
|
|
563
592
|
expectTextExists(wrapper, `2.5`);
|
|
564
593
|
|
|
565
|
-
const getIcon = (name: string, active: boolean): void => wrapper.queryByA11yLabel(`${name}_${active}`);
|
|
566
594
|
const sad = MoodEnum[MoodEnum.Sad];
|
|
567
|
-
expect(getIcon(sad, false)).not.toBeNull();
|
|
568
|
-
fireEvent(getIcon(sad, false), `onPress`);
|
|
569
595
|
|
|
570
|
-
const
|
|
571
|
-
|
|
596
|
+
const icon = getIcon(wrapper, sad, false);
|
|
597
|
+
|
|
598
|
+
if (icon === null) {
|
|
599
|
+
return fail(`Could not find icon from queryByA11yLabel: ${sad}_${false}`);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
fireEvent(icon, `onPress`);
|
|
603
|
+
|
|
604
|
+
const transfer = wrapper.getByTestId(TransferToLogbookTestIds.TransferButton);
|
|
572
605
|
|
|
573
606
|
// Press transfer
|
|
574
607
|
fireEvent(transfer, `onPress`);
|
|
575
608
|
|
|
576
609
|
const carbsExpected = {
|
|
577
|
-
entered:
|
|
610
|
+
entered: null,
|
|
578
611
|
suggested: 0,
|
|
579
612
|
};
|
|
580
613
|
const insulinExpected = {
|
|
581
|
-
entered:
|
|
614
|
+
entered: null,
|
|
582
615
|
suggested: 2,
|
|
583
616
|
};
|
|
584
617
|
|
|
@@ -592,16 +625,16 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
592
625
|
});
|
|
593
626
|
|
|
594
627
|
test.each`
|
|
595
|
-
locale
|
|
596
|
-
${
|
|
597
|
-
${
|
|
598
|
-
${
|
|
599
|
-
${
|
|
600
|
-
${
|
|
601
|
-
${
|
|
628
|
+
locale | text
|
|
629
|
+
${Languages.da} | ${`INSULIN\nANBEFALING`}
|
|
630
|
+
${Languages.en} | ${`INSULIN\nRECOMMENDATION`}
|
|
631
|
+
${Languages.de} | ${`INSULIN\nEMPFEHLUNG`}
|
|
632
|
+
${Languages.es} | ${`RECOMENDACIÓN\nDE INSULINA`}
|
|
633
|
+
${Languages.it} | ${`PRESCRIZIONE DI\nINSULINA`}
|
|
634
|
+
${Languages.fr} | ${`RECOMMANDATION\nD’INSULINE`}
|
|
602
635
|
`(
|
|
603
636
|
`Language props determine language shown; $locale`,
|
|
604
|
-
({ locale, text }: { locale:
|
|
637
|
+
({ locale, text }: { locale: Languages; text: string }): void => {
|
|
605
638
|
const props = getRecommendationProps({
|
|
606
639
|
language: locale,
|
|
607
640
|
});
|
|
@@ -615,25 +648,36 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
615
648
|
test(`Error is thrown when passing an unsupported language`, (): void => {
|
|
616
649
|
const props = getRecommendationProps();
|
|
617
650
|
|
|
618
|
-
const wrapper = render(<RecommendationScreen {...props} language={`INVALID_LANGUAGE` as
|
|
651
|
+
const wrapper = render(<RecommendationScreen {...props} language={`INVALID_LANGUAGE` as Languages} />);
|
|
619
652
|
expectTextNotExists(wrapper, `INSULIN\nRECOMMENDATION`);
|
|
620
653
|
expect(props.onError).toBeCalledWith(LanguageError());
|
|
621
654
|
});
|
|
655
|
+
test(`Error is thrown when passing an unsupported activity settings`, (): void => {
|
|
656
|
+
const props: IRecommendationProps = getRecommendationProps({
|
|
657
|
+
calculatorParams: {
|
|
658
|
+
...generateDefaultCalculatorParams(),
|
|
659
|
+
activity: { ...generateActivityProps(), activityIntensity: hard, activityDuration: 46 },
|
|
660
|
+
},
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
render(<RecommendationScreen {...props} />);
|
|
664
|
+
expect(props.onError).toBeCalledWith(new Error(BolusCalculator.Enums.ActivityErrors.InvalidInterval));
|
|
665
|
+
});
|
|
622
666
|
|
|
623
667
|
interface IChangeLanguageProps {
|
|
624
|
-
initialLocale:
|
|
625
|
-
locale:
|
|
668
|
+
initialLocale: Languages;
|
|
669
|
+
locale: Languages;
|
|
626
670
|
initialText: string;
|
|
627
671
|
text: string;
|
|
628
672
|
}
|
|
629
673
|
test.each`
|
|
630
|
-
initialLocale
|
|
631
|
-
${
|
|
632
|
-
${
|
|
633
|
-
${
|
|
634
|
-
${
|
|
635
|
-
${
|
|
636
|
-
${
|
|
674
|
+
initialLocale | locale | initialText | text
|
|
675
|
+
${Languages.en} | ${Languages.da} | ${`INSULIN\nRECOMMENDATION`} | ${`INSULIN\nANBEFALING`}
|
|
676
|
+
${Languages.da} | ${Languages.de} | ${`INSULIN\nANBEFALING`} | ${`INSULIN\nEMPFEHLUNG`}
|
|
677
|
+
${Languages.de} | ${Languages.es} | ${`INSULIN\nEMPFEHLUNG`} | ${`RECOMENDACIÓN\nDE INSULINA`}
|
|
678
|
+
${Languages.es} | ${Languages.it} | ${`RECOMENDACIÓN\nDE INSULINA`} | ${`PRESCRIZIONE DI\nINSULINA`}
|
|
679
|
+
${Languages.it} | ${Languages.fr} | ${`PRESCRIZIONE DI\nINSULINA`} | ${`RECOMMANDATION\nD’INSULINE`}
|
|
680
|
+
${Languages.fr} | ${Languages.en} | ${`RECOMMANDATION\nD’INSULINE`} | ${`INSULIN\nRECOMMENDATION`}
|
|
637
681
|
`(
|
|
638
682
|
`Changing language changes header text; initial-language:$initialLocale to changed-language:$locale`,
|
|
639
683
|
({ initialLocale, locale, initialText, text }: IChangeLanguageProps): void => {
|
|
@@ -667,7 +711,8 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
667
711
|
calculatorParams: {
|
|
668
712
|
...getRecommendationProps().calculatorParams,
|
|
669
713
|
currentBGL: 8,
|
|
670
|
-
|
|
714
|
+
targetBGL: 8,
|
|
715
|
+
recentBoluses: [],
|
|
671
716
|
},
|
|
672
717
|
});
|
|
673
718
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
@@ -680,16 +725,19 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
680
725
|
...getRecommendationProps({
|
|
681
726
|
calculatorParams: {
|
|
682
727
|
...getRecommendationProps().calculatorParams,
|
|
728
|
+
// @ts-ignore
|
|
683
729
|
currentBGL: null,
|
|
684
730
|
},
|
|
685
731
|
}),
|
|
686
732
|
currentBKL: null,
|
|
687
733
|
};
|
|
734
|
+
// @ts-ignore
|
|
688
735
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
689
736
|
|
|
690
737
|
expectTextExists(wrapper, /2\./);
|
|
691
738
|
expect(wrapper.queryAllByText(`-.-`)).toHaveLength(2);
|
|
692
739
|
});
|
|
740
|
+
|
|
693
741
|
test(`InfoBars displays bgl and ketones in mg/dL`, (): void => {
|
|
694
742
|
const props = getRecommendationProps({
|
|
695
743
|
calculatorParams: {
|
|
@@ -707,6 +755,7 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
707
755
|
expectTextExists(wrapper, `${bglMGDL}`);
|
|
708
756
|
expectTextExists(wrapper, `${bklMGDL}`);
|
|
709
757
|
});
|
|
758
|
+
|
|
710
759
|
test(`InfoBars displays negative level currentBKL as 0`, (): void => {
|
|
711
760
|
const props = getRecommendationProps({
|
|
712
761
|
calculatorParams: {
|
|
@@ -730,19 +779,20 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
730
779
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
731
780
|
|
|
732
781
|
expectTextExists(wrapper, `INSULIN\nRECOMMENDATION`);
|
|
733
|
-
|
|
782
|
+
const shownInsulin = queryTextFromComponent(wrapper, RecommendedInsulinTestIds.ShownInsulinText);
|
|
783
|
+
expect(shownInsulin).toBe(`0`);
|
|
734
784
|
});
|
|
735
785
|
|
|
736
786
|
test.each`
|
|
737
|
-
intensity
|
|
738
|
-
${
|
|
739
|
-
${
|
|
740
|
-
${
|
|
787
|
+
intensity | translation
|
|
788
|
+
${light} | ${`Let`}
|
|
789
|
+
${moderate} | ${`Moderat`}
|
|
790
|
+
${hard} | ${`Hård`}
|
|
741
791
|
`(
|
|
742
792
|
`Activity screen is displayed and intensity: $intensity can be translated`,
|
|
743
|
-
({ intensity, translation }: { intensity: ActivityIntensity; translation: string }): void => {
|
|
793
|
+
({ intensity, translation }: { intensity: Activity.Enums.ActivityIntensity; translation: string }): void => {
|
|
744
794
|
const props = getRecommendationProps({
|
|
745
|
-
activityDisplayProps: { activityType: ActivityEnum.Run },
|
|
795
|
+
activityDisplayProps: { activityType: ActivityEnum.Run, activityTitle: null },
|
|
746
796
|
calculatorParams: {
|
|
747
797
|
...getRecommendationProps().calculatorParams,
|
|
748
798
|
activity: {
|
|
@@ -753,14 +803,16 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
753
803
|
});
|
|
754
804
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
755
805
|
|
|
756
|
-
|
|
806
|
+
const englishText = ActivityIntensityTranslations[intensity]();
|
|
807
|
+
|
|
808
|
+
expectTextExists(wrapper, englishText);
|
|
757
809
|
expectTextNotExists(wrapper, translation);
|
|
758
810
|
|
|
759
|
-
i18n.activate(
|
|
811
|
+
i18n.activate(Languages.da);
|
|
760
812
|
wrapper.rerender(<RecommendationScreen {...props} />);
|
|
761
813
|
|
|
762
814
|
expectTextExists(wrapper, translation);
|
|
763
|
-
expectTextNotExists(wrapper,
|
|
815
|
+
expectTextNotExists(wrapper, englishText);
|
|
764
816
|
},
|
|
765
817
|
);
|
|
766
818
|
|
|
@@ -774,29 +826,43 @@ describe(`RecommendationScreen`, (): void => {
|
|
|
774
826
|
insulinSensitivity: 0.3,
|
|
775
827
|
targetBGL: 8.3,
|
|
776
828
|
recentBoluses: [],
|
|
829
|
+
activity: null,
|
|
777
830
|
},
|
|
778
831
|
userReminder: 5,
|
|
779
832
|
carbRecommendationAnswer,
|
|
780
833
|
});
|
|
834
|
+
|
|
835
|
+
// Render the screen, expecting a carb recommendation modal.
|
|
781
836
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
782
837
|
expectTextExists(wrapper, `We recommend eating an additional:`);
|
|
783
|
-
|
|
838
|
+
|
|
839
|
+
// Get the yes button from the modal
|
|
840
|
+
const yesButton = wrapper.getByTestId(RecommendationModalTestIds.AcceptCarbs);
|
|
841
|
+
|
|
784
842
|
fireEvent(yesButton, `onPress`);
|
|
785
843
|
expect(carbRecommendationAnswer).toBeCalledWith(true);
|
|
786
844
|
expectTextExists(wrapper, `Additional`);
|
|
787
|
-
expectTextExists(wrapper, `1`);
|
|
788
845
|
|
|
789
|
-
|
|
790
|
-
expect(
|
|
846
|
+
expect(queryTextFromComponent(wrapper, RecommendedCarbsTestIds.EnteredCarbs)).toBe(`1`);
|
|
847
|
+
expect(queryTextFromComponent(wrapper, RecommendedCarbsTestIds.RecommendedCarbs)).toBe(`3`);
|
|
848
|
+
expect(queryTextFromComponent(wrapper, RecommendedCarbsTestIds.TotalCarbs)).toBe(`4`);
|
|
849
|
+
|
|
850
|
+
const carbInput = wrapper.getByTestId(RecommendedCarbsTestIds.InvisibleCarbInput);
|
|
851
|
+
|
|
852
|
+
const manualCarbInput = 299;
|
|
791
853
|
|
|
792
854
|
// Input 299 into the carbs field
|
|
793
|
-
fireEvent(carbInput, `onEnd`,
|
|
794
|
-
|
|
855
|
+
fireEvent(carbInput, `onEnd`, manualCarbInput);
|
|
856
|
+
|
|
857
|
+
expect(queryTextFromComponent(wrapper, RecommendedCarbsTestIds.EnteredCarbs)).toBe(`1`);
|
|
858
|
+
expect(queryTextFromComponent(wrapper, RecommendedCarbsTestIds.RecommendedCarbs)).toBe(`299`);
|
|
859
|
+
expect(queryTextFromComponent(wrapper, RecommendedCarbsTestIds.TotalCarbs)).toBe(`300`);
|
|
860
|
+
|
|
795
861
|
// Expect text from limitation message after recalculation
|
|
796
862
|
expectTextExists(wrapper, `${Messages.RecommendationWasLimited()}`);
|
|
797
863
|
|
|
798
|
-
const nextButton = wrapper.
|
|
799
|
-
|
|
864
|
+
const nextButton = wrapper.getByTestId(LimitationMessageTestIds.OkButton);
|
|
865
|
+
|
|
800
866
|
fireEvent(nextButton, `onPress`);
|
|
801
867
|
expectTextNotExists(wrapper, `${Messages.RecommendationWasLimited()}`);
|
|
802
868
|
});
|
|
@@ -813,12 +879,15 @@ describe(`Recommendation Screen - RecommendationModal related tests`, (): void =
|
|
|
813
879
|
insulinSensitivity: 5,
|
|
814
880
|
targetBGL: 7,
|
|
815
881
|
recentBoluses: [],
|
|
882
|
+
activity: null,
|
|
816
883
|
},
|
|
817
884
|
userReminder: 5,
|
|
818
885
|
carbRecommendationAnswer,
|
|
819
886
|
});
|
|
820
887
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
821
|
-
|
|
888
|
+
|
|
889
|
+
const noButton = wrapper.getByTestId(RecommendationModalTestIds.DeclineCarbs);
|
|
890
|
+
|
|
822
891
|
fireEvent(noButton, `onPress`);
|
|
823
892
|
|
|
824
893
|
expect(carbRecommendationAnswer).toBeCalledWith(false);
|
|
@@ -836,13 +905,16 @@ describe(`Recommendation Screen - RecommendationModal related tests`, (): void =
|
|
|
836
905
|
insulinSensitivity: 5,
|
|
837
906
|
targetBGL: 7,
|
|
838
907
|
recentBoluses: [],
|
|
908
|
+
activity: null,
|
|
839
909
|
},
|
|
840
910
|
userReminder: 5,
|
|
841
911
|
carbRecommendationAnswer,
|
|
842
912
|
});
|
|
843
913
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
844
914
|
expectTextExists(wrapper, `We recommend eating an additional:`);
|
|
845
|
-
|
|
915
|
+
|
|
916
|
+
const yesButton = wrapper.getByTestId(RecommendationModalTestIds.AcceptCarbs);
|
|
917
|
+
|
|
846
918
|
fireEvent(yesButton, `onPress`);
|
|
847
919
|
expect(carbRecommendationAnswer).toBeCalledWith(true);
|
|
848
920
|
expectTextExists(wrapper, `Food`);
|
|
@@ -864,9 +936,12 @@ describe(`Recommendation Screen - RecommendationModal related tests`, (): void =
|
|
|
864
936
|
userReminder: 5,
|
|
865
937
|
});
|
|
866
938
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
867
|
-
const nextButton = wrapper.
|
|
939
|
+
const nextButton = wrapper.getByTestId(LimitationMessageTestIds.OkButton);
|
|
940
|
+
|
|
868
941
|
fireEvent(nextButton, `onPress`);
|
|
869
|
-
|
|
942
|
+
|
|
943
|
+
const yesButton = wrapper.getByTestId(RecommendationModalTestIds.OkButton);
|
|
944
|
+
|
|
870
945
|
fireEvent(yesButton, `onPress`);
|
|
871
946
|
expectTextExists(wrapper, `Food`);
|
|
872
947
|
expectTextNotExists(wrapper, `Additional`);
|
|
@@ -881,11 +956,13 @@ describe(`Recommendation Screen - TwoOptionModal related tests`, (): void => {
|
|
|
881
956
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
882
957
|
|
|
883
958
|
//press exit button
|
|
884
|
-
const exitButton = wrapper.
|
|
959
|
+
const exitButton = wrapper.getByTestId(HeaderTestIds.ExitCalculation);
|
|
960
|
+
|
|
885
961
|
fireEvent(exitButton, `onPress`);
|
|
886
962
|
expect(props.showBolusBar).toBeCalledWith(false);
|
|
887
963
|
|
|
888
|
-
const saveToLogbookModalButton = wrapper.
|
|
964
|
+
const saveToLogbookModalButton = wrapper.getByTestId(TwoOptionModalTestIds.FirstOption);
|
|
965
|
+
|
|
889
966
|
fireEvent(saveToLogbookModalButton, `onPress`);
|
|
890
967
|
expect(props.transferToLogbook).toBeCalled();
|
|
891
968
|
|
|
@@ -898,11 +975,13 @@ describe(`Recommendation Screen - TwoOptionModal related tests`, (): void => {
|
|
|
898
975
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
899
976
|
|
|
900
977
|
//press exit button
|
|
901
|
-
const exitButton = wrapper.
|
|
978
|
+
const exitButton = wrapper.getByTestId(HeaderTestIds.ExitCalculation);
|
|
979
|
+
|
|
902
980
|
fireEvent(exitButton, `onPress`);
|
|
903
981
|
expect(props.showBolusBar).toBeCalledWith(false);
|
|
904
982
|
|
|
905
|
-
const closeCalculation = wrapper.
|
|
983
|
+
const closeCalculation = wrapper.getByTestId(TwoOptionModalTestIds.SecondOption);
|
|
984
|
+
|
|
906
985
|
fireEvent(closeCalculation, `onPress`);
|
|
907
986
|
expect(props.closeCalculationCallback).toBeCalled();
|
|
908
987
|
|
|
@@ -916,7 +995,8 @@ describe(`Recommendation Screen - TwoOptionModal related tests`, (): void => {
|
|
|
916
995
|
});
|
|
917
996
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
918
997
|
|
|
919
|
-
const exitButton = wrapper.
|
|
998
|
+
const exitButton = wrapper.getByTestId(HeaderTestIds.ExitCalculation);
|
|
999
|
+
|
|
920
1000
|
fireEvent(exitButton, `onPress`);
|
|
921
1001
|
expectTextExists(wrapper, `Have you taken insulin within the last 4 hours?`);
|
|
922
1002
|
expect(props.showBolusBar).not.toBeCalled();
|
|
@@ -927,13 +1007,15 @@ describe(`Recommendation Screen - TwoOptionModal related tests`, (): void => {
|
|
|
927
1007
|
const props = getRecommendationProps();
|
|
928
1008
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
929
1009
|
|
|
930
|
-
const exitButton = wrapper.
|
|
1010
|
+
const exitButton = wrapper.getByTestId(HeaderTestIds.ExitCalculation);
|
|
1011
|
+
|
|
931
1012
|
fireEvent(exitButton, `onPress`);
|
|
932
1013
|
expect(props.showBolusBar).toBeCalledWith(false);
|
|
933
1014
|
expectTextExists(wrapper, `Save to logbook`);
|
|
934
1015
|
expectTextExists(wrapper, `Close calculation`);
|
|
935
1016
|
|
|
936
|
-
const modalExitIcon = wrapper.
|
|
1017
|
+
const modalExitIcon = wrapper.getByTestId(TwoOptionModalTestIds.ExitButton);
|
|
1018
|
+
|
|
937
1019
|
fireEvent(modalExitIcon, `onPress`);
|
|
938
1020
|
expect(props.showBolusBar).toBeCalledWith(true);
|
|
939
1021
|
expectTextNotExists(wrapper, `Save to logbook`);
|
|
@@ -941,11 +1023,12 @@ describe(`Recommendation Screen - TwoOptionModal related tests`, (): void => {
|
|
|
941
1023
|
});
|
|
942
1024
|
|
|
943
1025
|
test(`Can translate ExitModal option`, (): void => {
|
|
944
|
-
const props = getRecommendationProps({ language:
|
|
1026
|
+
const props = getRecommendationProps({ language: Languages.da });
|
|
945
1027
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
946
1028
|
|
|
947
1029
|
//press exit button
|
|
948
|
-
const exitButton = wrapper.
|
|
1030
|
+
const exitButton = wrapper.getByTestId(HeaderTestIds.ExitCalculation);
|
|
1031
|
+
|
|
949
1032
|
fireEvent(exitButton, `onPress`);
|
|
950
1033
|
expect(props.showBolusBar).toBeCalledWith(false);
|
|
951
1034
|
|
|
@@ -963,7 +1046,8 @@ describe(`Recommendation Screen - TwoOptionModal related tests`, (): void => {
|
|
|
963
1046
|
|
|
964
1047
|
jest.runAllTimers();
|
|
965
1048
|
expect(props.onError).not.toBeCalled();
|
|
966
|
-
|
|
1049
|
+
|
|
1050
|
+
const modalExitIcon = wrapper.queryByTestId(TwoOptionModalTestIds.ExitButton);
|
|
967
1051
|
expect(modalExitIcon).toBeNull();
|
|
968
1052
|
expect(props.showBolusBar).toBeCalledWith(false);
|
|
969
1053
|
|
|
@@ -971,12 +1055,13 @@ describe(`Recommendation Screen - TwoOptionModal related tests`, (): void => {
|
|
|
971
1055
|
expectTextExists(wrapper, `Yes, save to logbook`);
|
|
972
1056
|
expectTextExists(wrapper, `No, return to dashboard`);
|
|
973
1057
|
|
|
974
|
-
i18n.activate(
|
|
1058
|
+
i18n.activate(Languages.da);
|
|
975
1059
|
wrapper.rerender(<RecommendationScreen {...props} />);
|
|
976
1060
|
jest.runAllTimers();
|
|
977
1061
|
expectTextExists(wrapper, `Der er gået mere end 15 minutter siden udregningen blev startet.`);
|
|
978
1062
|
|
|
979
|
-
const saveToLogbook = wrapper.
|
|
1063
|
+
const saveToLogbook = wrapper.getByTestId(TwoOptionModalTestIds.FirstOption);
|
|
1064
|
+
|
|
980
1065
|
fireEvent(saveToLogbook, `onPress`);
|
|
981
1066
|
expect(props.transferToLogbook).toBeCalled();
|
|
982
1067
|
});
|
|
@@ -989,7 +1074,8 @@ describe(`Recommendation Screen - TwoOptionModal related tests`, (): void => {
|
|
|
989
1074
|
|
|
990
1075
|
jest.runAllTimers();
|
|
991
1076
|
expect(props.onError).not.toBeCalled();
|
|
992
|
-
|
|
1077
|
+
|
|
1078
|
+
const modalExitIcon = wrapper.queryByTestId(TwoOptionModalTestIds.ExitButton);
|
|
993
1079
|
expect(modalExitIcon).toBeNull();
|
|
994
1080
|
expect(props.showBolusBar).toBeCalledWith(false);
|
|
995
1081
|
|
|
@@ -997,7 +1083,8 @@ describe(`Recommendation Screen - TwoOptionModal related tests`, (): void => {
|
|
|
997
1083
|
expectTextExists(wrapper, `Yes, save to logbook`);
|
|
998
1084
|
expectTextExists(wrapper, `No, return to dashboard`);
|
|
999
1085
|
|
|
1000
|
-
const returnToDashboard = wrapper.
|
|
1086
|
+
const returnToDashboard = wrapper.getByTestId(TwoOptionModalTestIds.SecondOption);
|
|
1087
|
+
|
|
1001
1088
|
fireEvent(returnToDashboard, `onPress`);
|
|
1002
1089
|
expect(props.closeCalculationCallback).toBeCalled();
|
|
1003
1090
|
});
|
|
@@ -1013,7 +1100,8 @@ describe(`Recommendation Screen - TwoOptionModal related tests`, (): void => {
|
|
|
1013
1100
|
|
|
1014
1101
|
jest.runAllTimers();
|
|
1015
1102
|
expect(props.onError).not.toBeCalled();
|
|
1016
|
-
|
|
1103
|
+
|
|
1104
|
+
const modalExitIcon = wrapper.queryByTestId(TwoOptionModalTestIds.ExitButton);
|
|
1017
1105
|
expect(modalExitIcon).toBeNull();
|
|
1018
1106
|
expect(props.showBolusBar).toBeCalledWith(false);
|
|
1019
1107
|
|
|
@@ -1021,7 +1109,8 @@ describe(`Recommendation Screen - TwoOptionModal related tests`, (): void => {
|
|
|
1021
1109
|
expectTextExists(wrapper, `Start new calculation`);
|
|
1022
1110
|
expectTextExists(wrapper, `Return to dashboard`);
|
|
1023
1111
|
|
|
1024
|
-
const returnToDashboard = wrapper.
|
|
1112
|
+
const returnToDashboard = wrapper.getByTestId(TwoOptionModalTestIds.SecondOption);
|
|
1113
|
+
|
|
1025
1114
|
fireEvent(returnToDashboard, `onPress`);
|
|
1026
1115
|
expect(props.closeCalculationCallback).toBeCalled();
|
|
1027
1116
|
|
|
@@ -1040,7 +1129,8 @@ describe(`Recommendation Screen - TwoOptionModal related tests`, (): void => {
|
|
|
1040
1129
|
|
|
1041
1130
|
jest.runAllTimers();
|
|
1042
1131
|
expect(props.onError).not.toBeCalled();
|
|
1043
|
-
|
|
1132
|
+
|
|
1133
|
+
const modalExitIcon = wrapper.queryByTestId(TwoOptionModalTestIds.ExitButton);
|
|
1044
1134
|
expect(modalExitIcon).toBeNull();
|
|
1045
1135
|
expect(props.showBolusBar).toBeCalledWith(false);
|
|
1046
1136
|
|
|
@@ -1048,12 +1138,13 @@ describe(`Recommendation Screen - TwoOptionModal related tests`, (): void => {
|
|
|
1048
1138
|
expectTextExists(wrapper, `Start new calculation`);
|
|
1049
1139
|
expectTextExists(wrapper, `Return to dashboard`);
|
|
1050
1140
|
|
|
1051
|
-
i18n.activate(
|
|
1141
|
+
i18n.activate(Languages.da);
|
|
1052
1142
|
wrapper.rerender(<RecommendationScreen {...props} />);
|
|
1053
1143
|
jest.runAllTimers();
|
|
1054
1144
|
expectTextExists(wrapper, `Der er gået mere end 15 minutter siden udregningen blev startet.`);
|
|
1055
1145
|
|
|
1056
|
-
const returnToDashboard = wrapper.
|
|
1146
|
+
const returnToDashboard = wrapper.getByTestId(TwoOptionModalTestIds.FirstOption);
|
|
1147
|
+
|
|
1057
1148
|
fireEvent(returnToDashboard, `onPress`);
|
|
1058
1149
|
expect(props.restartCalculation).toBeCalled();
|
|
1059
1150
|
|
|
@@ -1081,22 +1172,27 @@ describe(`Recommendation Screen - TwoOptionModal related tests`, (): void => {
|
|
|
1081
1172
|
);
|
|
1082
1173
|
|
|
1083
1174
|
const wrapper = render(<RecommendationScreen {...props} />);
|
|
1084
|
-
|
|
1175
|
+
// @ts-ignore
|
|
1176
|
+
appStateListener?.(`active`);
|
|
1085
1177
|
// Run twice to test else path
|
|
1086
1178
|
global.Date.now = (): number => new Date().getTime() + Milliseconds.Minute * 14;
|
|
1087
|
-
|
|
1179
|
+
// @ts-ignore
|
|
1180
|
+
appStateListener?.(`active`);
|
|
1088
1181
|
|
|
1089
1182
|
wrapper.rerender(<RecommendationScreen {...props} />);
|
|
1090
1183
|
expect(props.showBolusBar).not.toBeCalledWith(false);
|
|
1091
1184
|
expectTextNotExists(wrapper, `No, return to dashboard`);
|
|
1092
1185
|
|
|
1093
1186
|
global.Date.now = (): number => new Date().getTime() + Milliseconds.Minute * 15;
|
|
1187
|
+
// @ts-ignore
|
|
1094
1188
|
appStateListener(`active`);
|
|
1095
1189
|
|
|
1096
1190
|
wrapper.rerender(<RecommendationScreen {...props} />);
|
|
1097
1191
|
expect(props.showBolusBar).toBeCalledWith(false);
|
|
1098
1192
|
expectTextExists(wrapper, `No, return to dashboard`);
|
|
1099
|
-
|
|
1193
|
+
|
|
1194
|
+
const closeModalButton = wrapper.getByTestId(TwoOptionModalTestIds.SecondOption);
|
|
1195
|
+
|
|
1100
1196
|
fireEvent(closeModalButton, `secondOption`);
|
|
1101
1197
|
|
|
1102
1198
|
wrapper.rerender(<RecommendationScreen {...props} />);
|
|
@@ -1126,6 +1222,7 @@ describe(`Recommendation Screen - TwoOptionModal related tests`, (): void => {
|
|
|
1126
1222
|
);
|
|
1127
1223
|
|
|
1128
1224
|
const rendered = render(<RecommendationScreen {...props} />);
|
|
1225
|
+
// @ts-ignore
|
|
1129
1226
|
appStateListener(`NotAnAppStateStatus` as AppStateStatus);
|
|
1130
1227
|
rendered.rerender(<RecommendationScreen {...props} />);
|
|
1131
1228
|
expect(props.showBolusBar).not.toBeCalled();
|