@hedia/recommendation-screen 2.1.33 → 2.1.34-alpha.0
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/ios/HediaRecommendationScreen.xcodeproj/project.pbxproj +2 -2
- package/ios/Podfile.lock +207 -207
- package/package.json +1 -1
- package/index.d.ts +0 -5
- package/index.js +0 -5
- package/src/RecommendationScreen.d.ts +0 -413
- package/src/RecommendationScreen.js +0 -493
- package/src/__tests__/RecommendationScreen.test.d.ts +0 -1
- package/src/__tests__/RecommendationScreen.test.js +0 -965
- package/src/__tests__/RecommendationUtils.test.d.ts +0 -1
- package/src/__tests__/RecommendationUtils.test.js +0 -216
- package/src/__tests__/Translate.test.d.ts +0 -1
- package/src/__tests__/Translate.test.js +0 -27
- package/src/__tests__/Utils.test.d.ts +0 -1
- package/src/__tests__/Utils.test.js +0 -66
- package/src/__tests__/Validations.test.d.ts +0 -1
- package/src/__tests__/Validations.test.js +0 -465
- package/src/__tests__/components/Activity.test.d.ts +0 -1
- package/src/__tests__/components/Activity.test.js +0 -86
- package/src/__tests__/components/Emotion.test.d.ts +0 -1
- package/src/__tests__/components/Emotion.test.js +0 -70
- package/src/__tests__/components/Header.test.d.ts +0 -1
- package/src/__tests__/components/Header.test.js +0 -36
- package/src/__tests__/components/InfoBars.test.d.ts +0 -1
- package/src/__tests__/components/InfoBars.test.js +0 -130
- package/src/__tests__/components/InvisibleNumberInput.test.d.ts +0 -1
- package/src/__tests__/components/InvisibleNumberInput.test.js +0 -160
- package/src/__tests__/components/LimitationMessage.test.d.ts +0 -1
- package/src/__tests__/components/LimitationMessage.test.js +0 -47
- package/src/__tests__/components/MoodIcon.test.d.ts +0 -1
- package/src/__tests__/components/MoodIcon.test.js +0 -30
- package/src/__tests__/components/RecommendationModal.test.d.ts +0 -1
- package/src/__tests__/components/RecommendationModal.test.js +0 -98
- package/src/__tests__/components/RecommendedCarbs.test.d.ts +0 -1
- package/src/__tests__/components/RecommendedCarbs.test.js +0 -120
- package/src/__tests__/components/RecommendedInsulin.test.d.ts +0 -1
- package/src/__tests__/components/RecommendedInsulin.test.js +0 -154
- package/src/__tests__/components/Remeasure.test.d.ts +0 -1
- package/src/__tests__/components/Remeasure.test.js +0 -78
- package/src/__tests__/components/TransferToLogbook.test.d.ts +0 -1
- package/src/__tests__/components/TransferToLogbook.test.js +0 -30
- package/src/__tests__/components/TwoOptionModal.test.d.ts +0 -1
- package/src/__tests__/components/TwoOptionModal.test.js +0 -65
- package/src/__tests__/utils.d.ts +0 -16
- package/src/__tests__/utils.js +0 -126
- package/src/components/Header.d.ts +0 -10
- package/src/components/Header.js +0 -75
- package/src/components/Icon.d.ts +0 -20
- package/src/components/Icon.js +0 -41
- package/src/components/InfoBars.d.ts +0 -103
- package/src/components/InfoBars.js +0 -129
- package/src/components/InvisibleNumberInput.d.ts +0 -89
- package/src/components/InvisibleNumberInput.js +0 -122
- package/src/components/LimitationMessage.d.ts +0 -14
- package/src/components/LimitationMessage.js +0 -31
- package/src/components/LineSeparator.d.ts +0 -10
- package/src/components/LineSeparator.js +0 -18
- package/src/components/RecentInsulin.d.ts +0 -17
- package/src/components/RecentInsulin.js +0 -94
- package/src/components/RecommendationModal.d.ts +0 -207
- package/src/components/RecommendationModal.js +0 -213
- package/src/components/RecommendedCarbs.d.ts +0 -94
- package/src/components/RecommendedCarbs.js +0 -251
- package/src/components/RecommendedInsulin.d.ts +0 -84
- package/src/components/RecommendedInsulin.js +0 -170
- package/src/components/Remeasure.d.ts +0 -49
- package/src/components/Remeasure.js +0 -125
- package/src/components/TransferToLogbook.d.ts +0 -34
- package/src/components/TransferToLogbook.js +0 -94
- package/src/components/TwoOptionModal.d.ts +0 -145
- package/src/components/TwoOptionModal.js +0 -148
- package/src/components/activity/Activity.d.ts +0 -26
- package/src/components/activity/Activity.js +0 -80
- package/src/components/activity/ActivityIcon.d.ts +0 -22
- package/src/components/activity/ActivityIcon.js +0 -58
- package/src/components/activity/ActivityIntensity.d.ts +0 -16
- package/src/components/activity/ActivityIntensity.js +0 -59
- package/src/components/mood/Emotion.d.ts +0 -38
- package/src/components/mood/Emotion.js +0 -65
- package/src/components/mood/MoodIcon.d.ts +0 -40
- package/src/components/mood/MoodIcon.js +0 -66
- package/src/locale/i18nUtils.d.ts +0 -18
- package/src/locale/i18nUtils.js +0 -39
- package/src/types/enum.d.ts +0 -122
- package/src/types/enum.js +0 -138
- package/src/types/types.d.ts +0 -17
- package/src/types/types.js +0 -1
- package/src/utils/AttentionMessages.d.ts +0 -96
- package/src/utils/AttentionMessages.js +0 -118
- package/src/utils/Constants.d.ts +0 -47
- package/src/utils/Constants.js +0 -47
- package/src/utils/RecommendationError.d.ts +0 -56
- package/src/utils/RecommendationError.js +0 -62
- package/src/utils/RecommendationUtils.d.ts +0 -100
- package/src/utils/RecommendationUtils.js +0 -199
- package/src/utils/Translations.d.ts +0 -9
- package/src/utils/Translations.js +0 -14
- package/src/utils/Utils.d.ts +0 -105
- package/src/utils/Utils.js +0 -141
- package/src/utils/Validations.d.ts +0 -250
- package/src/utils/Validations.js +0 -409
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { BolusCalculator, UserSettings } from "@hedia/types";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { Platform } from "react-native";
|
|
4
|
-
import { cleanup, fireEvent, render } from "react-native-testing-library";
|
|
5
|
-
import RecommendedInsulin from "../../components/RecommendedInsulin";
|
|
6
|
-
import { Testing } from "../../types/enum";
|
|
7
|
-
import { expectTextExists, expectTextNotExists } from "../utils";
|
|
8
|
-
const { RecommendedInsulinTestIds } = Testing.Id;
|
|
9
|
-
const SAFETY_INSULIN_LIMIT = BolusCalculator.Constants.SAFETY_INSULIN_LIMIT;
|
|
10
|
-
const InjectionMethod = UserSettings.Enums.InjectionMethod;
|
|
11
|
-
const { PenHalf, PenWhole, Pump } = InjectionMethod;
|
|
12
|
-
describe(`RecommendedInsulin - Component`, () => {
|
|
13
|
-
afterEach(cleanup);
|
|
14
|
-
test(`Component is rendered`, () => {
|
|
15
|
-
const updateMock = jest.fn();
|
|
16
|
-
const method = Pump;
|
|
17
|
-
const wrapper = render(<RecommendedInsulin insulinRecommendation={2.3} updateRecommendedInsulin={updateMock} injectionMethod={method} activityReduction={null} enteredInsulin={null}/>);
|
|
18
|
-
expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
19
|
-
expectTextExists(wrapper, `2.3`);
|
|
20
|
-
expectTextExists(wrapper, `Units`);
|
|
21
|
-
});
|
|
22
|
-
test(`Insulin props defaults to 0`, () => {
|
|
23
|
-
const updateMock = jest.fn();
|
|
24
|
-
const method = PenHalf;
|
|
25
|
-
// @ts-ignore
|
|
26
|
-
const wrapper = render(<RecommendedInsulin updateRecommendedInsulin={updateMock} injectionMethod={method}/>);
|
|
27
|
-
expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
28
|
-
expectTextExists(wrapper, `0`);
|
|
29
|
-
expectTextExists(wrapper, `Units`);
|
|
30
|
-
});
|
|
31
|
-
test.each `
|
|
32
|
-
method | amount | result
|
|
33
|
-
${PenWhole} | ${1} | ${1}
|
|
34
|
-
${PenWhole} | ${1.49} | ${1}
|
|
35
|
-
${PenWhole} | ${1.5} | ${2}
|
|
36
|
-
${PenHalf} | ${1.24} | ${1}
|
|
37
|
-
${PenHalf} | ${1.25} | ${1.5}
|
|
38
|
-
${PenHalf} | ${1.74} | ${1.5}
|
|
39
|
-
${Pump} | ${1.14} | ${1.1}
|
|
40
|
-
${Pump} | ${1.15} | ${1.2}
|
|
41
|
-
${Pump} | ${12.35} | ${12.4}
|
|
42
|
-
`(`Rounding $amount using $method to $result`, ({ amount, method, result, }) => {
|
|
43
|
-
const updateMock = jest.fn();
|
|
44
|
-
const wrapper = render(
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
<RecommendedInsulin updateRecommendedInsulin={updateMock} injectionMethod={method}/>);
|
|
47
|
-
expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
48
|
-
const input = wrapper.getByTestId(RecommendedInsulinTestIds.InvisibleInsulinInput);
|
|
49
|
-
fireEvent(input, `onEnd`, amount);
|
|
50
|
-
expectTextExists(wrapper, `${result}`);
|
|
51
|
-
expect(updateMock).toBeCalledWith(result);
|
|
52
|
-
});
|
|
53
|
-
test(`Throw error on Unsupported InjectMethod`, () => {
|
|
54
|
-
const updateMock = jest.fn();
|
|
55
|
-
const wrapper = render(
|
|
56
|
-
// @ts-ignore
|
|
57
|
-
<RecommendedInsulin updateRecommendedInsulin={updateMock} injectionMethod={`Error`}/>);
|
|
58
|
-
expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
59
|
-
const input = wrapper.getByTestId(RecommendedInsulinTestIds.InvisibleInsulinInput);
|
|
60
|
-
expect(() => fireEvent(input, `onEnd`)).toThrowError(`Unsupported InjectionMethod: Error`);
|
|
61
|
-
});
|
|
62
|
-
test.each `
|
|
63
|
-
value | result
|
|
64
|
-
${0.0} | ${0}
|
|
65
|
-
${0.1} | ${0.1}
|
|
66
|
-
`(`Will not remove leading zero from $value`, ({ result, value }) => {
|
|
67
|
-
const updateMock = jest.fn();
|
|
68
|
-
const wrapper = render(
|
|
69
|
-
// @ts-ignore
|
|
70
|
-
<RecommendedInsulin updateRecommendedInsulin={updateMock} injectionMethod={Pump}/>);
|
|
71
|
-
expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
72
|
-
const input = wrapper.getByTestId(RecommendedInsulinTestIds.InvisibleInsulinInput);
|
|
73
|
-
fireEvent(input, `onEnd`, value);
|
|
74
|
-
expectTextExists(wrapper, `${result}`);
|
|
75
|
-
});
|
|
76
|
-
test.each `
|
|
77
|
-
value | result
|
|
78
|
-
${`09`} | ${9}
|
|
79
|
-
${`09.1`} | ${9.1}
|
|
80
|
-
`(`Will remove leading zero from $value`, ({ result, value }) => {
|
|
81
|
-
const updateMock = jest.fn();
|
|
82
|
-
const wrapper = render(
|
|
83
|
-
// @ts-ignore
|
|
84
|
-
<RecommendedInsulin updateRecommendedInsulin={updateMock} injectionMethod={Pump}/>);
|
|
85
|
-
expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
86
|
-
const input = wrapper.getByTestId(RecommendedInsulinTestIds.InvisibleInsulinInput);
|
|
87
|
-
fireEvent(input, `partialInput`, value);
|
|
88
|
-
expectTextExists(wrapper, `${result}`);
|
|
89
|
-
});
|
|
90
|
-
test(`Pressing on TouchableOpacity will callback on the invisible text input`, () => {
|
|
91
|
-
const updateMock = jest.fn();
|
|
92
|
-
const wrapper = render(
|
|
93
|
-
// @ts-ignore
|
|
94
|
-
<RecommendedInsulin updateRecommendedInsulin={updateMock} injectionMethod={Pump}/>);
|
|
95
|
-
expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
96
|
-
const button = wrapper.getByTestId(RecommendedInsulinTestIds.EditRecommendedInsulin);
|
|
97
|
-
fireEvent(button, `onPress`);
|
|
98
|
-
});
|
|
99
|
-
test.each `
|
|
100
|
-
value | reduction | isCorrect
|
|
101
|
-
${`50`} | ${0} | ${true}
|
|
102
|
-
${`${SAFETY_INSULIN_LIMIT}`} | ${0} | ${true}
|
|
103
|
-
${`${SAFETY_INSULIN_LIMIT + 1}`} | ${0} | ${false}
|
|
104
|
-
${`24`} | ${0.5} | ${true}
|
|
105
|
-
${`${(SAFETY_INSULIN_LIMIT + 1) * 0.5}`} | ${0.5} | ${false}
|
|
106
|
-
${`10`} | ${0.75} | ${true}
|
|
107
|
-
${`${(SAFETY_INSULIN_LIMIT + 1) * 0.25}`} | ${0.75} | ${false}
|
|
108
|
-
`(`Throws an error at insulin limits`, ({ reduction, isCorrect, value }) => {
|
|
109
|
-
const updateMock = jest.fn();
|
|
110
|
-
const wrapper = render(
|
|
111
|
-
// @ts-ignore
|
|
112
|
-
<RecommendedInsulin activityReduction={reduction} updateRecommendedInsulin={updateMock} injectionMethod={Pump}/>);
|
|
113
|
-
expectTextExists(wrapper, `Recommended amount of insulin`);
|
|
114
|
-
const input = wrapper.getByTestId(RecommendedInsulinTestIds.InvisibleInsulinInput);
|
|
115
|
-
fireEvent(input, `onEnd`, value);
|
|
116
|
-
if (isCorrect) {
|
|
117
|
-
expectTextExists(wrapper, value);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
expectTextNotExists(wrapper, value);
|
|
121
|
-
expectTextNotExists(wrapper, `OK`);
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
test.each `
|
|
125
|
-
reduction | expected | reductionPercent
|
|
126
|
-
${null} | ${SAFETY_INSULIN_LIMIT * (1 - 0)} | ${`${0 * 100}%`}
|
|
127
|
-
${undefined} | ${SAFETY_INSULIN_LIMIT * (1 - 0)} | ${`${0 * 100}%`}
|
|
128
|
-
${0} | ${SAFETY_INSULIN_LIMIT * (1 - 0)} | ${`${0 * 100}%`}
|
|
129
|
-
${0.1} | ${SAFETY_INSULIN_LIMIT * (1 - 0.1)} | ${`${0.1 * 100}%`}
|
|
130
|
-
${0.25} | ${SAFETY_INSULIN_LIMIT * (1 - 0.25)} | ${`${0.25 * 100}%`}
|
|
131
|
-
${0.5} | ${SAFETY_INSULIN_LIMIT * (1 - 0.5)} | ${`${0.5 * 100}%`}
|
|
132
|
-
${0.75} | ${SAFETY_INSULIN_LIMIT * (1 - 0.75)} | ${`${0.75 * 100}%`}
|
|
133
|
-
${0.9} | ${SAFETY_INSULIN_LIMIT * (1 - 0.9)} | ${`${0.9 * 100}%`}
|
|
134
|
-
`(`Recommendation is limited when entering over the maximum safety threshold of insulin when activity reduction is $reductionPercent`, ({ expected, reduction }) => {
|
|
135
|
-
const updateMock = jest.fn();
|
|
136
|
-
const wrapper = render(<RecommendedInsulin insulinRecommendation={expected} updateRecommendedInsulin={updateMock} injectionMethod={Pump} activityReduction={reduction} enteredInsulin={null}/>);
|
|
137
|
-
const input = wrapper.getByTestId(RecommendedInsulinTestIds.InvisibleInsulinInput);
|
|
138
|
-
const INVALID_INSULIN = SAFETY_INSULIN_LIMIT + 1;
|
|
139
|
-
fireEvent(input, `onEnd`, INVALID_INSULIN);
|
|
140
|
-
expect(updateMock).toBeCalledWith(expected);
|
|
141
|
-
});
|
|
142
|
-
test.each `
|
|
143
|
-
platform | padding
|
|
144
|
-
${`ios`} | ${`3%`}
|
|
145
|
-
${`android`} | ${`1%`}
|
|
146
|
-
`(`On $platform the component has $padding paddingBottom`, ({ padding, platform }) => {
|
|
147
|
-
Platform.OS = platform;
|
|
148
|
-
const updateMock = jest.fn();
|
|
149
|
-
const wrapper = render(
|
|
150
|
-
// @ts-ignore
|
|
151
|
-
<RecommendedInsulin updateRecommendedInsulin={updateMock} injectionMethod={Pump}/>);
|
|
152
|
-
expect(!!new RegExp(`"paddingBottom":"${padding}"`).exec(JSON.stringify(wrapper.toJSON()))).toBeTruthy();
|
|
153
|
-
});
|
|
154
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Platform } from "react-native";
|
|
3
|
-
import { cleanup, fireEvent, render } from "react-native-testing-library";
|
|
4
|
-
import Remeasure from "../../components/Remeasure";
|
|
5
|
-
import { Testing } from "../../types/enum";
|
|
6
|
-
import { expectTextExists, expectTextNotExists } from "../utils";
|
|
7
|
-
const { RemeasureTestIds } = Testing.Id;
|
|
8
|
-
describe(`Remeasure Component`, () => {
|
|
9
|
-
afterEach(cleanup);
|
|
10
|
-
test.each `
|
|
11
|
-
value | expected
|
|
12
|
-
${0} | ${`OFF`}
|
|
13
|
-
${1} | ${`1`}
|
|
14
|
-
${1.0} | ${`1`}
|
|
15
|
-
${2.3} | ${`2.3`}
|
|
16
|
-
${3.8} | ${`3.8`}
|
|
17
|
-
`(`Setting slider to $value displays $expected`, ({ value, expected }) => {
|
|
18
|
-
const onChange = jest.fn();
|
|
19
|
-
const wrapper = render(<Remeasure remeasureTime={1.5} onSliderChange={onChange}/>);
|
|
20
|
-
expectTextExists(wrapper, `1.5`);
|
|
21
|
-
const slider = wrapper.getByTestId(RemeasureTestIds.RemeasureSlider);
|
|
22
|
-
fireEvent(slider, `onValueChange`, value);
|
|
23
|
-
wrapper.rerender(<Remeasure remeasureTime={value} onSliderChange={onChange}/>);
|
|
24
|
-
expectTextExists(wrapper, `Remind me to remeasure in`);
|
|
25
|
-
expectTextNotExists(wrapper, `1.5`);
|
|
26
|
-
expectTextExists(wrapper, expected);
|
|
27
|
-
expect(onChange).toBeCalledWith(value);
|
|
28
|
-
});
|
|
29
|
-
test.each `
|
|
30
|
-
value | expected | callbackValue
|
|
31
|
-
${0} | ${`OFF`} | ${0}
|
|
32
|
-
${-0.1} | ${`OFF`} | ${0}
|
|
33
|
-
${-100} | ${`OFF`} | ${0}
|
|
34
|
-
${4.5} | ${`4.5`} | ${4.5}
|
|
35
|
-
${6.1} | ${`6`} | ${6}
|
|
36
|
-
${6.5} | ${`6`} | ${6}
|
|
37
|
-
${12} | ${`6`} | ${6}
|
|
38
|
-
${55} | ${`6`} | ${6}
|
|
39
|
-
`(`Setting slider to edge-case $value displays $expected`, ({ value, expected, callbackValue }) => {
|
|
40
|
-
const onChange = jest.fn();
|
|
41
|
-
const wrapper = render(<Remeasure remeasureTime={1.5} onSliderChange={onChange}/>);
|
|
42
|
-
expectTextExists(wrapper, `1.5`);
|
|
43
|
-
const slider = wrapper.getByTestId(RemeasureTestIds.RemeasureSlider);
|
|
44
|
-
fireEvent(slider, `onValueChange`, value);
|
|
45
|
-
wrapper.rerender(<Remeasure remeasureTime={value} onSliderChange={onChange}/>);
|
|
46
|
-
expectTextNotExists(wrapper, `1.5`);
|
|
47
|
-
expectTextExists(wrapper, expected);
|
|
48
|
-
if (isNaN(Number(expected))) {
|
|
49
|
-
expectTextNotExists(wrapper, `hours`);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
expectTextExists(wrapper, `hours`);
|
|
53
|
-
}
|
|
54
|
-
expect(onChange).toBeCalledWith(callbackValue);
|
|
55
|
-
});
|
|
56
|
-
test(`Setting it to default 1.5 still calls callback function`, () => {
|
|
57
|
-
const value = 1.5;
|
|
58
|
-
const expected = `1.5`;
|
|
59
|
-
const onChange = jest.fn();
|
|
60
|
-
const wrapper = render(<Remeasure remeasureTime={1.5} onSliderChange={onChange}/>);
|
|
61
|
-
expectTextExists(wrapper, `1.5`);
|
|
62
|
-
const slider = wrapper.getByTestId(RemeasureTestIds.RemeasureSlider);
|
|
63
|
-
fireEvent(slider, `onValueChange`, value);
|
|
64
|
-
wrapper.rerender(<Remeasure remeasureTime={value} onSliderChange={onChange}/>);
|
|
65
|
-
expectTextExists(wrapper, expected);
|
|
66
|
-
expect(onChange).toBeCalledWith(value);
|
|
67
|
-
});
|
|
68
|
-
test.each `
|
|
69
|
-
platform | margin
|
|
70
|
-
${`ios`} | ${`3%`}
|
|
71
|
-
${`android`} | ${`0%`}
|
|
72
|
-
`(`On $platform the slider has $margin marginHorizontal`, ({ margin, platform }) => {
|
|
73
|
-
Platform.OS = platform;
|
|
74
|
-
const onChange = jest.fn();
|
|
75
|
-
const wrapper = render(<Remeasure remeasureTime={1.5} onSliderChange={onChange}/>);
|
|
76
|
-
expect(!!new RegExp(`RNCSlider",.*marginHorizontal":"${margin}"`).exec(JSON.stringify(wrapper.toJSON()))).toBeTruthy();
|
|
77
|
-
});
|
|
78
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { fireEvent, render } from "react-native-testing-library";
|
|
3
|
-
import TransferToLogbook from "../../components/TransferToLogbook";
|
|
4
|
-
import { Testing } from "../../types/enum";
|
|
5
|
-
import { expectTextExists, expectTextNotExists } from "../utils";
|
|
6
|
-
describe(`TransferToLogbook - Component`, () => {
|
|
7
|
-
test(`Is null when visible not visible`, () => {
|
|
8
|
-
const transferMock = jest.fn();
|
|
9
|
-
const wrapper = render(<TransferToLogbook visible={false} transfer={transferMock}/>);
|
|
10
|
-
expectTextNotExists(wrapper, `Transfer to logbook`);
|
|
11
|
-
expect(transferMock).not.toBeCalled();
|
|
12
|
-
});
|
|
13
|
-
test(`Mounts with "transfer to logbook" text when visible`, () => {
|
|
14
|
-
const transferMock = jest.fn();
|
|
15
|
-
const wrapper = render(<TransferToLogbook visible={true} transfer={transferMock}/>);
|
|
16
|
-
expectTextExists(wrapper, `Transfer to logbook`);
|
|
17
|
-
expect(transferMock).not.toBeCalled();
|
|
18
|
-
});
|
|
19
|
-
test(`Pressing the button will trigger the callback`, () => {
|
|
20
|
-
const transferMock = jest.fn();
|
|
21
|
-
const wrapper = render(<TransferToLogbook visible={true} transfer={transferMock}/>);
|
|
22
|
-
expectTextExists(wrapper, `Transfer to logbook`);
|
|
23
|
-
const button = wrapper.getByTestId(Testing.Id.TransferToLogbookTestIds.TransferButton);
|
|
24
|
-
expect(transferMock).not.toBeCalled();
|
|
25
|
-
fireEvent(button, `onPress`);
|
|
26
|
-
expectTextNotExists(wrapper, `Transfer to logbook`);
|
|
27
|
-
expectTextExists(wrapper, `Transferred to logbook`);
|
|
28
|
-
expect(transferMock).toBeCalled();
|
|
29
|
-
});
|
|
30
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { cleanup, fireEvent, render } from "react-native-testing-library";
|
|
3
|
-
import TwoOptionModal from "../../components/TwoOptionModal";
|
|
4
|
-
import { Testing } from "../../types/enum";
|
|
5
|
-
import { expectTextExists } from "../utils";
|
|
6
|
-
const { TwoOptionModalTestIds } = Testing.Id;
|
|
7
|
-
describe(`TwoOptionModal Component`, () => {
|
|
8
|
-
afterEach(cleanup);
|
|
9
|
-
test(`Can can show text `, () => {
|
|
10
|
-
const props = {
|
|
11
|
-
firstOption: jest.fn(),
|
|
12
|
-
secondOption: jest.fn(),
|
|
13
|
-
onClose: jest.fn(),
|
|
14
|
-
rowAsButtonLayout: true,
|
|
15
|
-
textFirstOption: `Gem i logbog`,
|
|
16
|
-
message: `Dine gemte indtastninger vil blive brugt til fremtidige beregninger.`,
|
|
17
|
-
textSecondOption: `Luk beregning`,
|
|
18
|
-
title: `Vil du gemme din indtastning?`,
|
|
19
|
-
};
|
|
20
|
-
const wrapper = render(<TwoOptionModal {...props}/>);
|
|
21
|
-
expectTextExists(wrapper, `Luk beregning`);
|
|
22
|
-
expectTextExists(wrapper, `Dine gemte indtastninger vil blive brugt til fremtidige beregninger.`);
|
|
23
|
-
expectTextExists(wrapper, `Gem i logbog`);
|
|
24
|
-
expectTextExists(wrapper, `Vil du gemme din indtastning?`);
|
|
25
|
-
});
|
|
26
|
-
test(`Test that callbacks are called`, () => {
|
|
27
|
-
const props = {
|
|
28
|
-
firstOption: jest.fn(),
|
|
29
|
-
secondOption: jest.fn(),
|
|
30
|
-
onClose: jest.fn(),
|
|
31
|
-
rowAsButtonLayout: true,
|
|
32
|
-
isCancelable: true,
|
|
33
|
-
textFirstOption: `Gem i logbog`,
|
|
34
|
-
message: `Dine gemte indtastninger vil blive brugt til fremtidige beregninger.`,
|
|
35
|
-
textSecondOption: `Luk beregning`,
|
|
36
|
-
title: `Vil du gemme din indtastning?`,
|
|
37
|
-
};
|
|
38
|
-
const wrapper = render(<TwoOptionModal {...props}/>);
|
|
39
|
-
expectTextExists(wrapper, `Luk beregning`);
|
|
40
|
-
const modalExitIcon = wrapper.getByTestId(TwoOptionModalTestIds.ExitButton);
|
|
41
|
-
fireEvent(modalExitIcon, `onPress`);
|
|
42
|
-
expect(props.onClose).toBeCalled();
|
|
43
|
-
const closeCalculation = wrapper.getByTestId(TwoOptionModalTestIds.SecondOption);
|
|
44
|
-
fireEvent(closeCalculation, `onPress`);
|
|
45
|
-
expect(props.secondOption).toBeCalled();
|
|
46
|
-
const firstOptionButton = wrapper.getByTestId(TwoOptionModalTestIds.FirstOption);
|
|
47
|
-
fireEvent(firstOptionButton, `onPress`);
|
|
48
|
-
expect(props.firstOption).toBeCalled();
|
|
49
|
-
});
|
|
50
|
-
test(`Test it is not cancelable`, () => {
|
|
51
|
-
const props = {
|
|
52
|
-
firstOption: jest.fn(),
|
|
53
|
-
secondOption: jest.fn(),
|
|
54
|
-
rowAsButtonLayout: true,
|
|
55
|
-
textFirstOption: `Gem i logbog`,
|
|
56
|
-
message: `Dine gemte indtastninger vil blive brugt til fremtidige beregninger.`,
|
|
57
|
-
textSecondOption: `Luk beregning`,
|
|
58
|
-
title: `Vil du gemme din indtastning?`,
|
|
59
|
-
};
|
|
60
|
-
const wrapper = render(<TwoOptionModal {...props}/>);
|
|
61
|
-
expectTextExists(wrapper, `Luk beregning`);
|
|
62
|
-
const modalExitIcon = wrapper.queryByTestId(TwoOptionModalTestIds.ExitButton);
|
|
63
|
-
expect(modalExitIcon).toBeNull();
|
|
64
|
-
});
|
|
65
|
-
});
|
package/src/__tests__/utils.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { BolusCalculator, Logbook } from "@hedia/types";
|
|
3
|
-
import { RenderAPI } from "react-native-testing-library";
|
|
4
|
-
import { ReactTestInstance } from "react-test-renderer";
|
|
5
|
-
import { IRecommendationProps } from "../RecommendationScreen";
|
|
6
|
-
import { Testing } from "../types/enum";
|
|
7
|
-
export declare function getRecommendationProps(partials?: Partial<IRecommendationProps>): IRecommendationProps;
|
|
8
|
-
export declare function generateDefaultCalculatorParams(): BolusCalculator.Types.IRecommendationParams;
|
|
9
|
-
export declare function generateActivityProps(): BolusCalculator.Types.IActivityParams;
|
|
10
|
-
export declare function generateDefaultActivitySettings(): BolusCalculator.Types.IActivityParams["activitySettings"];
|
|
11
|
-
export declare function generateDefaultLogbook(): Logbook.Types.ILogbookEntry;
|
|
12
|
-
export declare function expectTextExists(component: RenderAPI, text: string | RegExp): void;
|
|
13
|
-
export declare function queryTextFromComponent(wrapper: RenderAPI, testID: Testing.Types.TestIdEnum): string;
|
|
14
|
-
export declare function expectTextNotExists(component: RenderAPI, text: string | RegExp): void;
|
|
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.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { Activity, BloodGlucoseUnit, BloodKetonesUnit, Languages, UserSettings, } from "@hedia/types";
|
|
2
|
-
import { I18nProvider } from "@lingui/react";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { i18n } from "../locale/i18nUtils";
|
|
5
|
-
const ActivityEnum = Activity.Enums.ActivityEnum;
|
|
6
|
-
const ActivityIntensity = Activity.Enums.ActivityIntensity;
|
|
7
|
-
const InjectionMethod = UserSettings.Enums.InjectionMethod;
|
|
8
|
-
const { Run } = ActivityEnum;
|
|
9
|
-
const { moderate } = ActivityIntensity;
|
|
10
|
-
const { PenHalf } = InjectionMethod;
|
|
11
|
-
export function getRecommendationProps(partials) {
|
|
12
|
-
return {
|
|
13
|
-
currentBKL: partials?.currentBKL ?? 0.1,
|
|
14
|
-
bloodKetoneUnit: partials?.bloodKetoneUnit ?? BloodKetonesUnit.MMOL_L,
|
|
15
|
-
bloodGlucoseUnit: partials?.bloodGlucoseUnit ?? BloodGlucoseUnit.MMOL_L,
|
|
16
|
-
language: partials?.language ?? Languages.en,
|
|
17
|
-
userReminder: partials?.userReminder ?? 1.5,
|
|
18
|
-
latestLogbookFrom6Hours: partials?.latestLogbookFrom6Hours ?? generateDefaultLogbook(),
|
|
19
|
-
calculatorParams: partials?.calculatorParams ?? generateDefaultCalculatorParams(),
|
|
20
|
-
injectionMethod: partials?.injectionMethod ?? PenHalf,
|
|
21
|
-
transferToLogbook: partials?.transferToLogbook ?? jest.fn(),
|
|
22
|
-
onError: partials?.onError ?? jest.fn(),
|
|
23
|
-
onRecentInsulinYes: partials?.onRecentInsulinYes ?? jest.fn(),
|
|
24
|
-
exitCallback: partials?.exitCallback ?? jest.fn(),
|
|
25
|
-
closeCalculationCallback: partials?.closeCalculationCallback ?? jest.fn(),
|
|
26
|
-
carbRecommendationAnswer: partials?.carbRecommendationAnswer ?? jest.fn(),
|
|
27
|
-
showBolusBar: partials?.showBolusBar ?? jest.fn(),
|
|
28
|
-
restartCalculation: partials?.restartCalculation ?? jest.fn(),
|
|
29
|
-
activityDisplayProps: partials?.activityDisplayProps ?? {
|
|
30
|
-
activityTitle: `Activity Title Test`,
|
|
31
|
-
activityType: Run,
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
export function generateDefaultCalculatorParams() {
|
|
36
|
-
return {
|
|
37
|
-
carbohydrateRatio: 10,
|
|
38
|
-
carbohydrates: 4,
|
|
39
|
-
currentBGL: 5,
|
|
40
|
-
insulinSensitivity: 4,
|
|
41
|
-
targetBGL: 6,
|
|
42
|
-
recentBoluses: [
|
|
43
|
-
{
|
|
44
|
-
insulinDose: 2,
|
|
45
|
-
secondsPassed: 1000,
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
insulinDose: 1.7,
|
|
49
|
-
secondsPassed: 10000,
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
activity: null,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
export function generateActivityProps() {
|
|
56
|
-
return {
|
|
57
|
-
activityDate: new Date(),
|
|
58
|
-
activityDuration: 30,
|
|
59
|
-
activityIntensity: moderate,
|
|
60
|
-
activitySettings: generateDefaultActivitySettings(),
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
export function generateDefaultActivitySettings() {
|
|
64
|
-
return {
|
|
65
|
-
hard: { fromFortysix: null, fromThirty: 0.25, fromZero: 1 },
|
|
66
|
-
light: { fromFortysix: 0.5, fromThirty: 0.75, fromZero: 1 },
|
|
67
|
-
moderate: { fromFortysix: 0.25, fromThirty: 0.5, fromZero: 1 },
|
|
68
|
-
post: { fromFortysix: 0.5, fromThirty: 0.5, fromZero: 1 },
|
|
69
|
-
target: 9,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
export function generateDefaultLogbook() {
|
|
73
|
-
return {
|
|
74
|
-
blood_glucose_millimolar: 6,
|
|
75
|
-
carbohydrates_entered_grams: 25,
|
|
76
|
-
carbohydrates_suggested_grams: 25,
|
|
77
|
-
client_timestamp: new Date(),
|
|
78
|
-
client_version: `25`,
|
|
79
|
-
entry_timestamp: new Date(),
|
|
80
|
-
event_uuid: null,
|
|
81
|
-
insulin_entered_units: 25,
|
|
82
|
-
insulin_suggested_units: 25,
|
|
83
|
-
is_deleted: null,
|
|
84
|
-
mood: 2,
|
|
85
|
-
settings_uuid: `25`,
|
|
86
|
-
uuid: `aaa`,
|
|
87
|
-
device_and_os: `ios 12.1.2`,
|
|
88
|
-
overwritten_by_id: null,
|
|
89
|
-
server_timestamp: null,
|
|
90
|
-
server_version: null,
|
|
91
|
-
utc_timezone_offset: null,
|
|
92
|
-
blood_ketones_millimolar: null,
|
|
93
|
-
carbohydrates_modified_suggested_grams: null,
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
export function expectTextExists(component, text) {
|
|
97
|
-
const element = component.queryByText(text);
|
|
98
|
-
/*
|
|
99
|
-
if (!element) {
|
|
100
|
-
throw Error(`element with text: ${text} does not exist`);
|
|
101
|
-
}
|
|
102
|
-
*/
|
|
103
|
-
return expect(element).not.toBeNull();
|
|
104
|
-
}
|
|
105
|
-
export function queryTextFromComponent(wrapper, testID) {
|
|
106
|
-
const component = wrapper.getByTestId(testID);
|
|
107
|
-
const values = component.children;
|
|
108
|
-
return values.join(``);
|
|
109
|
-
}
|
|
110
|
-
export function expectTextNotExists(component, text) {
|
|
111
|
-
const element = component.queryByText(text);
|
|
112
|
-
/*
|
|
113
|
-
if (element) {
|
|
114
|
-
throw Error(`element with text: ${text} should not exist`);
|
|
115
|
-
}
|
|
116
|
-
*/
|
|
117
|
-
return expect(element).toBeNull();
|
|
118
|
-
}
|
|
119
|
-
export function i18nProvided(element) {
|
|
120
|
-
return (<I18nProvider language={i18n.language} i18n={i18n}>
|
|
121
|
-
{element}
|
|
122
|
-
</I18nProvider>);
|
|
123
|
-
}
|
|
124
|
-
export function getIcon(wrapper, name, active) {
|
|
125
|
-
return wrapper.queryByA11yLabel(`${name}_${active}`);
|
|
126
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
export interface IProps {
|
|
3
|
-
/** A callback that doesn’t take any arguments and doesn’t return a value to be called when the cancel-button is pressed. */
|
|
4
|
-
exitCallback(): void;
|
|
5
|
-
}
|
|
6
|
-
/** Component to display a header text along with a cancel-button that triggers a callback function. */
|
|
7
|
-
export default class Header extends React.Component<IProps> {
|
|
8
|
-
/** JSX element to display the cancel button and header. When the cancel button in the header is tabbed, the exitCallback prop callback function should be called. */
|
|
9
|
-
render(): JSX.Element;
|
|
10
|
-
}
|
package/src/components/Header.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { t } from "@lingui/macro";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { Dimensions, SafeAreaView, StyleSheet, Text, TouchableOpacity, View } from "react-native";
|
|
4
|
-
import { i18n } from "../locale/i18nUtils";
|
|
5
|
-
import { Testing } from "../types/enum";
|
|
6
|
-
import { BACKGROUND_COLOUR_PURPLE, BORDER_COLOUR_GREY } from "../utils/Constants";
|
|
7
|
-
import Icon from "./Icon";
|
|
8
|
-
/** Component to display a header text along with a cancel-button that triggers a callback function. */
|
|
9
|
-
export default class Header extends React.Component {
|
|
10
|
-
/** JSX element to display the cancel button and header. When the cancel button in the header is tabbed, the exitCallback prop callback function should be called. */
|
|
11
|
-
render() {
|
|
12
|
-
return (<React.Fragment>
|
|
13
|
-
<SafeAreaView style={headerStyles.backgroundColour}/>
|
|
14
|
-
<View style={headerStyles.headerContainer}>
|
|
15
|
-
<View style={headerStyles.margin}>
|
|
16
|
-
<View style={headerStyles.exitButtonContainer}>
|
|
17
|
-
<View style={headerStyles.exitButton}>
|
|
18
|
-
<TouchableOpacity testID={Testing.Id.HeaderTestIds.ExitCalculation} accessibilityLabel="exitButton" style={headerStyles.exitButton} onPress={this.props.exitCallback}>
|
|
19
|
-
<Icon iconIdentifier={`Ionicons/ios-close-circle-outline`} style={headerStyles.iconStyle}/>
|
|
20
|
-
</TouchableOpacity>
|
|
21
|
-
<View style={headerStyles.headerFiller}/>
|
|
22
|
-
</View>
|
|
23
|
-
</View>
|
|
24
|
-
<View style={headerStyles.headerTextContainer}>
|
|
25
|
-
<Text style={headerStyles.headerText} testID="headerText">
|
|
26
|
-
{i18n._(t `INSULIN${`\n`}RECOMMENDATION`)}
|
|
27
|
-
</Text>
|
|
28
|
-
</View>
|
|
29
|
-
<View style={headerStyles.headerFiller}/>
|
|
30
|
-
</View>
|
|
31
|
-
</View>
|
|
32
|
-
</React.Fragment>);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
const headerStyles = StyleSheet.create({
|
|
36
|
-
backgroundColour: {
|
|
37
|
-
backgroundColor: BACKGROUND_COLOUR_PURPLE,
|
|
38
|
-
},
|
|
39
|
-
margin: {
|
|
40
|
-
margin: `1%`,
|
|
41
|
-
marginBottom: `3%`,
|
|
42
|
-
flexDirection: `row`,
|
|
43
|
-
flex: 1,
|
|
44
|
-
},
|
|
45
|
-
headerContainer: {
|
|
46
|
-
flexDirection: `row`,
|
|
47
|
-
flex: 1,
|
|
48
|
-
},
|
|
49
|
-
exitButtonContainer: {
|
|
50
|
-
alignItems: `center`,
|
|
51
|
-
flex: 1,
|
|
52
|
-
},
|
|
53
|
-
exitButton: {
|
|
54
|
-
flex: 1,
|
|
55
|
-
},
|
|
56
|
-
iconStyle: {
|
|
57
|
-
fontSize: Dimensions.get(`screen`).width / 12,
|
|
58
|
-
color: BORDER_COLOUR_GREY,
|
|
59
|
-
},
|
|
60
|
-
headerTextContainer: {
|
|
61
|
-
flex: 6,
|
|
62
|
-
justifyContent: `center`,
|
|
63
|
-
alignItems: `center`,
|
|
64
|
-
marginTop: `5%`,
|
|
65
|
-
},
|
|
66
|
-
headerText: {
|
|
67
|
-
fontSize: Dimensions.get(`screen`).width / 18,
|
|
68
|
-
fontWeight: `bold`,
|
|
69
|
-
textAlign: `center`,
|
|
70
|
-
color: `white`,
|
|
71
|
-
},
|
|
72
|
-
headerFiller: {
|
|
73
|
-
flex: 1,
|
|
74
|
-
},
|
|
75
|
-
});
|
package/src/components/Icon.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { StyleSheet } from "react-native";
|
|
3
|
-
/** Mapping from react-native-vector-icons identifier to corresponding icon resource. */
|
|
4
|
-
export declare const IconSets: Record<string, any>;
|
|
5
|
-
export interface IProps {
|
|
6
|
-
/** The name of the react-native-vector-icons identifier */
|
|
7
|
-
iconIdentifier: string;
|
|
8
|
-
/** Style of the icon */
|
|
9
|
-
iconStyle: StyleSheet.NamedStyles<any>;
|
|
10
|
-
}
|
|
11
|
-
/** Component used to display a react-native-vector-icons */
|
|
12
|
-
export default class Icon extends React.Component<IProps> {
|
|
13
|
-
static defaultProps: any;
|
|
14
|
-
_root: any;
|
|
15
|
-
setNativeProps(nativeProps: any): void;
|
|
16
|
-
/**
|
|
17
|
-
* @returns JSX Element containing the desired react-native-vector-icons
|
|
18
|
-
*/
|
|
19
|
-
render(): JSX.Element;
|
|
20
|
-
}
|
package/src/components/Icon.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
/* tslint:disable */
|
|
3
|
-
import React from "react";
|
|
4
|
-
/** Mapping from react-native-vector-icons identifier to corresponding icon resource. */
|
|
5
|
-
export const IconSets = {
|
|
6
|
-
AntDesign: require(`react-native-vector-icons/AntDesign`),
|
|
7
|
-
Feather: require(`react-native-vector-icons/Feather`),
|
|
8
|
-
EvilIcons: require(`react-native-vector-icons/EvilIcons`),
|
|
9
|
-
Ionicons: require(`react-native-vector-icons/Ionicons`),
|
|
10
|
-
FontAwesome: require(`react-native-vector-icons/FontAwesome`),
|
|
11
|
-
Entypo: require(`react-native-vector-icons/Entypo`),
|
|
12
|
-
};
|
|
13
|
-
/** Component used to display a react-native-vector-icons */
|
|
14
|
-
export default class Icon extends React.Component {
|
|
15
|
-
setNativeProps(nativeProps) {
|
|
16
|
-
this._root.setNativeProps(nativeProps);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* @returns JSX Element containing the desired react-native-vector-icons
|
|
20
|
-
*/
|
|
21
|
-
render() {
|
|
22
|
-
const iconParts = this.props.iconIdentifier.split(`/`);
|
|
23
|
-
let iconPackageName = iconParts[0];
|
|
24
|
-
let iconName = iconParts[1];
|
|
25
|
-
if (!IconSets[iconPackageName]) {
|
|
26
|
-
iconPackageName = `FontAwesome`;
|
|
27
|
-
iconName = `question`;
|
|
28
|
-
}
|
|
29
|
-
const clonedProps = {
|
|
30
|
-
...this.props,
|
|
31
|
-
name: iconName,
|
|
32
|
-
iconIdentifier: undefined,
|
|
33
|
-
ref: (component) => (this._root = component),
|
|
34
|
-
};
|
|
35
|
-
const IconClass = IconSets[iconPackageName].default;
|
|
36
|
-
return <IconClass {...clonedProps}/>;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
Icon.defaultProps = {
|
|
40
|
-
iconIdentifier: `FontAwesome/question`,
|
|
41
|
-
};
|