@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
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const types_1 = require("@hedia/types");
|
|
6
7
|
const react_1 = require("@lingui/react");
|
|
7
8
|
const react_2 = __importDefault(require("react"));
|
|
8
9
|
const react_native_testing_library_1 = require("react-native-testing-library");
|
|
@@ -14,38 +15,38 @@ const utils_1 = require("../utils");
|
|
|
14
15
|
describe(`RecommendationModal Component`, () => {
|
|
15
16
|
afterEach(react_native_testing_library_1.cleanup);
|
|
16
17
|
beforeEach(() => {
|
|
17
|
-
i18nUtils_1.i18n.activate(
|
|
18
|
+
i18nUtils_1.i18n.activate(types_1.Languages.en);
|
|
18
19
|
});
|
|
19
|
-
test(`start display with the second page
|
|
20
|
+
test(`start display with the second page`, () => {
|
|
20
21
|
const acceptMock = jest.fn();
|
|
21
22
|
const declineMock = jest.fn();
|
|
22
23
|
const onClickOkMock = jest.fn();
|
|
23
|
-
const wrapper = react_native_testing_library_1.render(<RecommendationModal_1.default isVisible={true} attentionMessage={
|
|
24
|
+
const wrapper = react_native_testing_library_1.render(<RecommendationModal_1.default isVisible={true} attentionMessage={null} limitationMessage={null} suggestedCarbohydrates={2} onClickOkButton={onClickOkMock} onAcceptCarbohydrates={acceptMock} onDeclineCarbohydrates={declineMock}/>);
|
|
24
25
|
utils_1.expectTextExists(wrapper, `We recommend eating an additional:`);
|
|
25
26
|
utils_1.expectTextExists(wrapper, `2 `);
|
|
26
27
|
utils_1.expectTextExists(wrapper, `grams of carbohydrates`);
|
|
27
28
|
utils_1.expectTextExists(wrapper, `Instead of taking insulin`);
|
|
28
29
|
});
|
|
29
|
-
test(`accept carbs from second page
|
|
30
|
+
test(`accept carbs from second page`, () => {
|
|
30
31
|
const acceptMock = jest.fn();
|
|
31
32
|
const declineMock = jest.fn();
|
|
32
33
|
const onClickOkMock = jest.fn();
|
|
33
|
-
const wrapper = react_native_testing_library_1.render(<RecommendationModal_1.default isVisible={true} attentionMessage={
|
|
34
|
+
const wrapper = react_native_testing_library_1.render(<RecommendationModal_1.default isVisible={true} attentionMessage={null} limitationMessage={null} suggestedCarbohydrates={5} onClickOkButton={onClickOkMock} onAcceptCarbohydrates={acceptMock} onDeclineCarbohydrates={declineMock}/>);
|
|
34
35
|
utils_1.expectTextExists(wrapper, `We recommend eating an additional:`);
|
|
35
36
|
utils_1.expectTextExists(wrapper, `5 `);
|
|
36
37
|
utils_1.expectTextExists(wrapper, `grams of carbohydrates`);
|
|
37
|
-
const yesButtonModal = wrapper.
|
|
38
|
+
const yesButtonModal = wrapper.getByTestId(enum_1.RecommendationModalTestIds.AcceptCarbs);
|
|
38
39
|
react_native_testing_library_1.fireEvent(yesButtonModal, `onPress`);
|
|
39
40
|
expect(acceptMock).toBeCalled();
|
|
40
41
|
});
|
|
41
|
-
test(`decline carbs from second page
|
|
42
|
+
test(`decline carbs from second page`, () => {
|
|
42
43
|
const acceptMock = jest.fn();
|
|
43
44
|
const declineMock = jest.fn();
|
|
44
45
|
const onClickOkMock = jest.fn();
|
|
45
|
-
const wrapper = react_native_testing_library_1.render(<RecommendationModal_1.default isVisible={true} attentionMessage={
|
|
46
|
+
const wrapper = react_native_testing_library_1.render(<RecommendationModal_1.default isVisible={true} attentionMessage={null} limitationMessage={null} suggestedCarbohydrates={5} onClickOkButton={onClickOkMock} onAcceptCarbohydrates={acceptMock} onDeclineCarbohydrates={declineMock}/>);
|
|
46
47
|
utils_1.expectTextExists(wrapper, `We recommend eating an additional:`);
|
|
47
48
|
utils_1.expectTextExists(wrapper, `grams of carbohydrates`);
|
|
48
|
-
const noButtonModal = wrapper.
|
|
49
|
+
const noButtonModal = wrapper.getByTestId(enum_1.RecommendationModalTestIds.DeclineCarbs);
|
|
49
50
|
react_native_testing_library_1.fireEvent(noButtonModal, `onPress`);
|
|
50
51
|
expect(declineMock).toBeCalled();
|
|
51
52
|
});
|
|
@@ -58,12 +59,12 @@ describe(`RecommendationModal Component`, () => {
|
|
|
58
59
|
const wrapper = react_native_testing_library_1.render(<RecommendationModal_1.default isVisible={true} attentionMessage={attention} limitationMessage={limitation} suggestedCarbohydrates={0} onClickOkButton={onClickOkMock} onAcceptCarbohydrates={acceptMock} onDeclineCarbohydrates={declineMock}/>);
|
|
59
60
|
utils_1.expectTextExists(wrapper, limitation);
|
|
60
61
|
utils_1.expectTextExists(wrapper, `OK`);
|
|
61
|
-
const nextButton = wrapper.
|
|
62
|
+
const nextButton = wrapper.getByTestId(enum_1.LimitationMessageTestIds.OkButton);
|
|
62
63
|
react_native_testing_library_1.fireEvent(nextButton, `onPress`);
|
|
63
64
|
utils_1.expectTextExists(wrapper, attention);
|
|
64
65
|
utils_1.expectTextExists(wrapper, `OK`);
|
|
65
66
|
utils_1.expectTextNotExists(wrapper, `We recommend eating an additional:`);
|
|
66
|
-
const okayButton = wrapper.
|
|
67
|
+
const okayButton = wrapper.getByTestId(enum_1.RecommendationModalTestIds.OkButton);
|
|
67
68
|
react_native_testing_library_1.fireEvent(okayButton, `onPress`);
|
|
68
69
|
expect(onClickOkMock).toBeCalled();
|
|
69
70
|
});
|
|
@@ -72,28 +73,28 @@ describe(`RecommendationModal Component`, () => {
|
|
|
72
73
|
const declineMock = jest.fn();
|
|
73
74
|
const onClickOkMock = jest.fn();
|
|
74
75
|
const limitation = AttentionMessages_1.Messages.RecommendationWasLimited();
|
|
75
|
-
const wrapper = react_native_testing_library_1.render(<RecommendationModal_1.default isVisible={true} attentionMessage={
|
|
76
|
+
const wrapper = react_native_testing_library_1.render(<RecommendationModal_1.default isVisible={true} attentionMessage={null} limitationMessage={limitation} suggestedCarbohydrates={0} onClickOkButton={onClickOkMock} onAcceptCarbohydrates={acceptMock} onDeclineCarbohydrates={declineMock}/>);
|
|
76
77
|
utils_1.expectTextExists(wrapper, limitation);
|
|
77
78
|
utils_1.expectTextExists(wrapper, `OK`);
|
|
78
|
-
const nextButton = wrapper.
|
|
79
|
+
const nextButton = wrapper.getByTestId(enum_1.LimitationMessageTestIds.OkButton);
|
|
79
80
|
react_native_testing_library_1.fireEvent(nextButton, `onPress`);
|
|
80
81
|
expect(onClickOkMock).toBeCalled();
|
|
81
82
|
});
|
|
82
83
|
test.each `
|
|
83
|
-
language | locale
|
|
84
|
-
${`English`} | ${
|
|
85
|
-
${`Danish`} | ${
|
|
86
|
-
${`German`} | ${
|
|
87
|
-
${`Spanish`} | ${
|
|
88
|
-
${`Italian`} | ${
|
|
89
|
-
${`French`} | ${
|
|
84
|
+
language | locale | message
|
|
85
|
+
${`English`} | ${types_1.Languages.en} | ${`We recommend eating an additional:`}
|
|
86
|
+
${`Danish`} | ${types_1.Languages.da} | ${`Vi anbefaler at spise yderligere:`}
|
|
87
|
+
${`German`} | ${types_1.Languages.de} | ${`Wir empfehlen Ihnen, zusätzlich Folgendes zu essen:`}
|
|
88
|
+
${`Spanish`} | ${types_1.Languages.es} | ${`Recomendamos comer adicionalmente:`}
|
|
89
|
+
${`Italian`} | ${types_1.Languages.it} | ${`Consigliamo di ingerire una quantità supplementare:`}
|
|
90
|
+
${`French`} | ${types_1.Languages.fr} | ${`Nous vous recommandons de manger en plus :`}
|
|
90
91
|
`(`Modal renders attention messages in $language`, ({ message, locale }) => {
|
|
91
92
|
i18nUtils_1.i18n.activate(locale);
|
|
92
93
|
const acceptMock = jest.fn();
|
|
93
94
|
const declineMock = jest.fn();
|
|
94
95
|
const onClickOkMock = jest.fn();
|
|
95
96
|
const wrapper = react_native_testing_library_1.render(<react_1.I18nProvider language={locale} i18n={i18nUtils_1.i18n}>
|
|
96
|
-
<RecommendationModal_1.default isVisible={true} attentionMessage={
|
|
97
|
+
<RecommendationModal_1.default isVisible={true} attentionMessage={null} limitationMessage={null} suggestedCarbohydrates={2} onClickOkButton={onClickOkMock} onAcceptCarbohydrates={acceptMock} onDeclineCarbohydrates={declineMock}/>
|
|
97
98
|
,
|
|
98
99
|
</react_1.I18nProvider>);
|
|
99
100
|
utils_1.expectTextExists(wrapper, message);
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
+
import { Languages } from "@hedia/types";
|
|
1
2
|
import { I18nProvider } from "@lingui/react";
|
|
2
3
|
import React from "react";
|
|
3
4
|
import { cleanup, fireEvent, render } from "react-native-testing-library";
|
|
4
5
|
import RecommendationModal from "../../components/RecommendationModal";
|
|
5
6
|
import { i18n } from "../../locale/i18nUtils";
|
|
6
|
-
import {
|
|
7
|
+
import { LimitationMessageTestIds, RecommendationModalTestIds } from "../../types/enum";
|
|
7
8
|
import { Messages } from "../../utils/AttentionMessages";
|
|
8
9
|
import { expectTextExists, expectTextNotExists } from "../utils";
|
|
9
10
|
|
|
10
11
|
describe(`RecommendationModal Component`, (): void => {
|
|
11
12
|
afterEach(cleanup);
|
|
12
13
|
beforeEach((): void => {
|
|
13
|
-
i18n.activate(
|
|
14
|
+
i18n.activate(Languages.en);
|
|
14
15
|
});
|
|
15
16
|
|
|
16
|
-
test(`start display with the second page
|
|
17
|
+
test(`start display with the second page`, (): void => {
|
|
17
18
|
const acceptMock = jest.fn();
|
|
18
19
|
const declineMock = jest.fn();
|
|
19
20
|
const onClickOkMock = jest.fn();
|
|
20
21
|
const wrapper = render(
|
|
21
22
|
<RecommendationModal
|
|
22
23
|
isVisible={true}
|
|
23
|
-
attentionMessage={
|
|
24
|
-
limitationMessage={
|
|
24
|
+
attentionMessage={null}
|
|
25
|
+
limitationMessage={null}
|
|
25
26
|
suggestedCarbohydrates={2}
|
|
26
27
|
onClickOkButton={onClickOkMock}
|
|
27
28
|
onAcceptCarbohydrates={acceptMock}
|
|
@@ -33,15 +34,16 @@ describe(`RecommendationModal Component`, (): void => {
|
|
|
33
34
|
expectTextExists(wrapper, `grams of carbohydrates`);
|
|
34
35
|
expectTextExists(wrapper, `Instead of taking insulin`);
|
|
35
36
|
});
|
|
36
|
-
|
|
37
|
+
|
|
38
|
+
test(`accept carbs from second page`, (): void => {
|
|
37
39
|
const acceptMock = jest.fn();
|
|
38
40
|
const declineMock = jest.fn();
|
|
39
41
|
const onClickOkMock = jest.fn();
|
|
40
42
|
const wrapper = render(
|
|
41
43
|
<RecommendationModal
|
|
42
44
|
isVisible={true}
|
|
43
|
-
attentionMessage={
|
|
44
|
-
limitationMessage={
|
|
45
|
+
attentionMessage={null}
|
|
46
|
+
limitationMessage={null}
|
|
45
47
|
suggestedCarbohydrates={5}
|
|
46
48
|
onClickOkButton={onClickOkMock}
|
|
47
49
|
onAcceptCarbohydrates={acceptMock}
|
|
@@ -51,20 +53,20 @@ describe(`RecommendationModal Component`, (): void => {
|
|
|
51
53
|
expectTextExists(wrapper, `We recommend eating an additional:`);
|
|
52
54
|
expectTextExists(wrapper, `5 `);
|
|
53
55
|
expectTextExists(wrapper, `grams of carbohydrates`);
|
|
54
|
-
const yesButtonModal = wrapper.
|
|
56
|
+
const yesButtonModal = wrapper.getByTestId(RecommendationModalTestIds.AcceptCarbs);
|
|
55
57
|
fireEvent(yesButtonModal, `onPress`);
|
|
56
58
|
expect(acceptMock).toBeCalled();
|
|
57
59
|
});
|
|
58
60
|
|
|
59
|
-
test(`decline carbs from second page
|
|
61
|
+
test(`decline carbs from second page`, (): void => {
|
|
60
62
|
const acceptMock = jest.fn();
|
|
61
63
|
const declineMock = jest.fn();
|
|
62
64
|
const onClickOkMock = jest.fn();
|
|
63
65
|
const wrapper = render(
|
|
64
66
|
<RecommendationModal
|
|
65
67
|
isVisible={true}
|
|
66
|
-
attentionMessage={
|
|
67
|
-
limitationMessage={
|
|
68
|
+
attentionMessage={null}
|
|
69
|
+
limitationMessage={null}
|
|
68
70
|
suggestedCarbohydrates={5}
|
|
69
71
|
onClickOkButton={onClickOkMock}
|
|
70
72
|
onAcceptCarbohydrates={acceptMock}
|
|
@@ -73,7 +75,7 @@ describe(`RecommendationModal Component`, (): void => {
|
|
|
73
75
|
);
|
|
74
76
|
expectTextExists(wrapper, `We recommend eating an additional:`);
|
|
75
77
|
expectTextExists(wrapper, `grams of carbohydrates`);
|
|
76
|
-
const noButtonModal = wrapper.
|
|
78
|
+
const noButtonModal = wrapper.getByTestId(RecommendationModalTestIds.DeclineCarbs);
|
|
77
79
|
fireEvent(noButtonModal, `onPress`);
|
|
78
80
|
expect(declineMock).toBeCalled();
|
|
79
81
|
});
|
|
@@ -98,12 +100,12 @@ describe(`RecommendationModal Component`, (): void => {
|
|
|
98
100
|
);
|
|
99
101
|
expectTextExists(wrapper, limitation);
|
|
100
102
|
expectTextExists(wrapper, `OK`);
|
|
101
|
-
const nextButton = wrapper.
|
|
103
|
+
const nextButton = wrapper.getByTestId(LimitationMessageTestIds.OkButton);
|
|
102
104
|
fireEvent(nextButton, `onPress`);
|
|
103
105
|
expectTextExists(wrapper, attention);
|
|
104
106
|
expectTextExists(wrapper, `OK`);
|
|
105
107
|
expectTextNotExists(wrapper, `We recommend eating an additional:`);
|
|
106
|
-
const okayButton = wrapper.
|
|
108
|
+
const okayButton = wrapper.getByTestId(RecommendationModalTestIds.OkButton);
|
|
107
109
|
fireEvent(okayButton, `onPress`);
|
|
108
110
|
expect(onClickOkMock).toBeCalled();
|
|
109
111
|
});
|
|
@@ -116,7 +118,7 @@ describe(`RecommendationModal Component`, (): void => {
|
|
|
116
118
|
const wrapper = render(
|
|
117
119
|
<RecommendationModal
|
|
118
120
|
isVisible={true}
|
|
119
|
-
attentionMessage={
|
|
121
|
+
attentionMessage={null}
|
|
120
122
|
limitationMessage={limitation}
|
|
121
123
|
suggestedCarbohydrates={0}
|
|
122
124
|
onClickOkButton={onClickOkMock}
|
|
@@ -126,22 +128,22 @@ describe(`RecommendationModal Component`, (): void => {
|
|
|
126
128
|
);
|
|
127
129
|
expectTextExists(wrapper, limitation);
|
|
128
130
|
expectTextExists(wrapper, `OK`);
|
|
129
|
-
const nextButton = wrapper.
|
|
131
|
+
const nextButton = wrapper.getByTestId(LimitationMessageTestIds.OkButton);
|
|
130
132
|
fireEvent(nextButton, `onPress`);
|
|
131
133
|
expect(onClickOkMock).toBeCalled();
|
|
132
134
|
});
|
|
133
135
|
|
|
134
136
|
test.each`
|
|
135
|
-
language | locale
|
|
136
|
-
${`English`} | ${
|
|
137
|
-
${`Danish`} | ${
|
|
138
|
-
${`German`} | ${
|
|
139
|
-
${`Spanish`} | ${
|
|
140
|
-
${`Italian`} | ${
|
|
141
|
-
${`French`} | ${
|
|
137
|
+
language | locale | message
|
|
138
|
+
${`English`} | ${Languages.en} | ${`We recommend eating an additional:`}
|
|
139
|
+
${`Danish`} | ${Languages.da} | ${`Vi anbefaler at spise yderligere:`}
|
|
140
|
+
${`German`} | ${Languages.de} | ${`Wir empfehlen Ihnen, zusätzlich Folgendes zu essen:`}
|
|
141
|
+
${`Spanish`} | ${Languages.es} | ${`Recomendamos comer adicionalmente:`}
|
|
142
|
+
${`Italian`} | ${Languages.it} | ${`Consigliamo di ingerire una quantità supplementare:`}
|
|
143
|
+
${`French`} | ${Languages.fr} | ${`Nous vous recommandons de manger en plus :`}
|
|
142
144
|
`(
|
|
143
145
|
`Modal renders attention messages in $language`,
|
|
144
|
-
({ message, locale }: { locale:
|
|
146
|
+
({ message, locale }: { locale: Languages; message: string }): void => {
|
|
145
147
|
i18n.activate(locale);
|
|
146
148
|
const acceptMock = jest.fn();
|
|
147
149
|
const declineMock = jest.fn();
|
|
@@ -150,8 +152,8 @@ describe(`RecommendationModal Component`, (): void => {
|
|
|
150
152
|
<I18nProvider language={locale} i18n={i18n}>
|
|
151
153
|
<RecommendationModal
|
|
152
154
|
isVisible={true}
|
|
153
|
-
attentionMessage={
|
|
154
|
-
limitationMessage={
|
|
155
|
+
attentionMessage={null}
|
|
156
|
+
limitationMessage={null}
|
|
155
157
|
suggestedCarbohydrates={2}
|
|
156
158
|
onClickOkButton={onClickOkMock}
|
|
157
159
|
onAcceptCarbohydrates={acceptMock}
|
|
File without changes
|
|
@@ -7,6 +7,7 @@ const react_1 = __importDefault(require("react"));
|
|
|
7
7
|
const react_native_testing_library_1 = require("react-native-testing-library");
|
|
8
8
|
const InvisibleNumberInput_1 = __importDefault(require("../../components/InvisibleNumberInput"));
|
|
9
9
|
const RecommendedCarbs_1 = __importDefault(require("../../components/RecommendedCarbs"));
|
|
10
|
+
const enum_1 = require("../../types/enum");
|
|
10
11
|
const utils_1 = require("../utils");
|
|
11
12
|
describe(`Calculation Component`, () => {
|
|
12
13
|
afterEach(react_native_testing_library_1.cleanup);
|
|
@@ -20,8 +21,7 @@ describe(`Calculation Component`, () => {
|
|
|
20
21
|
utils_1.expectTextExists(wrapper, `10`);
|
|
21
22
|
utils_1.expectTextExists(wrapper, `25`);
|
|
22
23
|
utils_1.expectTextExists(wrapper, `35`);
|
|
23
|
-
const invisInput = wrapper.
|
|
24
|
-
expect(invisInput).not.toBeNull();
|
|
24
|
+
const invisInput = wrapper.getByTestId(enum_1.RecommendedCarbsTestIds.InvisibleCarbInput);
|
|
25
25
|
react_native_testing_library_1.fireEvent(invisInput, `onEnd`, newValue);
|
|
26
26
|
expect(changeMock).toBeCalledWith(newValue);
|
|
27
27
|
wrapper.rerender(<RecommendedCarbs_1.default enteredCarbs={`10`} recommendedCarbs={`${newValue}`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock}/>);
|
|
@@ -68,7 +68,7 @@ describe(`Calculation Component`, () => {
|
|
|
68
68
|
utils_1.expectTextExists(wrapper, `Food`);
|
|
69
69
|
utils_1.expectTextExists(wrapper, `Additional`);
|
|
70
70
|
expect(wrapper.getAllByText(`12`).length).toBe(2);
|
|
71
|
-
const carbButton = wrapper.
|
|
71
|
+
const carbButton = wrapper.getByTestId(enum_1.RecommendedCarbsTestIds.EditRecommendedCarbs);
|
|
72
72
|
react_native_testing_library_1.fireEvent(carbButton, `onPress`);
|
|
73
73
|
expect(wrapper.getAllByText(`12`).length).toBe(2);
|
|
74
74
|
});
|
|
@@ -78,11 +78,9 @@ describe(`Calculation Component`, () => {
|
|
|
78
78
|
const wrapper = react_native_testing_library_1.render(<RecommendedCarbs_1.default enteredCarbs={`0`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock} recommendedCarbs={`12`}/>);
|
|
79
79
|
utils_1.expectTextExists(wrapper, `Food`);
|
|
80
80
|
utils_1.expectTextExists(wrapper, `Additional`);
|
|
81
|
-
const carbButton = wrapper.
|
|
82
|
-
expect(carbButton).not.toBeNull();
|
|
81
|
+
const carbButton = wrapper.getByTestId(enum_1.RecommendedCarbsTestIds.EditRecommendedCarbs);
|
|
83
82
|
react_native_testing_library_1.fireEvent(carbButton, `onPress`);
|
|
84
|
-
const invisInput = wrapper.
|
|
85
|
-
expect(invisInput).not.toBeNull();
|
|
83
|
+
const invisInput = wrapper.getByTestId(enum_1.RecommendedCarbsTestIds.InvisibleCarbInput);
|
|
86
84
|
react_native_testing_library_1.fireEvent(invisInput, `onEndEditing`);
|
|
87
85
|
expect(changeMock).toBeCalledWith(Number(`12`));
|
|
88
86
|
});
|
|
@@ -92,7 +90,7 @@ describe(`Calculation Component`, () => {
|
|
|
92
90
|
const wrapper = react_native_testing_library_1.render(<RecommendedCarbs_1.default enteredCarbs={`0`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock} recommendedCarbs={`-12`}/>);
|
|
93
91
|
utils_1.expectTextExists(wrapper, `Food`);
|
|
94
92
|
utils_1.expectTextNotExists(wrapper, `Additional`);
|
|
95
|
-
const carbButton = wrapper.
|
|
93
|
+
const carbButton = wrapper.queryByTestId(enum_1.RecommendedCarbsTestIds.EditRecommendedCarbs);
|
|
96
94
|
expect(carbButton).toBeNull();
|
|
97
95
|
});
|
|
98
96
|
test(`Negative carbs doesn't invoke changedRecommendedCarbs callback`, () => {
|
|
@@ -109,8 +107,7 @@ describe(`Calculation Component`, () => {
|
|
|
109
107
|
const changeMock = jest.fn();
|
|
110
108
|
const wrapper = react_native_testing_library_1.render(<RecommendedCarbs_1.default enteredCarbs={`0`} recommendedCarbs={`25`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock}/>);
|
|
111
109
|
expect(wrapper.getAllByText(`25`).length).toBe(2);
|
|
112
|
-
const invisInput = wrapper.
|
|
113
|
-
expect(invisInput).not.toBeNull();
|
|
110
|
+
const invisInput = wrapper.getByTestId(enum_1.RecommendedCarbsTestIds.InvisibleCarbInput);
|
|
114
111
|
react_native_testing_library_1.fireEvent(invisInput, `onEnd`, 302);
|
|
115
112
|
expect(wrapper.getAllByText(`25`).length).toBe(2);
|
|
116
113
|
utils_1.expectTextNotExists(wrapper, `302`);
|
|
@@ -3,6 +3,7 @@ import { cleanup, fireEvent, render } from "react-native-testing-library";
|
|
|
3
3
|
|
|
4
4
|
import InvisibleNumberInput from "../../components/InvisibleNumberInput";
|
|
5
5
|
import RecommendedCarbs from "../../components/RecommendedCarbs";
|
|
6
|
+
import { RecommendedCarbsTestIds } from "../../types/enum";
|
|
6
7
|
import { expectTextExists, expectTextNotExists } from "../utils";
|
|
7
8
|
|
|
8
9
|
describe(`Calculation Component`, (): void => {
|
|
@@ -26,8 +27,8 @@ describe(`Calculation Component`, (): void => {
|
|
|
26
27
|
expectTextExists(wrapper, `25`);
|
|
27
28
|
expectTextExists(wrapper, `35`);
|
|
28
29
|
|
|
29
|
-
const invisInput = wrapper.
|
|
30
|
-
|
|
30
|
+
const invisInput = wrapper.getByTestId(RecommendedCarbsTestIds.InvisibleCarbInput);
|
|
31
|
+
|
|
31
32
|
fireEvent(invisInput, `onEnd`, newValue);
|
|
32
33
|
expect(changeMock).toBeCalledWith(newValue);
|
|
33
34
|
|
|
@@ -122,7 +123,7 @@ describe(`Calculation Component`, (): void => {
|
|
|
122
123
|
expectTextExists(wrapper, `Additional`);
|
|
123
124
|
expect(wrapper.getAllByText(`12`).length).toBe(2);
|
|
124
125
|
|
|
125
|
-
const carbButton = wrapper.
|
|
126
|
+
const carbButton = wrapper.getByTestId(RecommendedCarbsTestIds.EditRecommendedCarbs);
|
|
126
127
|
fireEvent(carbButton, `onPress`);
|
|
127
128
|
|
|
128
129
|
expect(wrapper.getAllByText(`12`).length).toBe(2);
|
|
@@ -142,12 +143,11 @@ describe(`Calculation Component`, (): void => {
|
|
|
142
143
|
expectTextExists(wrapper, `Food`);
|
|
143
144
|
expectTextExists(wrapper, `Additional`);
|
|
144
145
|
|
|
145
|
-
const carbButton = wrapper.
|
|
146
|
-
|
|
146
|
+
const carbButton = wrapper.getByTestId(RecommendedCarbsTestIds.EditRecommendedCarbs);
|
|
147
|
+
|
|
147
148
|
fireEvent(carbButton, `onPress`);
|
|
148
149
|
|
|
149
|
-
const invisInput = wrapper.
|
|
150
|
-
expect(invisInput).not.toBeNull();
|
|
150
|
+
const invisInput = wrapper.getByTestId(RecommendedCarbsTestIds.InvisibleCarbInput);
|
|
151
151
|
|
|
152
152
|
fireEvent(invisInput, `onEndEditing`);
|
|
153
153
|
expect(changeMock).toBeCalledWith(Number(`12`));
|
|
@@ -167,7 +167,7 @@ describe(`Calculation Component`, (): void => {
|
|
|
167
167
|
expectTextExists(wrapper, `Food`);
|
|
168
168
|
expectTextNotExists(wrapper, `Additional`);
|
|
169
169
|
|
|
170
|
-
const carbButton = wrapper.
|
|
170
|
+
const carbButton = wrapper.queryByTestId(RecommendedCarbsTestIds.EditRecommendedCarbs);
|
|
171
171
|
expect(carbButton).toBeNull();
|
|
172
172
|
});
|
|
173
173
|
|
|
@@ -204,8 +204,7 @@ describe(`Calculation Component`, (): void => {
|
|
|
204
204
|
);
|
|
205
205
|
expect(wrapper.getAllByText(`25`).length).toBe(2);
|
|
206
206
|
|
|
207
|
-
const invisInput = wrapper.
|
|
208
|
-
expect(invisInput).not.toBeNull();
|
|
207
|
+
const invisInput = wrapper.getByTestId(RecommendedCarbsTestIds.InvisibleCarbInput);
|
|
209
208
|
|
|
210
209
|
fireEvent(invisInput, `onEnd`, 302);
|
|
211
210
|
expect(wrapper.getAllByText(`25`).length).toBe(2);
|
|
File without changes
|
|
@@ -3,57 +3,64 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const types_1 = require("@hedia/types");
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const react_native_1 = require("react-native");
|
|
9
9
|
const react_native_testing_library_1 = require("react-native-testing-library");
|
|
10
|
-
const InvisibleNumberInput_1 = __importDefault(require("../../components/InvisibleNumberInput"));
|
|
11
10
|
const RecommendedInsulin_1 = __importDefault(require("../../components/RecommendedInsulin"));
|
|
12
11
|
const enum_1 = require("../../types/enum");
|
|
13
12
|
const utils_1 = require("../utils");
|
|
13
|
+
const SAFETY_INSULIN_LIMIT = types_1.BolusCalculator.Constants.SAFETY_INSULIN_LIMIT;
|
|
14
|
+
const InjectionMethod = types_1.UserSettings.Enums.InjectionMethod;
|
|
15
|
+
const { PenHalf, PenWhole, Pump } = InjectionMethod;
|
|
14
16
|
describe(`RecommendedInsulin - Component`, () => {
|
|
15
17
|
afterEach(react_native_testing_library_1.cleanup);
|
|
16
18
|
test(`Component is rendered`, () => {
|
|
17
19
|
const updateMock = jest.fn();
|
|
18
|
-
const method =
|
|
19
|
-
const wrapper = react_native_testing_library_1.render(<RecommendedInsulin_1.default insulinRecommendation={2.3} updateRecommendedInsulin={updateMock} injectionMethod={method}/>);
|
|
20
|
+
const method = Pump;
|
|
21
|
+
const wrapper = react_native_testing_library_1.render(<RecommendedInsulin_1.default insulinRecommendation={2.3} updateRecommendedInsulin={updateMock} injectionMethod={method} activityReduction={null} enteredInsulin={null}/>);
|
|
20
22
|
utils_1.expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
21
23
|
utils_1.expectTextExists(wrapper, `2.3`);
|
|
22
24
|
utils_1.expectTextExists(wrapper, `Units`);
|
|
23
25
|
});
|
|
24
26
|
test(`Insulin props defaults to 0`, () => {
|
|
25
27
|
const updateMock = jest.fn();
|
|
26
|
-
const method =
|
|
28
|
+
const method = PenHalf;
|
|
29
|
+
// @ts-ignore
|
|
27
30
|
const wrapper = react_native_testing_library_1.render(<RecommendedInsulin_1.default updateRecommendedInsulin={updateMock} injectionMethod={method}/>);
|
|
28
31
|
utils_1.expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
29
32
|
utils_1.expectTextExists(wrapper, `0`);
|
|
30
33
|
utils_1.expectTextExists(wrapper, `Units`);
|
|
31
34
|
});
|
|
32
35
|
test.each `
|
|
33
|
-
method
|
|
34
|
-
${
|
|
35
|
-
${
|
|
36
|
-
${
|
|
37
|
-
${
|
|
38
|
-
${
|
|
39
|
-
${
|
|
40
|
-
${
|
|
41
|
-
${
|
|
42
|
-
${
|
|
43
|
-
`(`Rounding $amount using $method to $result`, ({ amount, method, result }) => {
|
|
36
|
+
method | amount | result
|
|
37
|
+
${PenWhole} | ${1} | ${1}
|
|
38
|
+
${PenWhole} | ${1.49} | ${1}
|
|
39
|
+
${PenWhole} | ${1.5} | ${2}
|
|
40
|
+
${PenHalf} | ${1.24} | ${1}
|
|
41
|
+
${PenHalf} | ${1.25} | ${1.5}
|
|
42
|
+
${PenHalf} | ${1.74} | ${1.5}
|
|
43
|
+
${Pump} | ${1.14} | ${1.1}
|
|
44
|
+
${Pump} | ${1.15} | ${1.2}
|
|
45
|
+
${Pump} | ${12.35} | ${12.4}
|
|
46
|
+
`(`Rounding $amount using $method to $result`, ({ amount, method, result, }) => {
|
|
44
47
|
const updateMock = jest.fn();
|
|
45
|
-
const wrapper = react_native_testing_library_1.render(
|
|
48
|
+
const wrapper = react_native_testing_library_1.render(
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
<RecommendedInsulin_1.default updateRecommendedInsulin={updateMock} injectionMethod={method}/>);
|
|
46
51
|
utils_1.expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
47
|
-
const input = wrapper.
|
|
52
|
+
const input = wrapper.getByTestId(enum_1.RecommendedInsulinTestIds.InvisibleInsulinInput);
|
|
48
53
|
react_native_testing_library_1.fireEvent(input, `onEnd`, amount);
|
|
49
54
|
utils_1.expectTextExists(wrapper, `${result}`);
|
|
50
55
|
expect(updateMock).toBeCalledWith(result);
|
|
51
56
|
});
|
|
52
57
|
test(`Throw error on Unsupported InjectMethod`, () => {
|
|
53
58
|
const updateMock = jest.fn();
|
|
54
|
-
const wrapper = react_native_testing_library_1.render(
|
|
59
|
+
const wrapper = react_native_testing_library_1.render(
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
<RecommendedInsulin_1.default updateRecommendedInsulin={updateMock} injectionMethod={`Error`}/>);
|
|
55
62
|
utils_1.expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
56
|
-
const input = wrapper.
|
|
63
|
+
const input = wrapper.getByTestId(enum_1.RecommendedInsulinTestIds.InvisibleInsulinInput);
|
|
57
64
|
expect(() => react_native_testing_library_1.fireEvent(input, `onEnd`)).toThrowError(`Unsupported InjectionMethod: Error`);
|
|
58
65
|
});
|
|
59
66
|
test.each `
|
|
@@ -62,9 +69,11 @@ describe(`RecommendedInsulin - Component`, () => {
|
|
|
62
69
|
${0.1} | ${0.1}
|
|
63
70
|
`(`Will not remove leading zero from $value`, ({ result, value }) => {
|
|
64
71
|
const updateMock = jest.fn();
|
|
65
|
-
const wrapper = react_native_testing_library_1.render(
|
|
72
|
+
const wrapper = react_native_testing_library_1.render(
|
|
73
|
+
// @ts-ignore
|
|
74
|
+
<RecommendedInsulin_1.default updateRecommendedInsulin={updateMock} injectionMethod={Pump}/>);
|
|
66
75
|
utils_1.expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
67
|
-
const input = wrapper.
|
|
76
|
+
const input = wrapper.getByTestId(enum_1.RecommendedInsulinTestIds.InvisibleInsulinInput);
|
|
68
77
|
react_native_testing_library_1.fireEvent(input, `onEnd`, value);
|
|
69
78
|
utils_1.expectTextExists(wrapper, `${result}`);
|
|
70
79
|
});
|
|
@@ -74,18 +83,21 @@ describe(`RecommendedInsulin - Component`, () => {
|
|
|
74
83
|
${`09.1`} | ${9.1}
|
|
75
84
|
`(`Will remove leading zero from $value`, ({ result, value }) => {
|
|
76
85
|
const updateMock = jest.fn();
|
|
77
|
-
const wrapper = react_native_testing_library_1.render(
|
|
86
|
+
const wrapper = react_native_testing_library_1.render(
|
|
87
|
+
// @ts-ignore
|
|
88
|
+
<RecommendedInsulin_1.default updateRecommendedInsulin={updateMock} injectionMethod={Pump}/>);
|
|
78
89
|
utils_1.expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
79
|
-
const input = wrapper.
|
|
90
|
+
const input = wrapper.getByTestId(enum_1.RecommendedInsulinTestIds.InvisibleInsulinInput);
|
|
80
91
|
react_native_testing_library_1.fireEvent(input, `partialInput`, value);
|
|
81
92
|
utils_1.expectTextExists(wrapper, `${result}`);
|
|
82
93
|
});
|
|
83
94
|
test(`Pressing on TouchableOpacity will callback on the invisible text input`, () => {
|
|
84
95
|
const updateMock = jest.fn();
|
|
85
|
-
const wrapper = react_native_testing_library_1.render(
|
|
96
|
+
const wrapper = react_native_testing_library_1.render(
|
|
97
|
+
// @ts-ignore
|
|
98
|
+
<RecommendedInsulin_1.default updateRecommendedInsulin={updateMock} injectionMethod={Pump}/>);
|
|
86
99
|
utils_1.expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
87
|
-
const button = wrapper.
|
|
88
|
-
expect(button).not.toBeNull();
|
|
100
|
+
const button = wrapper.getByTestId(enum_1.RecommendedInsulinTestIds.EditRecommendedInsulin);
|
|
89
101
|
react_native_testing_library_1.fireEvent(button, `onPress`);
|
|
90
102
|
});
|
|
91
103
|
test.each `
|
|
@@ -98,9 +110,11 @@ describe(`RecommendedInsulin - Component`, () => {
|
|
|
98
110
|
${`15`} | ${0.75} | ${false}
|
|
99
111
|
`(`Throws an error at insulin limits`, ({ reduction, isCorrect, value }) => {
|
|
100
112
|
const updateMock = jest.fn();
|
|
101
|
-
const wrapper = react_native_testing_library_1.render(
|
|
113
|
+
const wrapper = react_native_testing_library_1.render(
|
|
114
|
+
// @ts-ignore
|
|
115
|
+
<RecommendedInsulin_1.default activityReduction={reduction} updateRecommendedInsulin={updateMock} injectionMethod={Pump}/>);
|
|
102
116
|
utils_1.expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
103
|
-
const input = wrapper.
|
|
117
|
+
const input = wrapper.getByTestId(enum_1.RecommendedInsulinTestIds.InvisibleInsulinInput);
|
|
104
118
|
react_native_testing_library_1.fireEvent(input, `onEnd`, value);
|
|
105
119
|
if (isCorrect) {
|
|
106
120
|
utils_1.expectTextExists(wrapper, value);
|
|
@@ -112,19 +126,19 @@ describe(`RecommendedInsulin - Component`, () => {
|
|
|
112
126
|
});
|
|
113
127
|
test.each `
|
|
114
128
|
reduction | expected | reductionPercent
|
|
115
|
-
${null} | ${
|
|
116
|
-
${undefined} | ${
|
|
117
|
-
${0} | ${
|
|
118
|
-
${0.1} | ${
|
|
119
|
-
${0.25} | ${
|
|
120
|
-
${0.5} | ${
|
|
121
|
-
${0.75} | ${
|
|
122
|
-
${0.9} | ${
|
|
129
|
+
${null} | ${SAFETY_INSULIN_LIMIT * (1 - 0)} | ${`${0 * 100}%`}
|
|
130
|
+
${undefined} | ${SAFETY_INSULIN_LIMIT * (1 - 0)} | ${`${0 * 100}%`}
|
|
131
|
+
${0} | ${SAFETY_INSULIN_LIMIT * (1 - 0)} | ${`${0 * 100}%`}
|
|
132
|
+
${0.1} | ${SAFETY_INSULIN_LIMIT * (1 - 0.1)} | ${`${0.1 * 100}%`}
|
|
133
|
+
${0.25} | ${SAFETY_INSULIN_LIMIT * (1 - 0.25)} | ${`${0.25 * 100}%`}
|
|
134
|
+
${0.5} | ${SAFETY_INSULIN_LIMIT * (1 - 0.5)} | ${`${0.5 * 100}%`}
|
|
135
|
+
${0.75} | ${SAFETY_INSULIN_LIMIT * (1 - 0.75)} | ${`${0.75 * 100}%`}
|
|
136
|
+
${0.9} | ${SAFETY_INSULIN_LIMIT * (1 - 0.9)} | ${`${0.9 * 100}%`}
|
|
123
137
|
`(`Recommendation is limited when entering over the maximum safety threshold of insulin when activity reduction is $reductionPercent`, ({ expected, reduction }) => {
|
|
124
138
|
const updateMock = jest.fn();
|
|
125
|
-
const wrapper = react_native_testing_library_1.render(<RecommendedInsulin_1.default insulinRecommendation={expected} updateRecommendedInsulin={updateMock} injectionMethod={
|
|
126
|
-
const input = wrapper.
|
|
127
|
-
const INVALID_INSULIN =
|
|
139
|
+
const wrapper = react_native_testing_library_1.render(<RecommendedInsulin_1.default insulinRecommendation={expected} updateRecommendedInsulin={updateMock} injectionMethod={Pump} activityReduction={reduction} enteredInsulin={null}/>);
|
|
140
|
+
const input = wrapper.getByTestId(enum_1.RecommendedInsulinTestIds.InvisibleInsulinInput);
|
|
141
|
+
const INVALID_INSULIN = SAFETY_INSULIN_LIMIT + 1;
|
|
128
142
|
react_native_testing_library_1.fireEvent(input, `onEnd`, INVALID_INSULIN);
|
|
129
143
|
expect(updateMock).toBeCalledWith(expected);
|
|
130
144
|
});
|
|
@@ -135,7 +149,9 @@ describe(`RecommendedInsulin - Component`, () => {
|
|
|
135
149
|
`(`On $platform the component has $padding paddingBottom`, ({ padding, platform }) => {
|
|
136
150
|
react_native_1.Platform.OS = platform;
|
|
137
151
|
const updateMock = jest.fn();
|
|
138
|
-
const wrapper = react_native_testing_library_1.render(
|
|
152
|
+
const wrapper = react_native_testing_library_1.render(
|
|
153
|
+
// @ts-ignore
|
|
154
|
+
<RecommendedInsulin_1.default updateRecommendedInsulin={updateMock} injectionMethod={Pump}/>);
|
|
139
155
|
expect(!!new RegExp(`"paddingBottom":"${padding}"`).exec(JSON.stringify(wrapper.toJSON()))).toBeTruthy();
|
|
140
156
|
});
|
|
141
157
|
});
|