@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,23 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BolusCalculator, UserSettings } from "@hedia/types";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { Platform } from "react-native";
|
|
4
4
|
import { cleanup, fireEvent, render } from "react-native-testing-library";
|
|
5
|
-
import InvisibleNumberInput from "../../components/InvisibleNumberInput";
|
|
6
5
|
import RecommendedInsulin from "../../components/RecommendedInsulin";
|
|
7
|
-
import {
|
|
6
|
+
import { RecommendedInsulinTestIds } from "../../types/enum";
|
|
8
7
|
import { expectTextExists, expectTextNotExists } from "../utils";
|
|
9
8
|
|
|
9
|
+
const SAFETY_INSULIN_LIMIT = BolusCalculator.Constants.SAFETY_INSULIN_LIMIT;
|
|
10
|
+
const InjectionMethod = UserSettings.Enums.InjectionMethod;
|
|
11
|
+
|
|
12
|
+
const { PenHalf, PenWhole, Pump } = InjectionMethod;
|
|
13
|
+
|
|
10
14
|
describe(`RecommendedInsulin - Component`, (): void => {
|
|
11
15
|
afterEach(cleanup);
|
|
12
16
|
|
|
13
17
|
test(`Component is rendered`, (): void => {
|
|
14
18
|
const updateMock = jest.fn();
|
|
15
|
-
const method: InjectionMethod =
|
|
19
|
+
const method: UserSettings.Enums.InjectionMethod = Pump;
|
|
16
20
|
const wrapper = render(
|
|
17
21
|
<RecommendedInsulin
|
|
18
22
|
insulinRecommendation={2.3}
|
|
19
23
|
updateRecommendedInsulin={updateMock}
|
|
20
24
|
injectionMethod={method}
|
|
25
|
+
activityReduction={null}
|
|
26
|
+
enteredInsulin={null}
|
|
21
27
|
/>,
|
|
22
28
|
);
|
|
23
29
|
|
|
@@ -28,7 +34,9 @@ describe(`RecommendedInsulin - Component`, (): void => {
|
|
|
28
34
|
|
|
29
35
|
test(`Insulin props defaults to 0`, (): void => {
|
|
30
36
|
const updateMock = jest.fn();
|
|
31
|
-
const method: InjectionMethod =
|
|
37
|
+
const method: UserSettings.Enums.InjectionMethod = PenHalf;
|
|
38
|
+
|
|
39
|
+
// @ts-ignore
|
|
32
40
|
const wrapper = render(<RecommendedInsulin updateRecommendedInsulin={updateMock} injectionMethod={method} />);
|
|
33
41
|
|
|
34
42
|
expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
@@ -37,27 +45,36 @@ describe(`RecommendedInsulin - Component`, (): void => {
|
|
|
37
45
|
});
|
|
38
46
|
|
|
39
47
|
test.each`
|
|
40
|
-
method
|
|
41
|
-
${
|
|
42
|
-
${
|
|
43
|
-
${
|
|
44
|
-
${
|
|
45
|
-
${
|
|
46
|
-
${
|
|
47
|
-
${
|
|
48
|
-
${
|
|
49
|
-
${
|
|
48
|
+
method | amount | result
|
|
49
|
+
${PenWhole} | ${1} | ${1}
|
|
50
|
+
${PenWhole} | ${1.49} | ${1}
|
|
51
|
+
${PenWhole} | ${1.5} | ${2}
|
|
52
|
+
${PenHalf} | ${1.24} | ${1}
|
|
53
|
+
${PenHalf} | ${1.25} | ${1.5}
|
|
54
|
+
${PenHalf} | ${1.74} | ${1.5}
|
|
55
|
+
${Pump} | ${1.14} | ${1.1}
|
|
56
|
+
${Pump} | ${1.15} | ${1.2}
|
|
57
|
+
${Pump} | ${12.35} | ${12.4}
|
|
50
58
|
`(
|
|
51
59
|
`Rounding $amount using $method to $result`,
|
|
52
|
-
({
|
|
60
|
+
({
|
|
61
|
+
amount,
|
|
62
|
+
method,
|
|
63
|
+
result,
|
|
64
|
+
}: {
|
|
65
|
+
method: UserSettings.Enums.InjectionMethod;
|
|
66
|
+
amount: number;
|
|
67
|
+
result: number;
|
|
68
|
+
}): void => {
|
|
53
69
|
const updateMock = jest.fn();
|
|
54
70
|
const wrapper = render(
|
|
71
|
+
// @ts-ignore
|
|
55
72
|
<RecommendedInsulin updateRecommendedInsulin={updateMock} injectionMethod={method} />,
|
|
56
73
|
);
|
|
57
74
|
|
|
58
75
|
expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
59
76
|
|
|
60
|
-
const input = wrapper.
|
|
77
|
+
const input = wrapper.getByTestId(RecommendedInsulinTestIds.InvisibleInsulinInput);
|
|
61
78
|
|
|
62
79
|
fireEvent(input, `onEnd`, amount);
|
|
63
80
|
expectTextExists(wrapper, `${result}`);
|
|
@@ -69,12 +86,16 @@ describe(`RecommendedInsulin - Component`, (): void => {
|
|
|
69
86
|
const updateMock = jest.fn();
|
|
70
87
|
|
|
71
88
|
const wrapper = render(
|
|
72
|
-
|
|
89
|
+
// @ts-ignore
|
|
90
|
+
<RecommendedInsulin
|
|
91
|
+
updateRecommendedInsulin={updateMock}
|
|
92
|
+
injectionMethod={`Error` as UserSettings.Enums.InjectionMethod}
|
|
93
|
+
/>,
|
|
73
94
|
);
|
|
74
95
|
|
|
75
96
|
expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
76
97
|
|
|
77
|
-
const input = wrapper.
|
|
98
|
+
const input = wrapper.getByTestId(RecommendedInsulinTestIds.InvisibleInsulinInput);
|
|
78
99
|
|
|
79
100
|
expect((): void => fireEvent(input, `onEnd`)).toThrowError(`Unsupported InjectionMethod: Error`);
|
|
80
101
|
});
|
|
@@ -86,12 +107,13 @@ describe(`RecommendedInsulin - Component`, (): void => {
|
|
|
86
107
|
`(`Will not remove leading zero from $value`, ({ result, value }: { value: number; result: number }): void => {
|
|
87
108
|
const updateMock = jest.fn();
|
|
88
109
|
const wrapper = render(
|
|
89
|
-
|
|
110
|
+
// @ts-ignore
|
|
111
|
+
<RecommendedInsulin updateRecommendedInsulin={updateMock} injectionMethod={Pump} />,
|
|
90
112
|
);
|
|
91
113
|
|
|
92
114
|
expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
93
115
|
|
|
94
|
-
const input = wrapper.
|
|
116
|
+
const input = wrapper.getByTestId(RecommendedInsulinTestIds.InvisibleInsulinInput);
|
|
95
117
|
fireEvent(input, `onEnd`, value);
|
|
96
118
|
expectTextExists(wrapper, `${result}`);
|
|
97
119
|
});
|
|
@@ -103,12 +125,13 @@ describe(`RecommendedInsulin - Component`, (): void => {
|
|
|
103
125
|
`(`Will remove leading zero from $value`, ({ result, value }: { value: string; result: number }): void => {
|
|
104
126
|
const updateMock = jest.fn();
|
|
105
127
|
const wrapper = render(
|
|
106
|
-
|
|
128
|
+
// @ts-ignore
|
|
129
|
+
<RecommendedInsulin updateRecommendedInsulin={updateMock} injectionMethod={Pump} />,
|
|
107
130
|
);
|
|
108
131
|
|
|
109
132
|
expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
110
133
|
|
|
111
|
-
const input = wrapper.
|
|
134
|
+
const input = wrapper.getByTestId(RecommendedInsulinTestIds.InvisibleInsulinInput);
|
|
112
135
|
fireEvent(input, `partialInput`, value);
|
|
113
136
|
expectTextExists(wrapper, `${result}`);
|
|
114
137
|
});
|
|
@@ -116,13 +139,13 @@ describe(`RecommendedInsulin - Component`, (): void => {
|
|
|
116
139
|
test(`Pressing on TouchableOpacity will callback on the invisible text input`, (): void => {
|
|
117
140
|
const updateMock = jest.fn();
|
|
118
141
|
const wrapper = render(
|
|
119
|
-
|
|
142
|
+
// @ts-ignore
|
|
143
|
+
<RecommendedInsulin updateRecommendedInsulin={updateMock} injectionMethod={Pump} />,
|
|
120
144
|
);
|
|
121
145
|
|
|
122
146
|
expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
123
147
|
|
|
124
|
-
const button = wrapper.
|
|
125
|
-
expect(button).not.toBeNull();
|
|
148
|
+
const button = wrapper.getByTestId(RecommendedInsulinTestIds.EditRecommendedInsulin);
|
|
126
149
|
|
|
127
150
|
fireEvent(button, `onPress`);
|
|
128
151
|
});
|
|
@@ -140,16 +163,17 @@ describe(`RecommendedInsulin - Component`, (): void => {
|
|
|
140
163
|
({ reduction, isCorrect, value }: { value: string; reduction: number; isCorrect: boolean }): void => {
|
|
141
164
|
const updateMock = jest.fn();
|
|
142
165
|
const wrapper = render(
|
|
166
|
+
// @ts-ignore
|
|
143
167
|
<RecommendedInsulin
|
|
144
168
|
activityReduction={reduction}
|
|
145
169
|
updateRecommendedInsulin={updateMock}
|
|
146
|
-
injectionMethod={
|
|
170
|
+
injectionMethod={Pump}
|
|
147
171
|
/>,
|
|
148
172
|
);
|
|
149
173
|
|
|
150
174
|
expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
151
175
|
|
|
152
|
-
const input = wrapper.
|
|
176
|
+
const input = wrapper.getByTestId(RecommendedInsulinTestIds.InvisibleInsulinInput);
|
|
153
177
|
fireEvent(input, `onEnd`, value);
|
|
154
178
|
|
|
155
179
|
if (isCorrect) {
|
|
@@ -180,12 +204,13 @@ describe(`RecommendedInsulin - Component`, (): void => {
|
|
|
180
204
|
<RecommendedInsulin
|
|
181
205
|
insulinRecommendation={expected}
|
|
182
206
|
updateRecommendedInsulin={updateMock}
|
|
183
|
-
injectionMethod={
|
|
207
|
+
injectionMethod={Pump}
|
|
184
208
|
activityReduction={reduction}
|
|
209
|
+
enteredInsulin={null}
|
|
185
210
|
/>,
|
|
186
211
|
);
|
|
187
212
|
|
|
188
|
-
const input = wrapper.
|
|
213
|
+
const input = wrapper.getByTestId(RecommendedInsulinTestIds.InvisibleInsulinInput);
|
|
189
214
|
const INVALID_INSULIN = SAFETY_INSULIN_LIMIT + 1;
|
|
190
215
|
|
|
191
216
|
fireEvent(input, `onEnd`, INVALID_INSULIN);
|
|
@@ -208,7 +233,8 @@ describe(`RecommendedInsulin - Component`, (): void => {
|
|
|
208
233
|
|
|
209
234
|
const updateMock = jest.fn();
|
|
210
235
|
const wrapper = render(
|
|
211
|
-
|
|
236
|
+
// @ts-ignore
|
|
237
|
+
<RecommendedInsulin updateRecommendedInsulin={updateMock} injectionMethod={Pump} />,
|
|
212
238
|
);
|
|
213
239
|
expect(!!new RegExp(`"paddingBottom":"${padding}"`).exec(JSON.stringify(wrapper.toJSON()))).toBeTruthy();
|
|
214
240
|
});
|
|
File without changes
|
|
@@ -7,6 +7,7 @@ const react_1 = __importDefault(require("react"));
|
|
|
7
7
|
const react_native_1 = require("react-native");
|
|
8
8
|
const react_native_testing_library_1 = require("react-native-testing-library");
|
|
9
9
|
const Remeasure_1 = __importDefault(require("../../components/Remeasure"));
|
|
10
|
+
const enum_1 = require("../../types/enum");
|
|
10
11
|
const utils_1 = require("../utils");
|
|
11
12
|
describe(`Remeasure Component`, () => {
|
|
12
13
|
afterEach(react_native_testing_library_1.cleanup);
|
|
@@ -21,7 +22,8 @@ describe(`Remeasure Component`, () => {
|
|
|
21
22
|
const onChange = jest.fn();
|
|
22
23
|
const wrapper = react_native_testing_library_1.render(<Remeasure_1.default remeasureTime={1.5} onSliderChange={onChange}/>);
|
|
23
24
|
utils_1.expectTextExists(wrapper, `1.5`);
|
|
24
|
-
|
|
25
|
+
const slider = wrapper.getByTestId(enum_1.RemeasureTestIds.RemeasureSlider);
|
|
26
|
+
react_native_testing_library_1.fireEvent(slider, `onValueChange`, value);
|
|
25
27
|
wrapper.rerender(<Remeasure_1.default remeasureTime={value} onSliderChange={onChange}/>);
|
|
26
28
|
utils_1.expectTextExists(wrapper, `Remind me to remeasure in`);
|
|
27
29
|
utils_1.expectTextNotExists(wrapper, `1.5`);
|
|
@@ -42,7 +44,8 @@ describe(`Remeasure Component`, () => {
|
|
|
42
44
|
const onChange = jest.fn();
|
|
43
45
|
const wrapper = react_native_testing_library_1.render(<Remeasure_1.default remeasureTime={1.5} onSliderChange={onChange}/>);
|
|
44
46
|
utils_1.expectTextExists(wrapper, `1.5`);
|
|
45
|
-
|
|
47
|
+
const slider = wrapper.getByTestId(enum_1.RemeasureTestIds.RemeasureSlider);
|
|
48
|
+
react_native_testing_library_1.fireEvent(slider, `onValueChange`, value);
|
|
46
49
|
wrapper.rerender(<Remeasure_1.default remeasureTime={value} onSliderChange={onChange}/>);
|
|
47
50
|
utils_1.expectTextNotExists(wrapper, `1.5`);
|
|
48
51
|
utils_1.expectTextExists(wrapper, expected);
|
|
@@ -60,7 +63,8 @@ describe(`Remeasure Component`, () => {
|
|
|
60
63
|
const onChange = jest.fn();
|
|
61
64
|
const wrapper = react_native_testing_library_1.render(<Remeasure_1.default remeasureTime={1.5} onSliderChange={onChange}/>);
|
|
62
65
|
utils_1.expectTextExists(wrapper, `1.5`);
|
|
63
|
-
|
|
66
|
+
const slider = wrapper.getByTestId(enum_1.RemeasureTestIds.RemeasureSlider);
|
|
67
|
+
react_native_testing_library_1.fireEvent(slider, `onValueChange`, value);
|
|
64
68
|
wrapper.rerender(<Remeasure_1.default remeasureTime={value} onSliderChange={onChange}/>);
|
|
65
69
|
utils_1.expectTextExists(wrapper, expected);
|
|
66
70
|
expect(onChange).toBeCalledWith(value);
|
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { Platform } from "react-native";
|
|
3
3
|
import { cleanup, fireEvent, render } from "react-native-testing-library";
|
|
4
4
|
import Remeasure from "../../components/Remeasure";
|
|
5
|
+
import { RemeasureTestIds } from "../../types/enum";
|
|
5
6
|
import { expectTextExists, expectTextNotExists } from "../utils";
|
|
6
7
|
|
|
7
8
|
describe(`Remeasure Component`, (): void => {
|
|
@@ -20,7 +21,9 @@ describe(`Remeasure Component`, (): void => {
|
|
|
20
21
|
const onChange = jest.fn();
|
|
21
22
|
const wrapper = render(<Remeasure remeasureTime={1.5} onSliderChange={onChange} />);
|
|
22
23
|
expectTextExists(wrapper, `1.5`);
|
|
23
|
-
|
|
24
|
+
const slider = wrapper.getByTestId(RemeasureTestIds.RemeasureSlider);
|
|
25
|
+
|
|
26
|
+
fireEvent(slider, `onValueChange`, value);
|
|
24
27
|
wrapper.rerender(<Remeasure remeasureTime={value} onSliderChange={onChange} />);
|
|
25
28
|
expectTextExists(wrapper, `Remind me to remeasure in`);
|
|
26
29
|
expectTextNotExists(wrapper, `1.5`);
|
|
@@ -45,7 +48,9 @@ describe(`Remeasure Component`, (): void => {
|
|
|
45
48
|
const onChange = jest.fn();
|
|
46
49
|
const wrapper = render(<Remeasure remeasureTime={1.5} onSliderChange={onChange} />);
|
|
47
50
|
expectTextExists(wrapper, `1.5`);
|
|
48
|
-
|
|
51
|
+
const slider = wrapper.getByTestId(RemeasureTestIds.RemeasureSlider);
|
|
52
|
+
|
|
53
|
+
fireEvent(slider, `onValueChange`, value);
|
|
49
54
|
wrapper.rerender(<Remeasure remeasureTime={value} onSliderChange={onChange} />);
|
|
50
55
|
expectTextNotExists(wrapper, `1.5`);
|
|
51
56
|
expectTextExists(wrapper, expected);
|
|
@@ -64,7 +69,10 @@ describe(`Remeasure Component`, (): void => {
|
|
|
64
69
|
const onChange = jest.fn();
|
|
65
70
|
const wrapper = render(<Remeasure remeasureTime={1.5} onSliderChange={onChange} />);
|
|
66
71
|
expectTextExists(wrapper, `1.5`);
|
|
67
|
-
|
|
72
|
+
|
|
73
|
+
const slider = wrapper.getByTestId(RemeasureTestIds.RemeasureSlider);
|
|
74
|
+
|
|
75
|
+
fireEvent(slider, `onValueChange`, value);
|
|
68
76
|
wrapper.rerender(<Remeasure remeasureTime={value} onSliderChange={onChange} />);
|
|
69
77
|
|
|
70
78
|
expectTextExists(wrapper, expected);
|
|
File without changes
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const react_1 = __importDefault(require("react"));
|
|
7
7
|
const react_native_testing_library_1 = require("react-native-testing-library");
|
|
8
8
|
const TransferToLogbook_1 = __importDefault(require("../../components/TransferToLogbook"));
|
|
9
|
+
const enum_1 = require("../../types/enum");
|
|
9
10
|
const utils_1 = require("../utils");
|
|
10
11
|
describe(`TransferToLogbook - Component`, () => {
|
|
11
12
|
test(`Is null when visible not visible`, () => {
|
|
@@ -24,8 +25,7 @@ describe(`TransferToLogbook - Component`, () => {
|
|
|
24
25
|
const transferMock = jest.fn();
|
|
25
26
|
const wrapper = react_native_testing_library_1.render(<TransferToLogbook_1.default visible={true} transfer={transferMock}/>);
|
|
26
27
|
utils_1.expectTextExists(wrapper, `Transfer to logbook`);
|
|
27
|
-
const button = wrapper.
|
|
28
|
-
expect(button).not.toBeNull();
|
|
28
|
+
const button = wrapper.getByTestId(enum_1.TransferToLogbookTestIds.TransferButton);
|
|
29
29
|
expect(transferMock).not.toBeCalled();
|
|
30
30
|
react_native_testing_library_1.fireEvent(button, `onPress`);
|
|
31
31
|
utils_1.expectTextNotExists(wrapper, `Transfer to logbook`);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { fireEvent, render } from "react-native-testing-library";
|
|
3
3
|
import TransferToLogbook from "../../components/TransferToLogbook";
|
|
4
|
+
import { TransferToLogbookTestIds } from "../../types/enum";
|
|
4
5
|
import { expectTextExists, expectTextNotExists } from "../utils";
|
|
5
6
|
|
|
6
7
|
describe(`TransferToLogbook - Component`, (): void => {
|
|
@@ -23,8 +24,7 @@ describe(`TransferToLogbook - Component`, (): void => {
|
|
|
23
24
|
const wrapper = render(<TransferToLogbook visible={true} transfer={transferMock} />);
|
|
24
25
|
expectTextExists(wrapper, `Transfer to logbook`);
|
|
25
26
|
|
|
26
|
-
const button = wrapper.
|
|
27
|
-
expect(button).not.toBeNull();
|
|
27
|
+
const button = wrapper.getByTestId(TransferToLogbookTestIds.TransferButton);
|
|
28
28
|
|
|
29
29
|
expect(transferMock).not.toBeCalled();
|
|
30
30
|
|
|
File without changes
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const react_1 = __importDefault(require("react"));
|
|
7
7
|
const react_native_testing_library_1 = require("react-native-testing-library");
|
|
8
8
|
const TwoOptionModal_1 = __importDefault(require("../../components/TwoOptionModal"));
|
|
9
|
+
const enum_1 = require("../../types/enum");
|
|
9
10
|
const utils_1 = require("../utils");
|
|
10
11
|
describe(`TwoOptionModal Component`, () => {
|
|
11
12
|
afterEach(react_native_testing_library_1.cleanup);
|
|
@@ -40,13 +41,13 @@ describe(`TwoOptionModal Component`, () => {
|
|
|
40
41
|
};
|
|
41
42
|
const wrapper = react_native_testing_library_1.render(<TwoOptionModal_1.default {...props}/>);
|
|
42
43
|
utils_1.expectTextExists(wrapper, `Luk beregning`);
|
|
43
|
-
const modalExitIcon = wrapper.
|
|
44
|
+
const modalExitIcon = wrapper.getByTestId(enum_1.TwoOptionModalTestIds.ExitButton);
|
|
44
45
|
react_native_testing_library_1.fireEvent(modalExitIcon, `onPress`);
|
|
45
46
|
expect(props.onClose).toBeCalled();
|
|
46
|
-
const closeCalculation = wrapper.
|
|
47
|
+
const closeCalculation = wrapper.getByTestId(enum_1.TwoOptionModalTestIds.SecondOption);
|
|
47
48
|
react_native_testing_library_1.fireEvent(closeCalculation, `onPress`);
|
|
48
49
|
expect(props.secondOption).toBeCalled();
|
|
49
|
-
const firstOptionButton = wrapper.
|
|
50
|
+
const firstOptionButton = wrapper.getByTestId(enum_1.TwoOptionModalTestIds.FirstOption);
|
|
50
51
|
react_native_testing_library_1.fireEvent(firstOptionButton, `onPress`);
|
|
51
52
|
expect(props.firstOption).toBeCalled();
|
|
52
53
|
});
|
|
@@ -62,7 +63,7 @@ describe(`TwoOptionModal Component`, () => {
|
|
|
62
63
|
};
|
|
63
64
|
const wrapper = react_native_testing_library_1.render(<TwoOptionModal_1.default {...props}/>);
|
|
64
65
|
utils_1.expectTextExists(wrapper, `Luk beregning`);
|
|
65
|
-
const modalExitIcon = wrapper.
|
|
66
|
+
const modalExitIcon = wrapper.queryByTestId(enum_1.TwoOptionModalTestIds.ExitButton);
|
|
66
67
|
expect(modalExitIcon).toBeNull();
|
|
67
68
|
});
|
|
68
69
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { cleanup, fireEvent, render } from "react-native-testing-library";
|
|
3
3
|
import TwoOptionModal, { ITwoOptionModalProps } from "../../components/TwoOptionModal";
|
|
4
|
+
import { TwoOptionModalTestIds } from "../../types/enum";
|
|
4
5
|
import { expectTextExists } from "../utils";
|
|
5
6
|
|
|
6
7
|
describe(`TwoOptionModal Component`, (): void => {
|
|
@@ -39,18 +40,19 @@ describe(`TwoOptionModal Component`, (): void => {
|
|
|
39
40
|
const wrapper = render(<TwoOptionModal {...props} />);
|
|
40
41
|
expectTextExists(wrapper, `Luk beregning`);
|
|
41
42
|
|
|
42
|
-
const modalExitIcon = wrapper.
|
|
43
|
+
const modalExitIcon = wrapper.getByTestId(TwoOptionModalTestIds.ExitButton);
|
|
43
44
|
fireEvent(modalExitIcon, `onPress`);
|
|
44
45
|
expect(props.onClose).toBeCalled();
|
|
45
46
|
|
|
46
|
-
const closeCalculation = wrapper.
|
|
47
|
+
const closeCalculation = wrapper.getByTestId(TwoOptionModalTestIds.SecondOption);
|
|
47
48
|
fireEvent(closeCalculation, `onPress`);
|
|
48
49
|
expect(props.secondOption).toBeCalled();
|
|
49
50
|
|
|
50
|
-
const firstOptionButton = wrapper.
|
|
51
|
+
const firstOptionButton = wrapper.getByTestId(TwoOptionModalTestIds.FirstOption);
|
|
51
52
|
fireEvent(firstOptionButton, `onPress`);
|
|
52
53
|
expect(props.firstOption).toBeCalled();
|
|
53
54
|
});
|
|
55
|
+
|
|
54
56
|
test(`Test it is not cancelable`, (): void => {
|
|
55
57
|
const props: ITwoOptionModalProps = {
|
|
56
58
|
firstOption: jest.fn(),
|
|
@@ -64,7 +66,7 @@ describe(`TwoOptionModal Component`, (): void => {
|
|
|
64
66
|
const wrapper = render(<TwoOptionModal {...props} />);
|
|
65
67
|
expectTextExists(wrapper, `Luk beregning`);
|
|
66
68
|
|
|
67
|
-
const modalExitIcon = wrapper.
|
|
69
|
+
const modalExitIcon = wrapper.queryByTestId(TwoOptionModalTestIds.ExitButton);
|
|
68
70
|
expect(modalExitIcon).toBeNull();
|
|
69
71
|
});
|
|
70
72
|
});
|
package/src/__tests__/utils.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { IRecommendationParams } from "@hedia/recommendation-calculator";
|
|
3
|
-
import { IActivityParams } from "@hedia/recommendation-calculator/src/RecommendationCalculator";
|
|
4
2
|
import { RenderAPI } from "react-native-testing-library";
|
|
3
|
+
import { ReactTestInstance } from "react-test-renderer";
|
|
5
4
|
import { IRecommendationProps } from "../RecommendationScreen";
|
|
5
|
+
import { TestIdEnum } from "../types/enum";
|
|
6
|
+
import { IActivityParams, IRecommendationParams, logbookEntry } from "../types/types";
|
|
6
7
|
export declare function getRecommendationProps(partials?: Partial<IRecommendationProps>): IRecommendationProps;
|
|
7
8
|
export declare function generateDefaultCalculatorParams(): IRecommendationParams;
|
|
8
9
|
export declare function generateActivityProps(): IActivityParams;
|
|
10
|
+
export declare function generateDefaultActivitySettings(): IActivityParams["activitySettings"];
|
|
11
|
+
export declare function generateDefaultLogbook(): logbookEntry;
|
|
9
12
|
export declare function expectTextExists(component: RenderAPI, text: string | RegExp): void;
|
|
13
|
+
export declare function queryTextFromComponent(wrapper: RenderAPI, testID: TestIdEnum): string;
|
|
10
14
|
export declare function expectTextNotExists(component: RenderAPI, text: string | RegExp): void;
|
|
11
15
|
export declare function i18nProvided(element: JSX.Element): JSX.Element;
|
|
16
|
+
export declare function getIcon(wrapper: RenderAPI, name: string, active: boolean): ReactTestInstance | null;
|
package/src/__tests__/utils.jsx
CHANGED
|
@@ -3,23 +3,27 @@ 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
|
-
exports.i18nProvided = exports.expectTextNotExists = exports.expectTextExists = exports.generateActivityProps = exports.generateDefaultCalculatorParams = exports.getRecommendationProps = void 0;
|
|
7
|
-
const RecommendationCalculator_1 = require("@hedia/recommendation-calculator/src/RecommendationCalculator");
|
|
6
|
+
exports.getIcon = exports.i18nProvided = exports.expectTextNotExists = exports.queryTextFromComponent = exports.expectTextExists = exports.generateDefaultLogbook = exports.generateDefaultActivitySettings = exports.generateActivityProps = exports.generateDefaultCalculatorParams = exports.getRecommendationProps = void 0;
|
|
8
7
|
const types_1 = require("@hedia/types");
|
|
9
8
|
const react_1 = require("@lingui/react");
|
|
10
9
|
const react_2 = __importDefault(require("react"));
|
|
11
10
|
const i18nUtils_1 = require("../locale/i18nUtils");
|
|
12
|
-
const
|
|
11
|
+
const ActivityEnum = types_1.Activity.Enums.ActivityEnum;
|
|
12
|
+
const ActivityIntensity = types_1.Activity.Enums.ActivityIntensity;
|
|
13
|
+
const InjectionMethod = types_1.UserSettings.Enums.InjectionMethod;
|
|
14
|
+
const { Run } = ActivityEnum;
|
|
15
|
+
const { moderate } = ActivityIntensity;
|
|
16
|
+
const { PenHalf } = InjectionMethod;
|
|
13
17
|
function getRecommendationProps(partials) {
|
|
14
18
|
return {
|
|
15
19
|
currentBKL: partials?.currentBKL ?? 0.1,
|
|
16
20
|
bloodKetoneUnit: partials?.bloodKetoneUnit ?? types_1.BloodKetonesUnit.MMOL_L,
|
|
17
21
|
bloodGlucoseUnit: partials?.bloodGlucoseUnit ?? types_1.BloodGlucoseUnit.MMOL_L,
|
|
18
|
-
language: partials?.language ??
|
|
22
|
+
language: partials?.language ?? types_1.Languages.en,
|
|
19
23
|
userReminder: partials?.userReminder ?? 1.5,
|
|
20
|
-
latestLogbookFrom6Hours: partials?.latestLogbookFrom6Hours,
|
|
24
|
+
latestLogbookFrom6Hours: partials?.latestLogbookFrom6Hours ?? generateDefaultLogbook(),
|
|
21
25
|
calculatorParams: partials?.calculatorParams ?? generateDefaultCalculatorParams(),
|
|
22
|
-
injectionMethod: partials?.injectionMethod ??
|
|
26
|
+
injectionMethod: partials?.injectionMethod ?? PenHalf,
|
|
23
27
|
transferToLogbook: partials?.transferToLogbook ?? jest.fn(),
|
|
24
28
|
onError: partials?.onError ?? jest.fn(),
|
|
25
29
|
onRecentInsulinYes: partials?.onRecentInsulinYes ?? jest.fn(),
|
|
@@ -30,7 +34,7 @@ function getRecommendationProps(partials) {
|
|
|
30
34
|
restartCalculation: partials?.restartCalculation ?? jest.fn(),
|
|
31
35
|
activityDisplayProps: partials?.activityDisplayProps ?? {
|
|
32
36
|
activityTitle: `Activity Title Test`,
|
|
33
|
-
activityType:
|
|
37
|
+
activityType: Run,
|
|
34
38
|
},
|
|
35
39
|
};
|
|
36
40
|
}
|
|
@@ -52,6 +56,7 @@ function generateDefaultCalculatorParams() {
|
|
|
52
56
|
secondsPassed: 10000,
|
|
53
57
|
},
|
|
54
58
|
],
|
|
59
|
+
activity: null,
|
|
55
60
|
};
|
|
56
61
|
}
|
|
57
62
|
exports.generateDefaultCalculatorParams = generateDefaultCalculatorParams;
|
|
@@ -59,17 +64,46 @@ function generateActivityProps() {
|
|
|
59
64
|
return {
|
|
60
65
|
activityDate: new Date(),
|
|
61
66
|
activityDuration: 30,
|
|
62
|
-
activityIntensity:
|
|
63
|
-
activitySettings:
|
|
64
|
-
hard: { fromFortysix: null, fromThirty: 0.25, fromZero: 1 },
|
|
65
|
-
light: { fromFortysix: 0.5, fromThirty: 0.75, fromZero: 1 },
|
|
66
|
-
moderate: { fromFortysix: 0.25, fromThirty: 0.5, fromZero: 1 },
|
|
67
|
-
post: { fromFortysix: 0.5, fromThirty: 0.5, fromZero: 1 },
|
|
68
|
-
target: 9,
|
|
69
|
-
},
|
|
67
|
+
activityIntensity: moderate,
|
|
68
|
+
activitySettings: generateDefaultActivitySettings(),
|
|
70
69
|
};
|
|
71
70
|
}
|
|
72
71
|
exports.generateActivityProps = generateActivityProps;
|
|
72
|
+
function generateDefaultActivitySettings() {
|
|
73
|
+
return {
|
|
74
|
+
hard: { fromFortysix: null, fromThirty: 0.25, fromZero: 1 },
|
|
75
|
+
light: { fromFortysix: 0.5, fromThirty: 0.75, fromZero: 1 },
|
|
76
|
+
moderate: { fromFortysix: 0.25, fromThirty: 0.5, fromZero: 1 },
|
|
77
|
+
post: { fromFortysix: 0.5, fromThirty: 0.5, fromZero: 1 },
|
|
78
|
+
target: 9,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
exports.generateDefaultActivitySettings = generateDefaultActivitySettings;
|
|
82
|
+
function generateDefaultLogbook() {
|
|
83
|
+
return {
|
|
84
|
+
blood_glucose_millimolar: 6,
|
|
85
|
+
carbohydrates_entered_grams: 25,
|
|
86
|
+
carbohydrates_suggested_grams: 25,
|
|
87
|
+
client_timestamp: `25`,
|
|
88
|
+
client_version: `25`,
|
|
89
|
+
entry_timestamp: `25`,
|
|
90
|
+
event_uuid: null,
|
|
91
|
+
insulin_entered_units: 25,
|
|
92
|
+
insulin_suggested_units: 25,
|
|
93
|
+
is_deleted: null,
|
|
94
|
+
mood: 2,
|
|
95
|
+
settings_uuid: `25`,
|
|
96
|
+
uuid: `aaa`,
|
|
97
|
+
device_and_os: `ios 12.1.2`,
|
|
98
|
+
overwritten_by_id: null,
|
|
99
|
+
server_timestamp: null,
|
|
100
|
+
server_version: null,
|
|
101
|
+
utc_timezone_offset: null,
|
|
102
|
+
blood_ketones_millimolar: null,
|
|
103
|
+
carbohydrates_modified_suggested_grams: null,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
exports.generateDefaultLogbook = generateDefaultLogbook;
|
|
73
107
|
function expectTextExists(component, text) {
|
|
74
108
|
const element = component.queryByText(text);
|
|
75
109
|
/*
|
|
@@ -80,6 +114,12 @@ function expectTextExists(component, text) {
|
|
|
80
114
|
return expect(element).not.toBeNull();
|
|
81
115
|
}
|
|
82
116
|
exports.expectTextExists = expectTextExists;
|
|
117
|
+
function queryTextFromComponent(wrapper, testID) {
|
|
118
|
+
const component = wrapper.getByTestId(testID);
|
|
119
|
+
const values = component.children;
|
|
120
|
+
return values.join(``);
|
|
121
|
+
}
|
|
122
|
+
exports.queryTextFromComponent = queryTextFromComponent;
|
|
83
123
|
function expectTextNotExists(component, text) {
|
|
84
124
|
const element = component.queryByText(text);
|
|
85
125
|
/*
|
|
@@ -96,3 +136,7 @@ function i18nProvided(element) {
|
|
|
96
136
|
</react_1.I18nProvider>);
|
|
97
137
|
}
|
|
98
138
|
exports.i18nProvided = i18nProvided;
|
|
139
|
+
function getIcon(wrapper, name, active) {
|
|
140
|
+
return wrapper.queryByA11yLabel(`${name}_${active}`);
|
|
141
|
+
}
|
|
142
|
+
exports.getIcon = getIcon;
|