@hedia/recommendation-screen 2.0.2 → 2.1.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/App.d.ts +2 -2
- package/coverage/clover.xml +700 -0
- package/coverage/coverage-final.json +28 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +79 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +201 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +170 -0
- package/coverage/lcov-report/src/RecommendationScreen.tsx.html +1460 -0
- package/coverage/lcov-report/src/__tests__/index.html +111 -0
- package/coverage/lcov-report/src/__tests__/utils.tsx.html +512 -0
- package/coverage/lcov-report/src/components/Header.tsx.html +347 -0
- package/coverage/lcov-report/src/components/InfoBars.tsx.html +404 -0
- package/coverage/lcov-report/src/components/InvisibleNumberInput.tsx.html +374 -0
- package/coverage/lcov-report/src/components/LimitationMessage.tsx.html +191 -0
- package/coverage/lcov-report/src/components/LineSeparator.tsx.html +152 -0
- package/coverage/lcov-report/src/components/RecentInsulin.tsx.html +383 -0
- package/coverage/lcov-report/src/components/RecommendationModal.tsx.html +737 -0
- package/coverage/lcov-report/src/components/RecommendedCarbs.tsx.html +857 -0
- package/coverage/lcov-report/src/components/RecommendedInsulin.tsx.html +605 -0
- package/coverage/lcov-report/src/components/Remeasure.tsx.html +440 -0
- package/coverage/lcov-report/src/components/TransferToLogbook.tsx.html +380 -0
- package/coverage/lcov-report/src/components/TwoOptionModal.tsx.html +635 -0
- package/coverage/lcov-report/src/components/activity/Activity.tsx.html +311 -0
- package/coverage/lcov-report/src/components/activity/ActivityIcon.tsx.html +242 -0
- package/coverage/lcov-report/src/components/activity/ActivityIntensity.tsx.html +257 -0
- package/coverage/lcov-report/src/components/activity/index.html +141 -0
- package/coverage/lcov-report/src/components/index.html +276 -0
- package/coverage/lcov-report/src/components/mood/Emotion.tsx.html +278 -0
- package/coverage/lcov-report/src/components/mood/MoodIcon.tsx.html +260 -0
- package/coverage/lcov-report/src/components/mood/index.html +126 -0
- package/coverage/lcov-report/src/index.html +111 -0
- package/coverage/lcov-report/src/locale/i18nUtils.ts.html +161 -0
- package/coverage/lcov-report/src/locale/index.html +111 -0
- package/coverage/lcov-report/src/utils/AttentionMessages.tsx.html +326 -0
- package/coverage/lcov-report/src/utils/Constants.ts.html +176 -0
- package/coverage/lcov-report/src/utils/RecommendationError.tsx.html +500 -0
- package/coverage/lcov-report/src/utils/RecommendationUtils.ts.html +467 -0
- package/coverage/lcov-report/src/utils/Translations.ts.html +107 -0
- package/coverage/lcov-report/src/utils/Utils.ts.html +263 -0
- package/coverage/lcov-report/src/utils/Validations.ts.html +815 -0
- package/coverage/lcov-report/src/utils/index.html +201 -0
- package/coverage/lcov.info +1581 -0
- package/jest.config.js +2 -1
- package/package.json +2 -2
- package/src/RecommendationScreen.d.ts +2 -3
- package/src/__tests__/components/Emotion.test.jsx +7 -8
- package/src/components/Icon.d.ts +13 -0
- package/src/components/Icon.jsx +42 -0
- package/src/components/LimitationMessage.d.ts +1 -2
- package/src/components/RecommendationModal.d.ts +2 -3
- package/src/components/RecommendationModal.jsx +2 -1
- package/src/components/activity/ActivityIntensity.jsx +4 -3
- package/src/utils/AttentionMessages.d.ts +16 -10
- package/src/utils/AttentionMessages.jsx +15 -10
- package/src/utils/RecommendationUtils.d.ts +2 -3
- package/src/utils/RecommendationUtils.js +10 -6
- package/src/utils/Utils.d.ts +1 -0
- package/src/utils/Utils.js +4 -0
- package/tsconfig.json +7 -5
- package/App.tsx +0 -140
- package/index.ts +0 -6
- package/src/RecommendationScreen.tsx +0 -461
- package/src/__tests__/RecommendationScreen.test.tsx +0 -1231
- package/src/__tests__/RecommendationUtils.test.ts +0 -332
- package/src/__tests__/Translate.test.tsx +0 -31
- package/src/__tests__/Utils.test.ts +0 -91
- package/src/__tests__/Validations.test.ts +0 -648
- package/src/__tests__/components/Activity.test.tsx +0 -163
- package/src/__tests__/components/Emotion.test.tsx +0 -110
- package/src/__tests__/components/Header.test.tsx +0 -44
- package/src/__tests__/components/InfoBars.test.tsx +0 -152
- package/src/__tests__/components/InvisibleNumberInput.test.tsx +0 -294
- package/src/__tests__/components/LimitationMessage.test.tsx +0 -58
- package/src/__tests__/components/MoodIcon.test.tsx +0 -45
- package/src/__tests__/components/RecommendationModal.test.tsx +0 -169
- package/src/__tests__/components/RecommendedCarbs.test.tsx +0 -234
- package/src/__tests__/components/RecommendedInsulin.test.tsx +0 -241
- package/src/__tests__/components/Remeasure.test.tsx +0 -97
- package/src/__tests__/components/TransferToLogbook.test.tsx +0 -38
- package/src/__tests__/components/TwoOptionModal.test.tsx +0 -72
- package/src/__tests__/utils.tsx +0 -144
- package/src/components/Header.tsx +0 -89
- package/src/components/Icon.js +0 -41
- package/src/components/InfoBars.tsx +0 -108
- package/src/components/InvisibleNumberInput.tsx +0 -98
- package/src/components/LimitationMessage.tsx +0 -38
- package/src/components/LineSeparator.tsx +0 -24
- package/src/components/RecentInsulin.tsx +0 -101
- package/src/components/RecommendationModal.tsx +0 -224
- package/src/components/RecommendedCarbs.tsx +0 -259
- package/src/components/RecommendedInsulin.tsx +0 -175
- package/src/components/Remeasure.tsx +0 -120
- package/src/components/TransferToLogbook.tsx +0 -100
- package/src/components/TwoOptionModal.tsx +0 -185
- package/src/components/activity/Activity.tsx +0 -77
- package/src/components/activity/ActivityIcon.tsx +0 -54
- package/src/components/activity/ActivityIntensity.tsx +0 -58
- package/src/components/mood/Emotion.tsx +0 -66
- package/src/components/mood/MoodIcon.tsx +0 -60
- package/src/locale/CleanLanguage.ts +0 -13
- package/src/locale/i18nUtils.ts +0 -27
- package/src/types/enum.ts +0 -108
- package/src/types/types.ts +0 -16
- package/src/utils/AttentionMessages.tsx +0 -75
- package/src/utils/Constants.ts +0 -32
- package/src/utils/RecommendationError.tsx +0 -140
- package/src/utils/RecommendationUtils.ts +0 -125
- package/src/utils/Translations.ts +0 -9
- package/src/utils/Utils.ts +0 -57
- package/src/utils/Validations.ts +0 -245
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { cleanup, fireEvent, render } from "react-native-testing-library";
|
|
3
|
-
import InvisibleNumberInput from "../../components/InvisibleNumberInput";
|
|
4
|
-
|
|
5
|
-
describe(`InvisibleNumberInput Component`, (): void => {
|
|
6
|
-
afterEach(cleanup);
|
|
7
|
-
|
|
8
|
-
test(`Can take value from props`, (): void => {
|
|
9
|
-
const onEndMock = jest.fn();
|
|
10
|
-
const partialInputMock = jest.fn();
|
|
11
|
-
let callbackInput: () => void;
|
|
12
|
-
const TEST_ID = `invisible-number-input-test-id`;
|
|
13
|
-
const startValue = `24`;
|
|
14
|
-
|
|
15
|
-
const NumberInput = render(
|
|
16
|
-
<InvisibleNumberInput
|
|
17
|
-
negativeAllowed={false}
|
|
18
|
-
cleanPartialInput={true}
|
|
19
|
-
decimalPlaces={0}
|
|
20
|
-
onEnd={onEndMock}
|
|
21
|
-
partialInput={partialInputMock}
|
|
22
|
-
visible={(e): (() => void) => (callbackInput = e)}
|
|
23
|
-
startValue={startValue}
|
|
24
|
-
testID={TEST_ID}
|
|
25
|
-
/>,
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
callbackInput?.();
|
|
30
|
-
|
|
31
|
-
const textInput = NumberInput.getByTestId(TEST_ID);
|
|
32
|
-
fireEvent(textInput, `onEndEditing`);
|
|
33
|
-
expect(partialInputMock).not.toBeCalled();
|
|
34
|
-
expect(onEndMock).toBeCalledWith(Number(startValue));
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test(`Default startValue is 0`, (): void => {
|
|
38
|
-
const onEndMock = jest.fn();
|
|
39
|
-
const partialInputMock = jest.fn();
|
|
40
|
-
let callbackInput: () => void;
|
|
41
|
-
const TEST_ID = `invisible-number-input-test-id`;
|
|
42
|
-
|
|
43
|
-
const NumberInput = render(
|
|
44
|
-
<InvisibleNumberInput
|
|
45
|
-
negativeAllowed={false}
|
|
46
|
-
cleanPartialInput={true}
|
|
47
|
-
decimalPlaces={0}
|
|
48
|
-
onEnd={onEndMock}
|
|
49
|
-
partialInput={partialInputMock}
|
|
50
|
-
visible={(e): (() => void) => (callbackInput = e)}
|
|
51
|
-
testID={TEST_ID}
|
|
52
|
-
/>,
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
// @ts-ignore
|
|
56
|
-
callbackInput?.();
|
|
57
|
-
|
|
58
|
-
const textInput = NumberInput.getByTestId(TEST_ID);
|
|
59
|
-
fireEvent(textInput, `onEndEditing`);
|
|
60
|
-
expect(partialInputMock).not.toBeCalled();
|
|
61
|
-
expect(onEndMock).toBeCalledWith(0);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test.each`
|
|
65
|
-
input | result
|
|
66
|
-
${``} | ${0}
|
|
67
|
-
${`A`} | ${0}
|
|
68
|
-
${`Z`} | ${0}
|
|
69
|
-
${`Ø`} | ${0}
|
|
70
|
-
${`INVALID`} | ${0}
|
|
71
|
-
${`123A`} | ${0}
|
|
72
|
-
`(`Invalid number: $input returns $result`, ({ input, result }: { input: string; result: number }): void => {
|
|
73
|
-
const onEndMock = jest.fn();
|
|
74
|
-
const partialInputMock = jest.fn();
|
|
75
|
-
let callbackInput: () => void;
|
|
76
|
-
const TEST_ID = `invisible-number-input-test-id`;
|
|
77
|
-
|
|
78
|
-
const NumberInput = render(
|
|
79
|
-
<InvisibleNumberInput
|
|
80
|
-
negativeAllowed={false}
|
|
81
|
-
cleanPartialInput={true}
|
|
82
|
-
decimalPlaces={0}
|
|
83
|
-
onEnd={onEndMock}
|
|
84
|
-
partialInput={partialInputMock}
|
|
85
|
-
visible={(e): (() => void) => (callbackInput = e)}
|
|
86
|
-
testID={TEST_ID}
|
|
87
|
-
/>,
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
// @ts-ignore
|
|
91
|
-
callbackInput?.();
|
|
92
|
-
|
|
93
|
-
const textInput = NumberInput.getByTestId(TEST_ID);
|
|
94
|
-
fireEvent(textInput, `onChangeText`, input);
|
|
95
|
-
expect(partialInputMock).toBeCalledWith(`${result}`);
|
|
96
|
-
expect(onEndMock).not.toBeCalled();
|
|
97
|
-
fireEvent(textInput, `onEndEditing`);
|
|
98
|
-
expect(onEndMock).toBeCalledWith(result);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
test(`Will send events when typing`, (): void => {
|
|
102
|
-
const onEndMock = jest.fn();
|
|
103
|
-
const partialInputMock = jest.fn();
|
|
104
|
-
let callbackInput: () => void;
|
|
105
|
-
const TEST_ID = `invisible-number-input-test-id`;
|
|
106
|
-
|
|
107
|
-
const NumberInput = render(
|
|
108
|
-
<InvisibleNumberInput
|
|
109
|
-
negativeAllowed={false}
|
|
110
|
-
cleanPartialInput={true}
|
|
111
|
-
decimalPlaces={0}
|
|
112
|
-
onEnd={onEndMock}
|
|
113
|
-
partialInput={partialInputMock}
|
|
114
|
-
visible={(e): (() => void) => (callbackInput = e)}
|
|
115
|
-
testID={TEST_ID}
|
|
116
|
-
/>,
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
// @ts-ignore
|
|
120
|
-
callbackInput?.();
|
|
121
|
-
|
|
122
|
-
const textInput = NumberInput.getByTestId(TEST_ID);
|
|
123
|
-
fireEvent.changeText(textInput, `22`);
|
|
124
|
-
expect(partialInputMock).toBeCalledWith(`22`);
|
|
125
|
-
expect(onEndMock).not.toBeCalled();
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
interface INumberParams {
|
|
129
|
-
startValue: string;
|
|
130
|
-
decimals: number;
|
|
131
|
-
expected: string;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
test.each`
|
|
135
|
-
startValue | decimals | expected
|
|
136
|
-
${`1.2`} | ${0} | ${`1`}
|
|
137
|
-
${`1.9`} | ${0} | ${`2`}
|
|
138
|
-
${`1.24`} | ${1} | ${`1.2`}
|
|
139
|
-
${`1.25`} | ${1} | ${`1.3`}
|
|
140
|
-
${`1.26`} | ${1} | ${`1.3`}
|
|
141
|
-
${`24.55`} | ${2} | ${`24.55`}
|
|
142
|
-
${`24.55`} | ${1} | ${`24.6`}
|
|
143
|
-
${`24.5555`} | ${3} | ${`24.556`}
|
|
144
|
-
${`1.`} | ${1} | ${`1.0`}
|
|
145
|
-
${`2.`} | ${2} | ${`2.00`}
|
|
146
|
-
`(
|
|
147
|
-
`Will round $startValue to $decimals decimal places; === $expected`,
|
|
148
|
-
({ startValue, decimals, expected }: INumberParams): void => {
|
|
149
|
-
const onEndMock = jest.fn();
|
|
150
|
-
const partialInputMock = jest.fn();
|
|
151
|
-
let callbackInput: () => void;
|
|
152
|
-
const TEST_ID = `invisible-number-input-test-id`;
|
|
153
|
-
|
|
154
|
-
const NumberInput = render(
|
|
155
|
-
<InvisibleNumberInput
|
|
156
|
-
negativeAllowed={false}
|
|
157
|
-
cleanPartialInput={true}
|
|
158
|
-
decimalPlaces={decimals}
|
|
159
|
-
onEnd={onEndMock}
|
|
160
|
-
partialInput={partialInputMock}
|
|
161
|
-
visible={(e): (() => void) => (callbackInput = e)}
|
|
162
|
-
startValue={startValue}
|
|
163
|
-
testID={TEST_ID}
|
|
164
|
-
/>,
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
// @ts-ignore
|
|
168
|
-
callbackInput?.();
|
|
169
|
-
|
|
170
|
-
const textInput = NumberInput.getByTestId(TEST_ID);
|
|
171
|
-
fireEvent(textInput, `onChangeText`, startValue);
|
|
172
|
-
expect(partialInputMock).toBeCalledWith(`${expected}`);
|
|
173
|
-
},
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
test.each`
|
|
177
|
-
startValue | decimals | expected
|
|
178
|
-
${`1..2`} | ${0} | ${`1`}
|
|
179
|
-
${`1..9`} | ${0} | ${`1`}
|
|
180
|
-
${`7..24`} | ${1} | ${`7.0`}
|
|
181
|
-
${`1...25`} | ${1} | ${`1.0`}
|
|
182
|
-
${`5,.26`} | ${1} | ${`5.0`}
|
|
183
|
-
${`1.2.3`} | ${1} | ${`1.2`}
|
|
184
|
-
${`2,3,4`} | ${1} | ${`2.3`}
|
|
185
|
-
${`3.4,5`} | ${1} | ${`3.4`}
|
|
186
|
-
${`4,5.6`} | ${1} | ${`4.5`}
|
|
187
|
-
${`1.2.3`} | ${0} | ${`1`}
|
|
188
|
-
${`2,3,4`} | ${0} | ${`2`}
|
|
189
|
-
${`3.4,5`} | ${0} | ${`3`}
|
|
190
|
-
${`4,5.6`} | ${0} | ${`5`}
|
|
191
|
-
`(
|
|
192
|
-
`Will remove all non-digits of $startValue, format it to $decimals decimals; === $expected`,
|
|
193
|
-
({ startValue, decimals, expected }: INumberParams): void => {
|
|
194
|
-
const onEndMock = jest.fn();
|
|
195
|
-
const partialInputMock = jest.fn();
|
|
196
|
-
let callbackInput: () => void;
|
|
197
|
-
const TEST_ID = `invisible-number-input-test-id`;
|
|
198
|
-
|
|
199
|
-
const NumberInput = render(
|
|
200
|
-
<InvisibleNumberInput
|
|
201
|
-
negativeAllowed={false}
|
|
202
|
-
cleanPartialInput={true}
|
|
203
|
-
decimalPlaces={decimals}
|
|
204
|
-
onEnd={onEndMock}
|
|
205
|
-
partialInput={partialInputMock}
|
|
206
|
-
visible={(e): (() => void) => (callbackInput = e)}
|
|
207
|
-
startValue={startValue}
|
|
208
|
-
testID={TEST_ID}
|
|
209
|
-
/>,
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
// @ts-ignore
|
|
213
|
-
callbackInput?.();
|
|
214
|
-
|
|
215
|
-
const textInput = NumberInput.getByTestId(TEST_ID);
|
|
216
|
-
fireEvent(textInput, `onChangeText`, startValue);
|
|
217
|
-
expect(partialInputMock).toBeCalledWith(`${expected}`);
|
|
218
|
-
},
|
|
219
|
-
);
|
|
220
|
-
|
|
221
|
-
test.each`
|
|
222
|
-
startValue | decimals | expected
|
|
223
|
-
${`1..2`} | ${0} | ${`1.2`}
|
|
224
|
-
${`1..9`} | ${0} | ${`1.9`}
|
|
225
|
-
${`1..24`} | ${1} | ${`1.24`}
|
|
226
|
-
${`1...25`} | ${1} | ${`1.25`}
|
|
227
|
-
${`1,.26`} | ${1} | ${`1.26`}
|
|
228
|
-
`(`Not cleaning partialInput on $startValue`, ({ startValue, decimals, expected }: INumberParams): void => {
|
|
229
|
-
const onEndMock = jest.fn();
|
|
230
|
-
const partialInputMock = jest.fn();
|
|
231
|
-
let callbackInput: () => void;
|
|
232
|
-
const TEST_ID = `invisible-number-input-test-id`;
|
|
233
|
-
|
|
234
|
-
const NumberInput = render(
|
|
235
|
-
<InvisibleNumberInput
|
|
236
|
-
negativeAllowed={false}
|
|
237
|
-
cleanPartialInput={false}
|
|
238
|
-
decimalPlaces={decimals}
|
|
239
|
-
onEnd={onEndMock}
|
|
240
|
-
partialInput={partialInputMock}
|
|
241
|
-
visible={(e): (() => void) => (callbackInput = e)}
|
|
242
|
-
startValue={startValue}
|
|
243
|
-
testID={TEST_ID}
|
|
244
|
-
/>,
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
// @ts-ignore
|
|
248
|
-
callbackInput?.();
|
|
249
|
-
|
|
250
|
-
const textInput = NumberInput.getByTestId(TEST_ID);
|
|
251
|
-
fireEvent(textInput, `onChangeText`, startValue);
|
|
252
|
-
expect(partialInputMock).toBeCalledWith(expected);
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
test.each`
|
|
256
|
-
startValue | decimals | expected
|
|
257
|
-
${`-2`} | ${0} | ${-2}
|
|
258
|
-
${`-0.001`} | ${3} | ${-0.001}
|
|
259
|
-
${`-0.001`} | ${2} | ${0}
|
|
260
|
-
${`-10000`} | ${0} | ${-10000}
|
|
261
|
-
${`-0`} | ${0} | ${0}
|
|
262
|
-
`(
|
|
263
|
-
`Negative values allowed; $startValue with $decimals decimals should clean to: $expected`,
|
|
264
|
-
({ startValue, decimals, expected }: INumberParams & { expected: number }): void => {
|
|
265
|
-
const onEndMock = jest.fn();
|
|
266
|
-
const partialInputMock = jest.fn();
|
|
267
|
-
let callbackInput: () => void;
|
|
268
|
-
const TEST_ID = `invisible-number-input-test-id`;
|
|
269
|
-
|
|
270
|
-
const NumberInput = render(
|
|
271
|
-
<InvisibleNumberInput
|
|
272
|
-
negativeAllowed={true}
|
|
273
|
-
cleanPartialInput={false}
|
|
274
|
-
decimalPlaces={decimals}
|
|
275
|
-
onEnd={onEndMock}
|
|
276
|
-
partialInput={partialInputMock}
|
|
277
|
-
visible={(e): (() => void) => (callbackInput = e)}
|
|
278
|
-
startValue={startValue}
|
|
279
|
-
testID={TEST_ID}
|
|
280
|
-
/>,
|
|
281
|
-
);
|
|
282
|
-
|
|
283
|
-
// @ts-ignore
|
|
284
|
-
callbackInput?.();
|
|
285
|
-
|
|
286
|
-
const textInput = NumberInput.getByTestId(TEST_ID);
|
|
287
|
-
fireEvent(textInput, `onChangeText`, startValue);
|
|
288
|
-
expect(partialInputMock).toBeCalledWith(startValue);
|
|
289
|
-
|
|
290
|
-
fireEvent(textInput, `onEndEditing`, startValue);
|
|
291
|
-
expect(onEndMock).toBeCalledWith(expected);
|
|
292
|
-
},
|
|
293
|
-
);
|
|
294
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { BolusCalculator, Languages } from "@hedia/types";
|
|
2
|
-
import { I18nProvider } from "@lingui/react";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { cleanup, fireEvent, render } from "react-native-testing-library";
|
|
5
|
-
import LimitationMessage, { ILimitationMessageProps } from "../../components/LimitationMessage";
|
|
6
|
-
import { i18n } from "../../locale/i18nUtils";
|
|
7
|
-
import { LimitationMessageTestIds } from "../../types/enum";
|
|
8
|
-
import { Messages } from "../../utils/AttentionMessages";
|
|
9
|
-
import { expectTextExists } from "../utils";
|
|
10
|
-
|
|
11
|
-
const SAFETY_INSULIN_LIMIT = BolusCalculator.Constants.SAFETY_INSULIN_LIMIT;
|
|
12
|
-
|
|
13
|
-
describe(`Info Bars Component`, (): void => {
|
|
14
|
-
afterEach(cleanup);
|
|
15
|
-
beforeEach((): void => {
|
|
16
|
-
i18n.activate(Languages.en);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test(`Can call the callback`, (): void => {
|
|
20
|
-
const onPressNextButton = jest.fn();
|
|
21
|
-
const props: ILimitationMessageProps = {
|
|
22
|
-
limitationMessage: Messages.RecommendationWasLimited(),
|
|
23
|
-
onPressNextButton,
|
|
24
|
-
};
|
|
25
|
-
const limitationMessage = render(<LimitationMessage {...props} />);
|
|
26
|
-
const nextButton = limitationMessage.getByTestId(LimitationMessageTestIds.OkButton);
|
|
27
|
-
|
|
28
|
-
fireEvent(nextButton, `onPress`);
|
|
29
|
-
expect(onPressNextButton).toBeCalled();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test.each`
|
|
33
|
-
language | locale | message
|
|
34
|
-
${`English`} | ${Languages.en} | ${`Your recommendation would have been higher than ${SAFETY_INSULIN_LIMIT} units of insulin, but it has been limited for safety reasons. Hedia never recommends more than ${SAFETY_INSULIN_LIMIT} units of insulin per calculation.`}
|
|
35
|
-
${`Danish`} | ${Languages.da} | ${`Din anbefaling ville have været højere end ${SAFETY_INSULIN_LIMIT} units af insulin, men den er blevet begrænset af sikkerhedshensyn. Hedia anbefaler aldrig mere end ${SAFETY_INSULIN_LIMIT} units af insulin per beregning.`}
|
|
36
|
-
${`German`} | ${Languages.de} | ${`Ihre Empfehlung wäre höher als ${SAFETY_INSULIN_LIMIT} Einheiten Insulin gewesen, aber sie wurde aus Sicherheitsgründen begrenzt. Hedia empfiehlt nie mehr als ${SAFETY_INSULIN_LIMIT} Einheiten Insulin pro Berechnung.`}
|
|
37
|
-
${`Spanish`} | ${Languages.es} | ${`Su recomendación habría sido superior a ${SAFETY_INSULIN_LIMIT} unidades de insulina, pero se ha limitado por razones de seguridad. Hedia nunca recomienda más de ${SAFETY_INSULIN_LIMIT} unidades de insulina por calculación.`}
|
|
38
|
-
${`Italian`} | ${Languages.it} | ${`La tua prescrizione sarebbe stata superiore a ${SAFETY_INSULIN_LIMIT} unità di insulina, ma è stata limitata per motivi di sicurezza. Hedia non prescrive mai più di ${SAFETY_INSULIN_LIMIT} unità di insulina per calcolo.`}
|
|
39
|
-
${`French`} | ${Languages.fr} | ${`Votre recommandation aurait été supérieure à ${SAFETY_INSULIN_LIMIT} unités d’insuline, mais elle a été limitée pour des raisons de sécurité. Hedia ne recommande jamais plus de ${SAFETY_INSULIN_LIMIT} unités d’insuline par calcul.`}
|
|
40
|
-
`(
|
|
41
|
-
`Can display limitation message in $language`,
|
|
42
|
-
({ message, locale }: { locale: Languages; message: string }): void => {
|
|
43
|
-
i18n.activate(locale);
|
|
44
|
-
const onPressNextButton = jest.fn();
|
|
45
|
-
const props: ILimitationMessageProps = {
|
|
46
|
-
limitationMessage: Messages.RecommendationWasLimited(),
|
|
47
|
-
onPressNextButton,
|
|
48
|
-
};
|
|
49
|
-
const limitationMessage = render(
|
|
50
|
-
<I18nProvider language={locale} i18n={i18n}>
|
|
51
|
-
<LimitationMessage {...props} />,
|
|
52
|
-
</I18nProvider>,
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
expectTextExists(limitationMessage, message);
|
|
56
|
-
},
|
|
57
|
-
);
|
|
58
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Logbook } from "@hedia/types";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { cleanup, fireEvent, render } from "react-native-testing-library";
|
|
4
|
-
import { ReactTestInstance } from "react-test-renderer";
|
|
5
|
-
import MoodIcon from "../../components/mood/MoodIcon";
|
|
6
|
-
|
|
7
|
-
const MoodEnum = Logbook.Enums.MoodEnum;
|
|
8
|
-
|
|
9
|
-
describe(`MoodIcon - Component`, (): void => {
|
|
10
|
-
afterEach(cleanup);
|
|
11
|
-
|
|
12
|
-
test.each`
|
|
13
|
-
mood | moodName
|
|
14
|
-
${MoodEnum.Happy} | ${MoodEnum[MoodEnum.Happy]}
|
|
15
|
-
${MoodEnum.SemiHappy} | ${MoodEnum[MoodEnum.SemiHappy]}
|
|
16
|
-
${MoodEnum.Neutral} | ${MoodEnum[MoodEnum.Neutral]}
|
|
17
|
-
${MoodEnum.SemiSad} | ${MoodEnum[MoodEnum.SemiSad]}
|
|
18
|
-
${MoodEnum.Sad} | ${MoodEnum[MoodEnum.Sad]}
|
|
19
|
-
`(
|
|
20
|
-
`Mounting $moodName smiley is mounted inactive and can be toggled on`,
|
|
21
|
-
({ mood, moodName }: { mood: Logbook.Enums.MoodEnum; moodName: string }): void => {
|
|
22
|
-
let active = false;
|
|
23
|
-
const onPressMock = jest.fn((toggle): boolean => (active = toggle));
|
|
24
|
-
const wrapper = render(<MoodIcon active={active} mood={mood} onPress={onPressMock} />);
|
|
25
|
-
|
|
26
|
-
const getButton = (isActive: boolean): ReactTestInstance | null =>
|
|
27
|
-
wrapper.getByA11yLabel(`${moodName}_${isActive}`);
|
|
28
|
-
|
|
29
|
-
const button = getButton(false);
|
|
30
|
-
|
|
31
|
-
if (button === null) {
|
|
32
|
-
return fail(`No button found for getByA11yLabel: ${moodName}_${false}`);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
fireEvent(button, `onPress`);
|
|
36
|
-
|
|
37
|
-
expect(onPressMock).toBeCalledWith(true);
|
|
38
|
-
expect(active).toBe(true);
|
|
39
|
-
|
|
40
|
-
wrapper.rerender(<MoodIcon active={active} mood={mood} onPress={onPressMock} />);
|
|
41
|
-
|
|
42
|
-
expect(getButton(true)).not.toBeNull();
|
|
43
|
-
},
|
|
44
|
-
);
|
|
45
|
-
});
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import { Languages } from "@hedia/types";
|
|
2
|
-
import { I18nProvider } from "@lingui/react";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { cleanup, fireEvent, render } from "react-native-testing-library";
|
|
5
|
-
import RecommendationModal from "../../components/RecommendationModal";
|
|
6
|
-
import { i18n } from "../../locale/i18nUtils";
|
|
7
|
-
import { LimitationMessageTestIds, RecommendationModalTestIds } from "../../types/enum";
|
|
8
|
-
import { Messages } from "../../utils/AttentionMessages";
|
|
9
|
-
import { expectTextExists, expectTextNotExists } from "../utils";
|
|
10
|
-
|
|
11
|
-
describe(`RecommendationModal Component`, (): void => {
|
|
12
|
-
afterEach(cleanup);
|
|
13
|
-
beforeEach((): void => {
|
|
14
|
-
i18n.activate(Languages.en);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test(`start display with the second page`, (): void => {
|
|
18
|
-
const acceptMock = jest.fn();
|
|
19
|
-
const declineMock = jest.fn();
|
|
20
|
-
const onClickOkMock = jest.fn();
|
|
21
|
-
const wrapper = render(
|
|
22
|
-
<RecommendationModal
|
|
23
|
-
isVisible={true}
|
|
24
|
-
attentionMessage={null}
|
|
25
|
-
limitationMessage={null}
|
|
26
|
-
suggestedCarbohydrates={2}
|
|
27
|
-
onClickOkButton={onClickOkMock}
|
|
28
|
-
onAcceptCarbohydrates={acceptMock}
|
|
29
|
-
onDeclineCarbohydrates={declineMock}
|
|
30
|
-
/>,
|
|
31
|
-
);
|
|
32
|
-
expectTextExists(wrapper, `We recommend eating an additional:`);
|
|
33
|
-
expectTextExists(wrapper, `2 `);
|
|
34
|
-
expectTextExists(wrapper, `grams of carbohydrates`);
|
|
35
|
-
expectTextExists(wrapper, `Instead of taking insulin`);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test(`accept carbs from second page`, (): void => {
|
|
39
|
-
const acceptMock = jest.fn();
|
|
40
|
-
const declineMock = jest.fn();
|
|
41
|
-
const onClickOkMock = jest.fn();
|
|
42
|
-
const wrapper = render(
|
|
43
|
-
<RecommendationModal
|
|
44
|
-
isVisible={true}
|
|
45
|
-
attentionMessage={null}
|
|
46
|
-
limitationMessage={null}
|
|
47
|
-
suggestedCarbohydrates={5}
|
|
48
|
-
onClickOkButton={onClickOkMock}
|
|
49
|
-
onAcceptCarbohydrates={acceptMock}
|
|
50
|
-
onDeclineCarbohydrates={declineMock}
|
|
51
|
-
/>,
|
|
52
|
-
);
|
|
53
|
-
expectTextExists(wrapper, `We recommend eating an additional:`);
|
|
54
|
-
expectTextExists(wrapper, `5 `);
|
|
55
|
-
expectTextExists(wrapper, `grams of carbohydrates`);
|
|
56
|
-
const yesButtonModal = wrapper.getByTestId(RecommendationModalTestIds.AcceptCarbs);
|
|
57
|
-
fireEvent(yesButtonModal, `onPress`);
|
|
58
|
-
expect(acceptMock).toBeCalled();
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test(`decline carbs from second page`, (): void => {
|
|
62
|
-
const acceptMock = jest.fn();
|
|
63
|
-
const declineMock = jest.fn();
|
|
64
|
-
const onClickOkMock = jest.fn();
|
|
65
|
-
const wrapper = render(
|
|
66
|
-
<RecommendationModal
|
|
67
|
-
isVisible={true}
|
|
68
|
-
attentionMessage={null}
|
|
69
|
-
limitationMessage={null}
|
|
70
|
-
suggestedCarbohydrates={5}
|
|
71
|
-
onClickOkButton={onClickOkMock}
|
|
72
|
-
onAcceptCarbohydrates={acceptMock}
|
|
73
|
-
onDeclineCarbohydrates={declineMock}
|
|
74
|
-
/>,
|
|
75
|
-
);
|
|
76
|
-
expectTextExists(wrapper, `We recommend eating an additional:`);
|
|
77
|
-
expectTextExists(wrapper, `grams of carbohydrates`);
|
|
78
|
-
const noButtonModal = wrapper.getByTestId(RecommendationModalTestIds.DeclineCarbs);
|
|
79
|
-
fireEvent(noButtonModal, `onPress`);
|
|
80
|
-
expect(declineMock).toBeCalled();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test(`test opens with first page and navigate to second`, (): void => {
|
|
84
|
-
const acceptMock = jest.fn();
|
|
85
|
-
const declineMock = jest.fn();
|
|
86
|
-
const onClickOkMock = jest.fn();
|
|
87
|
-
const limitation = Messages.RecommendationWasLimited();
|
|
88
|
-
const attention = Messages.VeryLowBGL();
|
|
89
|
-
|
|
90
|
-
const wrapper = render(
|
|
91
|
-
<RecommendationModal
|
|
92
|
-
isVisible={true}
|
|
93
|
-
attentionMessage={attention}
|
|
94
|
-
limitationMessage={limitation}
|
|
95
|
-
suggestedCarbohydrates={0}
|
|
96
|
-
onClickOkButton={onClickOkMock}
|
|
97
|
-
onAcceptCarbohydrates={acceptMock}
|
|
98
|
-
onDeclineCarbohydrates={declineMock}
|
|
99
|
-
/>,
|
|
100
|
-
);
|
|
101
|
-
expectTextExists(wrapper, limitation);
|
|
102
|
-
expectTextExists(wrapper, `OK`);
|
|
103
|
-
const nextButton = wrapper.getByTestId(LimitationMessageTestIds.OkButton);
|
|
104
|
-
fireEvent(nextButton, `onPress`);
|
|
105
|
-
expectTextExists(wrapper, attention);
|
|
106
|
-
expectTextExists(wrapper, `OK`);
|
|
107
|
-
expectTextNotExists(wrapper, `We recommend eating an additional:`);
|
|
108
|
-
const okayButton = wrapper.getByTestId(RecommendationModalTestIds.OkButton);
|
|
109
|
-
fireEvent(okayButton, `onPress`);
|
|
110
|
-
expect(onClickOkMock).toBeCalled();
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
test(`close modal from first page if ther are no carbs or attention messages on second page`, (): void => {
|
|
114
|
-
const acceptMock = jest.fn();
|
|
115
|
-
const declineMock = jest.fn();
|
|
116
|
-
const onClickOkMock = jest.fn();
|
|
117
|
-
const limitation = Messages.RecommendationWasLimited();
|
|
118
|
-
const wrapper = render(
|
|
119
|
-
<RecommendationModal
|
|
120
|
-
isVisible={true}
|
|
121
|
-
attentionMessage={null}
|
|
122
|
-
limitationMessage={limitation}
|
|
123
|
-
suggestedCarbohydrates={0}
|
|
124
|
-
onClickOkButton={onClickOkMock}
|
|
125
|
-
onAcceptCarbohydrates={acceptMock}
|
|
126
|
-
onDeclineCarbohydrates={declineMock}
|
|
127
|
-
/>,
|
|
128
|
-
);
|
|
129
|
-
expectTextExists(wrapper, limitation);
|
|
130
|
-
expectTextExists(wrapper, `OK`);
|
|
131
|
-
const nextButton = wrapper.getByTestId(LimitationMessageTestIds.OkButton);
|
|
132
|
-
fireEvent(nextButton, `onPress`);
|
|
133
|
-
expect(onClickOkMock).toBeCalled();
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
test.each`
|
|
137
|
-
language | locale | message
|
|
138
|
-
${`English`} | ${Languages.en} | ${`We recommend eating an additional:`}
|
|
139
|
-
${`Danish`} | ${Languages.da} | ${`Vi anbefaler at spise yderligere:`}
|
|
140
|
-
${`German`} | ${Languages.de} | ${`Wir empfehlen Ihnen, zusätzlich Folgendes zu essen:`}
|
|
141
|
-
${`Spanish`} | ${Languages.es} | ${`Recomendamos comer adicionalmente:`}
|
|
142
|
-
${`Italian`} | ${Languages.it} | ${`Consigliamo di ingerire una quantità supplementare:`}
|
|
143
|
-
${`French`} | ${Languages.fr} | ${`Nous vous recommandons de manger en plus :`}
|
|
144
|
-
`(
|
|
145
|
-
`Modal renders attention messages in $language`,
|
|
146
|
-
({ message, locale }: { locale: Languages; message: string }): void => {
|
|
147
|
-
i18n.activate(locale);
|
|
148
|
-
const acceptMock = jest.fn();
|
|
149
|
-
const declineMock = jest.fn();
|
|
150
|
-
const onClickOkMock = jest.fn();
|
|
151
|
-
const wrapper = render(
|
|
152
|
-
<I18nProvider language={locale} i18n={i18n}>
|
|
153
|
-
<RecommendationModal
|
|
154
|
-
isVisible={true}
|
|
155
|
-
attentionMessage={null}
|
|
156
|
-
limitationMessage={null}
|
|
157
|
-
suggestedCarbohydrates={2}
|
|
158
|
-
onClickOkButton={onClickOkMock}
|
|
159
|
-
onAcceptCarbohydrates={acceptMock}
|
|
160
|
-
onDeclineCarbohydrates={declineMock}
|
|
161
|
-
/>
|
|
162
|
-
,
|
|
163
|
-
</I18nProvider>,
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
expectTextExists(wrapper, message);
|
|
167
|
-
},
|
|
168
|
-
);
|
|
169
|
-
});
|