@hedia/recommendation-screen 2.1.3-beta.6 → 2.1.3-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/coverage/clover.xml +2 -2
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov-report/src/RecommendationScreen.tsx.html +1 -1
- package/coverage/lcov-report/src/__tests__/index.html +1 -1
- package/coverage/lcov-report/src/__tests__/utils.tsx.html +1 -1
- package/coverage/lcov-report/src/components/Header.tsx.html +1 -1
- package/coverage/lcov-report/src/components/InfoBars.tsx.html +1 -1
- package/coverage/lcov-report/src/components/InvisibleNumberInput.tsx.html +1 -1
- package/coverage/lcov-report/src/components/LimitationMessage.tsx.html +1 -1
- package/coverage/lcov-report/src/components/LineSeparator.tsx.html +1 -1
- package/coverage/lcov-report/src/components/RecentInsulin.tsx.html +1 -1
- package/coverage/lcov-report/src/components/RecommendationModal.tsx.html +1 -1
- package/coverage/lcov-report/src/components/RecommendedCarbs.tsx.html +1 -1
- package/coverage/lcov-report/src/components/RecommendedInsulin.tsx.html +1 -1
- package/coverage/lcov-report/src/components/Remeasure.tsx.html +1 -1
- package/coverage/lcov-report/src/components/TransferToLogbook.tsx.html +1 -1
- package/coverage/lcov-report/src/components/TwoOptionModal.tsx.html +1 -1
- package/coverage/lcov-report/src/components/activity/Activity.tsx.html +1 -1
- package/coverage/lcov-report/src/components/activity/ActivityIcon.tsx.html +1 -1
- package/coverage/lcov-report/src/components/activity/ActivityIntensity.tsx.html +1 -1
- package/coverage/lcov-report/src/components/activity/index.html +1 -1
- package/coverage/lcov-report/src/components/index.html +1 -1
- package/coverage/lcov-report/src/components/mood/Emotion.tsx.html +1 -1
- package/coverage/lcov-report/src/components/mood/MoodIcon.tsx.html +1 -1
- package/coverage/lcov-report/src/components/mood/index.html +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/locale/i18nUtils.ts.html +1 -1
- package/coverage/lcov-report/src/locale/index.html +1 -1
- package/coverage/lcov-report/src/utils/AttentionMessages.tsx.html +1 -1
- package/coverage/lcov-report/src/utils/Constants.ts.html +1 -1
- package/coverage/lcov-report/src/utils/RecommendationError.tsx.html +1 -1
- package/coverage/lcov-report/src/utils/RecommendationUtils.ts.html +1 -1
- package/coverage/lcov-report/src/utils/Translations.ts.html +1 -1
- package/coverage/lcov-report/src/utils/Utils.ts.html +1 -1
- package/coverage/lcov-report/src/utils/Validations.ts.html +1 -1
- package/coverage/lcov-report/src/utils/index.html +1 -1
- package/index.js +5 -31
- package/package.json +2 -1
- package/src/RecommendationScreen.js +76 -101
- package/src/__tests__/RecommendationScreen.test.js +404 -409
- package/src/__tests__/RecommendationUtils.test.js +117 -119
- package/src/__tests__/Translate.test.js +14 -16
- package/src/__tests__/Utils.test.js +16 -18
- package/src/__tests__/Validations.test.js +30 -51
- package/src/__tests__/components/Activity.test.js +51 -56
- package/src/__tests__/components/Emotion.test.js +28 -33
- package/src/__tests__/components/Header.test.js +24 -29
- package/src/__tests__/components/InfoBars.test.js +59 -64
- package/src/__tests__/components/InvisibleNumberInput.test.js +22 -27
- package/src/__tests__/components/LimitationMessage.test.js +28 -33
- package/src/__tests__/components/MoodIcon.test.js +9 -14
- package/src/__tests__/components/RecommendationModal.test.js +56 -61
- package/src/__tests__/components/RecommendedCarbs.test.js +58 -63
- package/src/__tests__/components/RecommendedInsulin.test.js +60 -65
- package/src/__tests__/components/Remeasure.test.js +32 -37
- package/src/__tests__/components/TransferToLogbook.test.js +15 -20
- package/src/__tests__/components/TwoOptionModal.test.js +22 -27
- package/src/__tests__/utils.js +22 -38
- package/src/components/Header.js +34 -41
- package/src/components/Icon.js +2 -8
- package/src/components/InfoBars.js +36 -43
- package/src/components/InvisibleNumberInput.js +5 -11
- package/src/components/LimitationMessage.js +18 -40
- package/src/components/LineSeparator.js +7 -13
- package/src/components/RecentInsulin.js +33 -39
- package/src/components/RecommendationModal.js +59 -85
- package/src/components/RecommendedCarbs.js +93 -99
- package/src/components/RecommendedInsulin.js +46 -52
- package/src/components/Remeasure.js +36 -42
- package/src/components/TransferToLogbook.js +20 -26
- package/src/components/TwoOptionModal.js +39 -65
- package/src/components/activity/Activity.js +42 -48
- package/src/components/activity/ActivityIcon.js +15 -21
- package/src/components/activity/ActivityIntensity.js +19 -25
- package/src/components/mood/Emotion.js +17 -23
- package/src/components/mood/MoodIcon.js +11 -17
- package/src/locale/i18nUtils.js +17 -24
- package/src/types/enum.js +28 -31
- package/src/types/types.js +1 -2
- package/src/utils/AttentionMessages.js +24 -32
- package/src/utils/Constants.js +23 -26
- package/src/utils/RecommendationError.js +28 -54
- package/src/utils/RecommendationUtils.js +60 -72
- package/src/utils/Translations.js +6 -9
- package/src/utils/Utils.js +8 -12
- package/src/utils/Validations.js +77 -107
- package/tsconfig.json +3 -3
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const i18nUtils_1 = require("../../locale/i18nUtils");
|
|
12
|
-
const enum_1 = require("../../types/enum");
|
|
13
|
-
const Translations_1 = require("../../utils/Translations");
|
|
14
|
-
const utils_1 = require("../utils");
|
|
15
|
-
const ActivityIntensity = types_1.Activity.Enums.ActivityIntensity;
|
|
1
|
+
import { Activity, Languages } from "@hedia/types";
|
|
2
|
+
import { I18nProvider } from "@lingui/react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { cleanup, render } from "react-native-testing-library";
|
|
5
|
+
import { default as ActivityComponent } from "../../components/activity/Activity";
|
|
6
|
+
import { i18n } from "../../locale/i18nUtils";
|
|
7
|
+
import { ActivityTestIds } from "../../types/enum";
|
|
8
|
+
import { ActivityIntensityTranslations } from "../../utils/Translations";
|
|
9
|
+
import { expectTextExists, generateActivityProps, getRecommendationProps, i18nProvided, queryTextFromComponent, } from "../utils";
|
|
10
|
+
const ActivityIntensity = Activity.Enums.ActivityIntensity;
|
|
16
11
|
const { light, moderate, hard } = ActivityIntensity;
|
|
17
12
|
describe(`Activity - Component`, () => {
|
|
18
|
-
afterEach(
|
|
13
|
+
afterEach(cleanup);
|
|
19
14
|
beforeEach(() => {
|
|
20
|
-
|
|
15
|
+
i18n.activate(Languages.en);
|
|
21
16
|
});
|
|
22
17
|
test.each `
|
|
23
18
|
activityIntensity
|
|
@@ -25,14 +20,14 @@ describe(`Activity - Component`, () => {
|
|
|
25
20
|
${moderate}
|
|
26
21
|
${hard}
|
|
27
22
|
`(`Renders $activityIntensity`, ({ activityIntensity }) => {
|
|
28
|
-
const { activityDisplayProps } =
|
|
29
|
-
const activity =
|
|
30
|
-
const wrapper =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
const { activityDisplayProps } = getRecommendationProps();
|
|
24
|
+
const activity = generateActivityProps();
|
|
25
|
+
const wrapper = render(i18nProvided(<ActivityComponent activity={{ ...activity, activityIntensity }} activityType={activityDisplayProps?.activityType ?? null} activityTitle={activityDisplayProps?.activityTitle ?? null} activityReduction={0}/>));
|
|
26
|
+
expectTextExists(wrapper, `Activity`);
|
|
27
|
+
expectTextExists(wrapper, `30`);
|
|
28
|
+
expectTextExists(wrapper, `min`);
|
|
29
|
+
expectTextExists(wrapper, `Based on the selected activity your insulin recommendation is reduced by:`);
|
|
30
|
+
expectTextExists(wrapper, ActivityIntensityTranslations[activityIntensity]());
|
|
36
31
|
});
|
|
37
32
|
test.each `
|
|
38
33
|
reduction
|
|
@@ -42,49 +37,49 @@ describe(`Activity - Component`, () => {
|
|
|
42
37
|
${0.5}
|
|
43
38
|
${0.8}
|
|
44
39
|
`(`Renders activity reduction from decimal: $reduction to percentage`, ({ reduction }) => {
|
|
45
|
-
const { activityDisplayProps } =
|
|
46
|
-
const activity =
|
|
47
|
-
const wrapper =
|
|
48
|
-
|
|
40
|
+
const { activityDisplayProps } = getRecommendationProps();
|
|
41
|
+
const activity = generateActivityProps();
|
|
42
|
+
const wrapper = render(i18nProvided(<ActivityComponent activity={activity} activityType={activityDisplayProps?.activityType ?? null} activityReduction={reduction} activityTitle={activityDisplayProps?.activityTitle ?? null}/>));
|
|
43
|
+
expectTextExists(wrapper, `${reduction * 100}%`);
|
|
49
44
|
});
|
|
50
45
|
test(`Renders activity reduction as 0 when null is passed`, () => {
|
|
51
|
-
const { activityDisplayProps } =
|
|
52
|
-
const activity =
|
|
46
|
+
const { activityDisplayProps } = getRecommendationProps();
|
|
47
|
+
const activity = generateActivityProps();
|
|
53
48
|
const reduction = null;
|
|
54
|
-
const wrapper =
|
|
55
|
-
const text =
|
|
49
|
+
const wrapper = render(i18nProvided(<ActivityComponent activity={activity} activityType={activityDisplayProps?.activityType ?? null} activityReduction={reduction} activityTitle={activityDisplayProps?.activityTitle ?? null}/>));
|
|
50
|
+
const text = queryTextFromComponent(wrapper, ActivityTestIds.ActivityReduction);
|
|
56
51
|
expect(text).toBe(`0%`);
|
|
57
52
|
});
|
|
58
53
|
test(`Can render activity title`, () => {
|
|
59
|
-
const { activityDisplayProps } =
|
|
60
|
-
const activity =
|
|
61
|
-
const wrapper =
|
|
62
|
-
|
|
54
|
+
const { activityDisplayProps } = getRecommendationProps();
|
|
55
|
+
const activity = generateActivityProps();
|
|
56
|
+
const wrapper = render(i18nProvided(<ActivityComponent activity={{ ...activity }} activityType={activityDisplayProps?.activityType ?? null} activityTitle={activityDisplayProps?.activityTitle ?? null} activityReduction={0}/>));
|
|
57
|
+
expectTextExists(wrapper, activityDisplayProps?.activityTitle);
|
|
63
58
|
});
|
|
64
59
|
test.each `
|
|
65
60
|
language | locale | message
|
|
66
|
-
${`English`} | ${
|
|
67
|
-
${`Danish`} | ${
|
|
68
|
-
${`German`} | ${
|
|
69
|
-
${`Spanish`} | ${
|
|
70
|
-
${`Italian`} | ${
|
|
71
|
-
${`French`} | ${
|
|
61
|
+
${`English`} | ${Languages.en} | ${`Activity`}
|
|
62
|
+
${`Danish`} | ${Languages.da} | ${`Aktivitet`}
|
|
63
|
+
${`German`} | ${Languages.de} | ${`Aktivität`}
|
|
64
|
+
${`Spanish`} | ${Languages.es} | ${`Actividad`}
|
|
65
|
+
${`Italian`} | ${Languages.it} | ${`Attività fisica`}
|
|
66
|
+
${`French`} | ${Languages.fr} | ${`Activité`}
|
|
72
67
|
`(`Can render in $language`, ({ message, locale }) => {
|
|
73
|
-
const { activityDisplayProps } =
|
|
74
|
-
const activity =
|
|
75
|
-
|
|
76
|
-
const wrapper =
|
|
77
|
-
<
|
|
78
|
-
</
|
|
79
|
-
|
|
68
|
+
const { activityDisplayProps } = getRecommendationProps();
|
|
69
|
+
const activity = generateActivityProps();
|
|
70
|
+
i18n.activate(locale);
|
|
71
|
+
const wrapper = render(<I18nProvider language={locale} i18n={i18n}>
|
|
72
|
+
<ActivityComponent activity={activity} activityType={activityDisplayProps?.activityType ?? null} activityTitle={activityDisplayProps?.activityTitle ?? null} activityReduction={0}/>
|
|
73
|
+
</I18nProvider>);
|
|
74
|
+
expectTextExists(wrapper, message);
|
|
80
75
|
});
|
|
81
76
|
test(`ActivityIcon defaults to other if activityType is null`, () => {
|
|
82
|
-
const { activityDisplayProps } =
|
|
83
|
-
const activity =
|
|
84
|
-
const wrapper =
|
|
85
|
-
|
|
86
|
-
const existingLabel = `${
|
|
87
|
-
const nonExistingLabel = `${
|
|
77
|
+
const { activityDisplayProps } = getRecommendationProps();
|
|
78
|
+
const activity = generateActivityProps();
|
|
79
|
+
const wrapper = render(i18nProvided(<ActivityComponent activity={{ ...activity }} activityType={null} activityTitle={activityDisplayProps?.activityTitle ?? null} activityReduction={0}/>));
|
|
80
|
+
expectTextExists(wrapper, activityDisplayProps?.activityTitle);
|
|
81
|
+
const existingLabel = `${Activity.Enums.ActivityEnum[Activity.Enums.ActivityEnum.Other]}_activity`;
|
|
82
|
+
const nonExistingLabel = `${Activity.Enums.ActivityEnum[Activity.Enums.ActivityEnum.Run]}_activity`;
|
|
88
83
|
expect(wrapper.queryByA11yLabel(existingLabel)).not.toBeNull();
|
|
89
84
|
expect(wrapper.queryByA11yLabel(nonExistingLabel)).toBeNull();
|
|
90
85
|
});
|
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const react_native_testing_library_1 = require("react-native-testing-library");
|
|
9
|
-
const Emotion_1 = __importDefault(require("../../components/mood/Emotion"));
|
|
10
|
-
const i18nUtils_1 = require("../../locale/i18nUtils");
|
|
11
|
-
const utils_1 = require("../utils");
|
|
12
|
-
const MoodEnum = types_1.Logbook.Enums.MoodEnum;
|
|
1
|
+
import { Languages, Logbook } from "@hedia/types";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { cleanup, fireEvent, render } from "react-native-testing-library";
|
|
4
|
+
import Emotion from "../../components/mood/Emotion";
|
|
5
|
+
import { i18n } from "../../locale/i18nUtils";
|
|
6
|
+
import { expectTextExists, getIcon, i18nProvided } from "../utils";
|
|
7
|
+
const MoodEnum = Logbook.Enums.MoodEnum;
|
|
13
8
|
describe(`Emotion - Component`, () => {
|
|
14
|
-
afterEach(
|
|
9
|
+
afterEach(cleanup);
|
|
15
10
|
beforeEach(() => {
|
|
16
|
-
|
|
11
|
+
i18n.activate(Languages.en);
|
|
17
12
|
});
|
|
18
13
|
test(`Can mount component in `, () => {
|
|
19
14
|
const mockSelected = jest.fn();
|
|
20
|
-
const wrapper =
|
|
21
|
-
|
|
15
|
+
const wrapper = render(i18nProvided(<Emotion moodSelected={mockSelected} currentMood={null}/>));
|
|
16
|
+
expectTextExists(wrapper, `How are you feeling?`);
|
|
22
17
|
});
|
|
23
18
|
test.each `
|
|
24
19
|
mood | moodName | preselected | preselectedName
|
|
@@ -30,28 +25,28 @@ describe(`Emotion - Component`, () => {
|
|
|
30
25
|
`(`Pressing on $moodName icon deselects others`, ({ mood, moodName, preselected, preselectedName, }) => {
|
|
31
26
|
let mockedStateMood = preselected;
|
|
32
27
|
const mockSelected = jest.fn((selectedMood) => (mockedStateMood = selectedMood));
|
|
33
|
-
const wrapper =
|
|
34
|
-
const preIcon =
|
|
28
|
+
const wrapper = render(<Emotion moodSelected={mockSelected} currentMood={mockedStateMood}/>);
|
|
29
|
+
const preIcon = getIcon(wrapper, preselectedName, true);
|
|
35
30
|
if (preIcon === null) {
|
|
36
31
|
return fail(`No icon found for queryByA11yLabel: ${preselectedName}_${true}`);
|
|
37
32
|
}
|
|
38
|
-
const newIcon =
|
|
33
|
+
const newIcon = getIcon(wrapper, moodName, false);
|
|
39
34
|
if (newIcon === null) {
|
|
40
35
|
return fail(`No icon found for queryByA11yLabel: ${moodName}_${false}`);
|
|
41
36
|
}
|
|
42
37
|
// Select a different mood
|
|
43
|
-
|
|
38
|
+
fireEvent(newIcon, `onPress`);
|
|
44
39
|
expect(mockedStateMood).toBe(mood);
|
|
45
|
-
wrapper.update(<
|
|
40
|
+
wrapper.update(<Emotion moodSelected={mockSelected} currentMood={mockedStateMood}/>);
|
|
46
41
|
const moodValues = Object.values(MoodEnum).filter((value) => typeof value === `string`);
|
|
47
42
|
moodValues.forEach((value) => {
|
|
48
43
|
if (moodName === value) {
|
|
49
|
-
expect(
|
|
50
|
-
expect(
|
|
44
|
+
expect(getIcon(wrapper, value, true)).not.toBeNull();
|
|
45
|
+
expect(getIcon(wrapper, value, false)).toBeNull();
|
|
51
46
|
}
|
|
52
47
|
else {
|
|
53
|
-
expect(
|
|
54
|
-
expect(
|
|
48
|
+
expect(getIcon(wrapper, value, false)).not.toBeNull();
|
|
49
|
+
expect(getIcon(wrapper, value, true)).toBeNull();
|
|
55
50
|
}
|
|
56
51
|
});
|
|
57
52
|
});
|
|
@@ -59,17 +54,17 @@ describe(`Emotion - Component`, () => {
|
|
|
59
54
|
let mockedStateMood = MoodEnum.Happy;
|
|
60
55
|
const mockSelected = jest.fn((newMood) => (mockedStateMood = newMood));
|
|
61
56
|
const mood = MoodEnum[mockedStateMood];
|
|
62
|
-
const wrapper =
|
|
57
|
+
const wrapper = render(<Emotion moodSelected={mockSelected} currentMood={mockedStateMood}/>);
|
|
63
58
|
// current mood has already been selected: Happy
|
|
64
|
-
expect(
|
|
65
|
-
expect(
|
|
66
|
-
const icon =
|
|
59
|
+
expect(getIcon(wrapper, mood, true)).not.toBeNull();
|
|
60
|
+
expect(getIcon(wrapper, mood, false)).toBeNull();
|
|
61
|
+
const icon = getIcon(wrapper, mood, true);
|
|
67
62
|
if (icon === null) {
|
|
68
63
|
return fail(`No icon found for queryByA11yLabel: ${mood}_${true}`);
|
|
69
64
|
}
|
|
70
|
-
|
|
71
|
-
wrapper.update(<
|
|
72
|
-
expect(
|
|
73
|
-
expect(
|
|
65
|
+
fireEvent(icon, `onPress`);
|
|
66
|
+
wrapper.update(<Emotion moodSelected={mockSelected} currentMood={mockedStateMood}/>);
|
|
67
|
+
expect(getIcon(wrapper, mood, true)).toBeNull();
|
|
68
|
+
expect(getIcon(wrapper, mood, false)).not.toBeNull();
|
|
74
69
|
});
|
|
75
70
|
});
|
|
@@ -1,41 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const react_2 = require("@lingui/react");
|
|
10
|
-
const Header_1 = __importDefault(require("../../components/Header"));
|
|
11
|
-
const types_1 = require("@hedia/types");
|
|
12
|
-
const i18nUtils_1 = require("../../locale/i18nUtils");
|
|
13
|
-
const enum_1 = require("../../types/enum");
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { cleanup, fireEvent, render } from "react-native-testing-library";
|
|
3
|
+
import { expectTextExists, getRecommendationProps } from "../utils";
|
|
4
|
+
import { I18nProvider } from "@lingui/react";
|
|
5
|
+
import Header from "../../components/Header";
|
|
6
|
+
import { Languages } from "@hedia/types";
|
|
7
|
+
import { i18n } from "../../locale/i18nUtils";
|
|
8
|
+
import { HeaderTestIds } from "../../types/enum";
|
|
14
9
|
describe(`Header Component`, () => {
|
|
15
|
-
afterEach(
|
|
10
|
+
afterEach(cleanup);
|
|
16
11
|
test(`Exit button calls exitCallback`, () => {
|
|
17
|
-
const props =
|
|
18
|
-
const { getByTestId } =
|
|
12
|
+
const props = getRecommendationProps();
|
|
13
|
+
const { getByTestId } = render(<Header exitCallback={props.exitCallback}/>);
|
|
19
14
|
expect(props.exitCallback).not.toBeCalled();
|
|
20
|
-
|
|
15
|
+
fireEvent.press(getByTestId(HeaderTestIds.ExitCalculation));
|
|
21
16
|
expect(props.exitCallback).toBeCalled();
|
|
22
17
|
});
|
|
23
18
|
test.each `
|
|
24
19
|
language | locale | header
|
|
25
|
-
${`English`} | ${
|
|
26
|
-
${`Danish`} | ${
|
|
27
|
-
${`German`} | ${
|
|
28
|
-
${`Spanish`} | ${
|
|
29
|
-
${`Italian`} | ${
|
|
30
|
-
${`French`} | ${
|
|
20
|
+
${`English`} | ${Languages.en} | ${`INSULIN\nRECOMMENDATION`}
|
|
21
|
+
${`Danish`} | ${Languages.da} | ${`INSULIN\nANBEFALING`}
|
|
22
|
+
${`German`} | ${Languages.de} | ${`INSULIN\nEMPFEHLUNG`}
|
|
23
|
+
${`Spanish`} | ${Languages.es} | ${`RECOMENDACIÓN\nDE INSULINA`}
|
|
24
|
+
${`Italian`} | ${Languages.it} | ${`PRESCRIZIONE DI\nINSULINA`}
|
|
25
|
+
${`French`} | ${Languages.fr} | ${`RECOMMANDATION\nD’INSULINE`}
|
|
31
26
|
`(`Header is translated to $language`, ({ header, locale }) => {
|
|
32
|
-
const props =
|
|
27
|
+
const props = getRecommendationProps({
|
|
33
28
|
language: locale,
|
|
34
29
|
});
|
|
35
|
-
|
|
36
|
-
const wrapper =
|
|
37
|
-
<
|
|
38
|
-
</
|
|
39
|
-
|
|
30
|
+
i18n.activate(locale);
|
|
31
|
+
const wrapper = render(<I18nProvider language={locale} i18n={i18n}>
|
|
32
|
+
<Header exitCallback={props.exitCallback}/>
|
|
33
|
+
</I18nProvider>);
|
|
34
|
+
expectTextExists(wrapper, header);
|
|
40
35
|
});
|
|
41
36
|
});
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const types_1 = require("@hedia/types");
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const react_native_testing_library_1 = require("react-native-testing-library");
|
|
9
|
-
const InfoBars_1 = __importDefault(require("../../components/InfoBars"));
|
|
10
|
-
const utils_1 = require("../utils");
|
|
1
|
+
import { BloodGlucoseUnit, BloodKetonesUnit } from "@hedia/types";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { cleanup, render } from "react-native-testing-library";
|
|
4
|
+
import InfoBars from "../../components/InfoBars";
|
|
5
|
+
import { expectTextExists, expectTextNotExists } from "../utils";
|
|
11
6
|
var DisplayedUnit;
|
|
12
7
|
(function (DisplayedUnit) {
|
|
13
8
|
DisplayedUnit["MG_DL"] = "mg/dL";
|
|
14
9
|
DisplayedUnit["MMOL_L"] = "mmol/L";
|
|
15
10
|
})(DisplayedUnit || (DisplayedUnit = {}));
|
|
16
11
|
describe(`Info Bars Component`, () => {
|
|
17
|
-
afterEach(
|
|
12
|
+
afterEach(cleanup);
|
|
18
13
|
test(`Active Insulin info bar shows value`, () => {
|
|
19
14
|
const props = {
|
|
20
15
|
label: `Active Insulin`,
|
|
@@ -22,11 +17,11 @@ describe(`Info Bars Component`, () => {
|
|
|
22
17
|
value: `4.5`,
|
|
23
18
|
showNullAsDash: true,
|
|
24
19
|
};
|
|
25
|
-
const InfoBarsComponent =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
const InfoBarsComponent = render(<InfoBars {...props}/>);
|
|
21
|
+
expectTextNotExists(InfoBarsComponent, `${BloodGlucoseUnit.MMOL_L}`);
|
|
22
|
+
expectTextExists(InfoBarsComponent, props.label);
|
|
23
|
+
expectTextExists(InfoBarsComponent, `${props.unit}`);
|
|
24
|
+
expectTextExists(InfoBarsComponent, props.value);
|
|
30
25
|
});
|
|
31
26
|
test(`Active Insulin info bar - showNullAsDash`, () => {
|
|
32
27
|
const props = {
|
|
@@ -35,11 +30,11 @@ describe(`Info Bars Component`, () => {
|
|
|
35
30
|
showNullAsDash: true,
|
|
36
31
|
value: null,
|
|
37
32
|
};
|
|
38
|
-
const InfoBarsComponent =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
const InfoBarsComponent = render(<InfoBars {...props}/>);
|
|
34
|
+
expectTextNotExists(InfoBarsComponent, `${BloodGlucoseUnit.MG_DL}`);
|
|
35
|
+
expectTextExists(InfoBarsComponent, props.label);
|
|
36
|
+
expectTextExists(InfoBarsComponent, `${props.unit}`);
|
|
37
|
+
expectTextExists(InfoBarsComponent, `-.-`);
|
|
43
38
|
});
|
|
44
39
|
test(`Active Insulin info bar - don't showNullAsDash`, () => {
|
|
45
40
|
const props = {
|
|
@@ -48,80 +43,80 @@ describe(`Info Bars Component`, () => {
|
|
|
48
43
|
value: `3.5`,
|
|
49
44
|
showNullAsDash: false,
|
|
50
45
|
};
|
|
51
|
-
const InfoBarsComponent =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
const InfoBarsComponent = render(<InfoBars {...props}/>);
|
|
47
|
+
expectTextNotExists(InfoBarsComponent, `${BloodGlucoseUnit.MG_DL}`);
|
|
48
|
+
expectTextExists(InfoBarsComponent, props.label);
|
|
49
|
+
expectTextExists(InfoBarsComponent, `${props.unit}`);
|
|
50
|
+
expectTextExists(InfoBarsComponent, props.value);
|
|
56
51
|
});
|
|
57
52
|
test(`Blood Glucose mmol/l can be displayed`, () => {
|
|
58
53
|
const props = {
|
|
59
54
|
label: `Blood Glucose Levels`,
|
|
60
|
-
unit:
|
|
55
|
+
unit: BloodGlucoseUnit.MMOL_L,
|
|
61
56
|
value: `4.5`,
|
|
62
57
|
showNullAsDash: true,
|
|
63
58
|
};
|
|
64
|
-
const InfoBarsComponent =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
59
|
+
const InfoBarsComponent = render(<InfoBars {...props}/>);
|
|
60
|
+
expectTextNotExists(InfoBarsComponent, `${BloodGlucoseUnit.MG_DL}`);
|
|
61
|
+
expectTextNotExists(InfoBarsComponent, `${BloodGlucoseUnit.MMOL_L}`);
|
|
62
|
+
expectTextExists(InfoBarsComponent, props.label);
|
|
63
|
+
expectTextExists(InfoBarsComponent, DisplayedUnit.MMOL_L);
|
|
64
|
+
expectTextExists(InfoBarsComponent, props.value);
|
|
70
65
|
});
|
|
71
66
|
test(`Blood Glucose mg/dl can be displayed`, () => {
|
|
72
67
|
const props = {
|
|
73
68
|
label: `Blood Glucose Levels`,
|
|
74
|
-
unit:
|
|
69
|
+
unit: BloodGlucoseUnit.MG_DL,
|
|
75
70
|
value: `135`,
|
|
76
71
|
showNullAsDash: true,
|
|
77
72
|
};
|
|
78
|
-
const InfoBarsComponent =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
73
|
+
const InfoBarsComponent = render(<InfoBars {...props}/>);
|
|
74
|
+
expectTextNotExists(InfoBarsComponent, `${BloodGlucoseUnit.MMOL_L}`);
|
|
75
|
+
expectTextNotExists(InfoBarsComponent, `${BloodGlucoseUnit.MG_DL}`);
|
|
76
|
+
expectTextExists(InfoBarsComponent, props.label);
|
|
77
|
+
expectTextExists(InfoBarsComponent, DisplayedUnit.MG_DL);
|
|
78
|
+
expectTextExists(InfoBarsComponent, props.value);
|
|
84
79
|
});
|
|
85
80
|
test(`Blood Ketones mmol/l can be displayed`, () => {
|
|
86
81
|
const props = {
|
|
87
82
|
label: `Blood Ketone Level`,
|
|
88
|
-
unit:
|
|
83
|
+
unit: BloodKetonesUnit.MMOL_L,
|
|
89
84
|
value: `2.2`,
|
|
90
85
|
showNullAsDash: true,
|
|
91
86
|
};
|
|
92
|
-
const InfoBarsComponent =
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
87
|
+
const InfoBarsComponent = render(<InfoBars {...props}/>);
|
|
88
|
+
expectTextNotExists(InfoBarsComponent, `${BloodKetonesUnit.MG_DL}`);
|
|
89
|
+
expectTextNotExists(InfoBarsComponent, `${BloodKetonesUnit.MMOL_L}`);
|
|
90
|
+
expectTextExists(InfoBarsComponent, props.label);
|
|
91
|
+
expectTextExists(InfoBarsComponent, DisplayedUnit.MMOL_L);
|
|
92
|
+
expectTextExists(InfoBarsComponent, props.value);
|
|
98
93
|
});
|
|
99
94
|
test(`Blood Ketones mg/dl can be displayed`, () => {
|
|
100
95
|
const props = {
|
|
101
96
|
label: `Blood Ketone Level`,
|
|
102
|
-
unit:
|
|
97
|
+
unit: BloodKetonesUnit.MG_DL,
|
|
103
98
|
value: `10`,
|
|
104
99
|
showNullAsDash: true,
|
|
105
100
|
};
|
|
106
|
-
const InfoBarsComponent =
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
101
|
+
const InfoBarsComponent = render(<InfoBars {...props}/>);
|
|
102
|
+
expectTextNotExists(InfoBarsComponent, `${BloodKetonesUnit.MMOL_L}`);
|
|
103
|
+
expectTextNotExists(InfoBarsComponent, `${BloodKetonesUnit.MG_DL}`);
|
|
104
|
+
expectTextExists(InfoBarsComponent, props.label);
|
|
105
|
+
expectTextExists(InfoBarsComponent, DisplayedUnit.MG_DL);
|
|
106
|
+
expectTextExists(InfoBarsComponent, props.value);
|
|
112
107
|
});
|
|
113
108
|
test.each `
|
|
114
109
|
value | showNullAsDash | unit | expected
|
|
115
110
|
${null} | ${false} | ${`units`} | ${`0`}
|
|
116
|
-
${null} | ${false} | ${
|
|
117
|
-
${null} | ${false} | ${
|
|
118
|
-
${null} | ${false} | ${
|
|
119
|
-
${null} | ${false} | ${
|
|
111
|
+
${null} | ${false} | ${BloodGlucoseUnit.MG_DL} | ${`0`}
|
|
112
|
+
${null} | ${false} | ${BloodGlucoseUnit.MG_DL} | ${`0`}
|
|
113
|
+
${null} | ${false} | ${BloodKetonesUnit.MG_DL} | ${`0`}
|
|
114
|
+
${null} | ${false} | ${BloodKetonesUnit.MMOL_L} | ${`0`}
|
|
120
115
|
${null} | ${true} | ${`units`} | ${`-.-`}
|
|
121
|
-
${null} | ${true} | ${
|
|
122
|
-
${null} | ${true} | ${
|
|
123
|
-
${null} | ${true} | ${
|
|
124
|
-
${null} | ${true} | ${
|
|
116
|
+
${null} | ${true} | ${BloodGlucoseUnit.MG_DL} | ${`-`}
|
|
117
|
+
${null} | ${true} | ${BloodGlucoseUnit.MMOL_L} | ${`-.-`}
|
|
118
|
+
${null} | ${true} | ${BloodKetonesUnit.MG_DL} | ${`-`}
|
|
119
|
+
${null} | ${true} | ${BloodKetonesUnit.MMOL_L} | ${`-.-`}
|
|
125
120
|
`(`$value will be displayed as $expected when showNullAsDash === $showNullAsDash`, ({ expected, showNullAsDash, unit, value }) => {
|
|
126
121
|
const props = {
|
|
127
122
|
label: `Blood Glucose Levels`,
|
|
@@ -129,7 +124,7 @@ describe(`Info Bars Component`, () => {
|
|
|
129
124
|
value,
|
|
130
125
|
showNullAsDash,
|
|
131
126
|
};
|
|
132
|
-
const InfoBarsComponent =
|
|
133
|
-
|
|
127
|
+
const InfoBarsComponent = render(<InfoBars {...props}/>);
|
|
128
|
+
expectTextExists(InfoBarsComponent, expected);
|
|
134
129
|
});
|
|
135
130
|
});
|