@hedia/recommendation-screen 2.1.3-beta.6 → 2.1.3

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.
Files changed (88) hide show
  1. package/coverage/clover.xml +29 -29
  2. package/coverage/coverage-final.json +27 -27
  3. package/coverage/lcov-report/index.html +1 -1
  4. package/coverage/lcov-report/src/RecommendationScreen.tsx.html +1 -1
  5. package/coverage/lcov-report/src/__tests__/index.html +1 -1
  6. package/coverage/lcov-report/src/__tests__/utils.tsx.html +1 -1
  7. package/coverage/lcov-report/src/components/Header.tsx.html +1 -1
  8. package/coverage/lcov-report/src/components/InfoBars.tsx.html +1 -1
  9. package/coverage/lcov-report/src/components/InvisibleNumberInput.tsx.html +1 -1
  10. package/coverage/lcov-report/src/components/LimitationMessage.tsx.html +1 -1
  11. package/coverage/lcov-report/src/components/LineSeparator.tsx.html +1 -1
  12. package/coverage/lcov-report/src/components/RecentInsulin.tsx.html +1 -1
  13. package/coverage/lcov-report/src/components/RecommendationModal.tsx.html +1 -1
  14. package/coverage/lcov-report/src/components/RecommendedCarbs.tsx.html +1 -1
  15. package/coverage/lcov-report/src/components/RecommendedInsulin.tsx.html +1 -1
  16. package/coverage/lcov-report/src/components/Remeasure.tsx.html +1 -1
  17. package/coverage/lcov-report/src/components/TransferToLogbook.tsx.html +1 -1
  18. package/coverage/lcov-report/src/components/TwoOptionModal.tsx.html +1 -1
  19. package/coverage/lcov-report/src/components/activity/Activity.tsx.html +1 -1
  20. package/coverage/lcov-report/src/components/activity/ActivityIcon.tsx.html +1 -1
  21. package/coverage/lcov-report/src/components/activity/ActivityIntensity.tsx.html +1 -1
  22. package/coverage/lcov-report/src/components/activity/index.html +1 -1
  23. package/coverage/lcov-report/src/components/index.html +1 -1
  24. package/coverage/lcov-report/src/components/mood/Emotion.tsx.html +1 -1
  25. package/coverage/lcov-report/src/components/mood/MoodIcon.tsx.html +1 -1
  26. package/coverage/lcov-report/src/components/mood/index.html +1 -1
  27. package/coverage/lcov-report/src/index.html +1 -1
  28. package/coverage/lcov-report/src/locale/i18nUtils.ts.html +1 -1
  29. package/coverage/lcov-report/src/locale/index.html +1 -1
  30. package/coverage/lcov-report/src/utils/AttentionMessages.tsx.html +1 -1
  31. package/coverage/lcov-report/src/utils/Constants.ts.html +1 -1
  32. package/coverage/lcov-report/src/utils/RecommendationError.tsx.html +1 -1
  33. package/coverage/lcov-report/src/utils/RecommendationUtils.ts.html +1 -1
  34. package/coverage/lcov-report/src/utils/Translations.ts.html +1 -1
  35. package/coverage/lcov-report/src/utils/Utils.ts.html +1 -1
  36. package/coverage/lcov-report/src/utils/Validations.ts.html +1 -1
  37. package/coverage/lcov-report/src/utils/index.html +1 -1
  38. package/index.js +5 -31
  39. package/package.json +1 -1
  40. package/src/RecommendationScreen.js +76 -101
  41. package/src/__tests__/RecommendationScreen.test.js +404 -409
  42. package/src/__tests__/RecommendationUtils.test.js +117 -119
  43. package/src/__tests__/Translate.test.js +14 -16
  44. package/src/__tests__/Utils.test.js +16 -18
  45. package/src/__tests__/Validations.test.js +30 -51
  46. package/src/__tests__/components/Activity.test.js +51 -56
  47. package/src/__tests__/components/Emotion.test.js +28 -33
  48. package/src/__tests__/components/Header.test.js +24 -29
  49. package/src/__tests__/components/InfoBars.test.js +59 -64
  50. package/src/__tests__/components/InvisibleNumberInput.test.js +22 -27
  51. package/src/__tests__/components/LimitationMessage.test.js +28 -33
  52. package/src/__tests__/components/MoodIcon.test.js +9 -14
  53. package/src/__tests__/components/RecommendationModal.test.js +56 -61
  54. package/src/__tests__/components/RecommendedCarbs.test.js +58 -63
  55. package/src/__tests__/components/RecommendedInsulin.test.js +60 -65
  56. package/src/__tests__/components/Remeasure.test.js +32 -37
  57. package/src/__tests__/components/TransferToLogbook.test.js +15 -20
  58. package/src/__tests__/components/TwoOptionModal.test.js +22 -27
  59. package/src/__tests__/utils.js +22 -38
  60. package/src/components/Header.js +34 -41
  61. package/src/components/Icon.js +2 -8
  62. package/src/components/InfoBars.js +36 -43
  63. package/src/components/InvisibleNumberInput.js +5 -11
  64. package/src/components/LimitationMessage.js +18 -40
  65. package/src/components/LineSeparator.js +7 -13
  66. package/src/components/RecentInsulin.js +33 -39
  67. package/src/components/RecommendationModal.js +59 -85
  68. package/src/components/RecommendedCarbs.js +93 -99
  69. package/src/components/RecommendedInsulin.js +46 -52
  70. package/src/components/Remeasure.js +36 -42
  71. package/src/components/TransferToLogbook.js +20 -26
  72. package/src/components/TwoOptionModal.js +39 -65
  73. package/src/components/activity/Activity.js +42 -48
  74. package/src/components/activity/ActivityIcon.js +15 -21
  75. package/src/components/activity/ActivityIntensity.js +19 -25
  76. package/src/components/mood/Emotion.js +17 -23
  77. package/src/components/mood/MoodIcon.js +11 -17
  78. package/src/locale/i18nUtils.js +17 -24
  79. package/src/types/enum.js +28 -31
  80. package/src/types/types.js +1 -2
  81. package/src/utils/AttentionMessages.js +24 -32
  82. package/src/utils/Constants.js +23 -26
  83. package/src/utils/RecommendationError.js +28 -54
  84. package/src/utils/RecommendationUtils.js +60 -72
  85. package/src/utils/Translations.js +6 -9
  86. package/src/utils/Utils.js +8 -12
  87. package/src/utils/Validations.js +77 -107
  88. package/tsconfig.json +3 -3
@@ -1,24 +1,19 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const react_1 = __importDefault(require("react"));
7
- const react_native_testing_library_1 = require("react-native-testing-library");
8
- const InvisibleNumberInput_1 = __importDefault(require("../../components/InvisibleNumberInput"));
1
+ import React from "react";
2
+ import { cleanup, fireEvent, render } from "react-native-testing-library";
3
+ import InvisibleNumberInput from "../../components/InvisibleNumberInput";
9
4
  describe(`InvisibleNumberInput Component`, () => {
10
- afterEach(react_native_testing_library_1.cleanup);
5
+ afterEach(cleanup);
11
6
  test(`Can take value from props`, () => {
12
7
  const onEndMock = jest.fn();
13
8
  const partialInputMock = jest.fn();
14
9
  let callbackInput;
15
10
  const TEST_ID = `invisible-number-input-test-id`;
16
11
  const startValue = `24`;
17
- const NumberInput = react_native_testing_library_1.render(<InvisibleNumberInput_1.default negativeAllowed={false} cleanPartialInput={true} decimalPlaces={0} onEnd={onEndMock} partialInput={partialInputMock} visible={(e) => (callbackInput = e)} startValue={startValue} testID={TEST_ID}/>);
12
+ const NumberInput = render(<InvisibleNumberInput negativeAllowed={false} cleanPartialInput={true} decimalPlaces={0} onEnd={onEndMock} partialInput={partialInputMock} visible={(e) => (callbackInput = e)} startValue={startValue} testID={TEST_ID}/>);
18
13
  // @ts-ignore
19
14
  callbackInput?.();
20
15
  const textInput = NumberInput.getByTestId(TEST_ID);
21
- react_native_testing_library_1.fireEvent(textInput, `onEndEditing`);
16
+ fireEvent(textInput, `onEndEditing`);
22
17
  expect(partialInputMock).not.toBeCalled();
23
18
  expect(onEndMock).toBeCalledWith(Number(startValue));
24
19
  });
@@ -27,11 +22,11 @@ describe(`InvisibleNumberInput Component`, () => {
27
22
  const partialInputMock = jest.fn();
28
23
  let callbackInput;
29
24
  const TEST_ID = `invisible-number-input-test-id`;
30
- const NumberInput = react_native_testing_library_1.render(<InvisibleNumberInput_1.default negativeAllowed={false} cleanPartialInput={true} decimalPlaces={0} onEnd={onEndMock} partialInput={partialInputMock} visible={(e) => (callbackInput = e)} testID={TEST_ID}/>);
25
+ const NumberInput = render(<InvisibleNumberInput negativeAllowed={false} cleanPartialInput={true} decimalPlaces={0} onEnd={onEndMock} partialInput={partialInputMock} visible={(e) => (callbackInput = e)} testID={TEST_ID}/>);
31
26
  // @ts-ignore
32
27
  callbackInput?.();
33
28
  const textInput = NumberInput.getByTestId(TEST_ID);
34
- react_native_testing_library_1.fireEvent(textInput, `onEndEditing`);
29
+ fireEvent(textInput, `onEndEditing`);
35
30
  expect(partialInputMock).not.toBeCalled();
36
31
  expect(onEndMock).toBeCalledWith(0);
37
32
  });
@@ -48,14 +43,14 @@ describe(`InvisibleNumberInput Component`, () => {
48
43
  const partialInputMock = jest.fn();
49
44
  let callbackInput;
50
45
  const TEST_ID = `invisible-number-input-test-id`;
51
- const NumberInput = react_native_testing_library_1.render(<InvisibleNumberInput_1.default negativeAllowed={false} cleanPartialInput={true} decimalPlaces={0} onEnd={onEndMock} partialInput={partialInputMock} visible={(e) => (callbackInput = e)} testID={TEST_ID}/>);
46
+ const NumberInput = render(<InvisibleNumberInput negativeAllowed={false} cleanPartialInput={true} decimalPlaces={0} onEnd={onEndMock} partialInput={partialInputMock} visible={(e) => (callbackInput = e)} testID={TEST_ID}/>);
52
47
  // @ts-ignore
53
48
  callbackInput?.();
54
49
  const textInput = NumberInput.getByTestId(TEST_ID);
55
- react_native_testing_library_1.fireEvent(textInput, `onChangeText`, input);
50
+ fireEvent(textInput, `onChangeText`, input);
56
51
  expect(partialInputMock).toBeCalledWith(`${result}`);
57
52
  expect(onEndMock).not.toBeCalled();
58
- react_native_testing_library_1.fireEvent(textInput, `onEndEditing`);
53
+ fireEvent(textInput, `onEndEditing`);
59
54
  expect(onEndMock).toBeCalledWith(result);
60
55
  });
61
56
  test(`Will send events when typing`, () => {
@@ -63,11 +58,11 @@ describe(`InvisibleNumberInput Component`, () => {
63
58
  const partialInputMock = jest.fn();
64
59
  let callbackInput;
65
60
  const TEST_ID = `invisible-number-input-test-id`;
66
- const NumberInput = react_native_testing_library_1.render(<InvisibleNumberInput_1.default negativeAllowed={false} cleanPartialInput={true} decimalPlaces={0} onEnd={onEndMock} partialInput={partialInputMock} visible={(e) => (callbackInput = e)} testID={TEST_ID}/>);
61
+ const NumberInput = render(<InvisibleNumberInput negativeAllowed={false} cleanPartialInput={true} decimalPlaces={0} onEnd={onEndMock} partialInput={partialInputMock} visible={(e) => (callbackInput = e)} testID={TEST_ID}/>);
67
62
  // @ts-ignore
68
63
  callbackInput?.();
69
64
  const textInput = NumberInput.getByTestId(TEST_ID);
70
- react_native_testing_library_1.fireEvent.changeText(textInput, `22`);
65
+ fireEvent.changeText(textInput, `22`);
71
66
  expect(partialInputMock).toBeCalledWith(`22`);
72
67
  expect(onEndMock).not.toBeCalled();
73
68
  });
@@ -88,11 +83,11 @@ describe(`InvisibleNumberInput Component`, () => {
88
83
  const partialInputMock = jest.fn();
89
84
  let callbackInput;
90
85
  const TEST_ID = `invisible-number-input-test-id`;
91
- const NumberInput = react_native_testing_library_1.render(<InvisibleNumberInput_1.default negativeAllowed={false} cleanPartialInput={true} decimalPlaces={decimals} onEnd={onEndMock} partialInput={partialInputMock} visible={(e) => (callbackInput = e)} startValue={startValue} testID={TEST_ID}/>);
86
+ const NumberInput = render(<InvisibleNumberInput negativeAllowed={false} cleanPartialInput={true} decimalPlaces={decimals} onEnd={onEndMock} partialInput={partialInputMock} visible={(e) => (callbackInput = e)} startValue={startValue} testID={TEST_ID}/>);
92
87
  // @ts-ignore
93
88
  callbackInput?.();
94
89
  const textInput = NumberInput.getByTestId(TEST_ID);
95
- react_native_testing_library_1.fireEvent(textInput, `onChangeText`, startValue);
90
+ fireEvent(textInput, `onChangeText`, startValue);
96
91
  expect(partialInputMock).toBeCalledWith(`${expected}`);
97
92
  });
98
93
  test.each `
@@ -115,11 +110,11 @@ describe(`InvisibleNumberInput Component`, () => {
115
110
  const partialInputMock = jest.fn();
116
111
  let callbackInput;
117
112
  const TEST_ID = `invisible-number-input-test-id`;
118
- const NumberInput = react_native_testing_library_1.render(<InvisibleNumberInput_1.default negativeAllowed={false} cleanPartialInput={true} decimalPlaces={decimals} onEnd={onEndMock} partialInput={partialInputMock} visible={(e) => (callbackInput = e)} startValue={startValue} testID={TEST_ID}/>);
113
+ const NumberInput = render(<InvisibleNumberInput negativeAllowed={false} cleanPartialInput={true} decimalPlaces={decimals} onEnd={onEndMock} partialInput={partialInputMock} visible={(e) => (callbackInput = e)} startValue={startValue} testID={TEST_ID}/>);
119
114
  // @ts-ignore
120
115
  callbackInput?.();
121
116
  const textInput = NumberInput.getByTestId(TEST_ID);
122
- react_native_testing_library_1.fireEvent(textInput, `onChangeText`, startValue);
117
+ fireEvent(textInput, `onChangeText`, startValue);
123
118
  expect(partialInputMock).toBeCalledWith(`${expected}`);
124
119
  });
125
120
  test.each `
@@ -134,11 +129,11 @@ describe(`InvisibleNumberInput Component`, () => {
134
129
  const partialInputMock = jest.fn();
135
130
  let callbackInput;
136
131
  const TEST_ID = `invisible-number-input-test-id`;
137
- const NumberInput = react_native_testing_library_1.render(<InvisibleNumberInput_1.default negativeAllowed={false} cleanPartialInput={false} decimalPlaces={decimals} onEnd={onEndMock} partialInput={partialInputMock} visible={(e) => (callbackInput = e)} startValue={startValue} testID={TEST_ID}/>);
132
+ const NumberInput = render(<InvisibleNumberInput negativeAllowed={false} cleanPartialInput={false} decimalPlaces={decimals} onEnd={onEndMock} partialInput={partialInputMock} visible={(e) => (callbackInput = e)} startValue={startValue} testID={TEST_ID}/>);
138
133
  // @ts-ignore
139
134
  callbackInput?.();
140
135
  const textInput = NumberInput.getByTestId(TEST_ID);
141
- react_native_testing_library_1.fireEvent(textInput, `onChangeText`, startValue);
136
+ fireEvent(textInput, `onChangeText`, startValue);
142
137
  expect(partialInputMock).toBeCalledWith(expected);
143
138
  });
144
139
  test.each `
@@ -153,13 +148,13 @@ describe(`InvisibleNumberInput Component`, () => {
153
148
  const partialInputMock = jest.fn();
154
149
  let callbackInput;
155
150
  const TEST_ID = `invisible-number-input-test-id`;
156
- const NumberInput = react_native_testing_library_1.render(<InvisibleNumberInput_1.default negativeAllowed={true} cleanPartialInput={false} decimalPlaces={decimals} onEnd={onEndMock} partialInput={partialInputMock} visible={(e) => (callbackInput = e)} startValue={startValue} testID={TEST_ID}/>);
151
+ const NumberInput = render(<InvisibleNumberInput negativeAllowed={true} cleanPartialInput={false} decimalPlaces={decimals} onEnd={onEndMock} partialInput={partialInputMock} visible={(e) => (callbackInput = e)} startValue={startValue} testID={TEST_ID}/>);
157
152
  // @ts-ignore
158
153
  callbackInput?.();
159
154
  const textInput = NumberInput.getByTestId(TEST_ID);
160
- react_native_testing_library_1.fireEvent(textInput, `onChangeText`, startValue);
155
+ fireEvent(textInput, `onChangeText`, startValue);
161
156
  expect(partialInputMock).toBeCalledWith(startValue);
162
- react_native_testing_library_1.fireEvent(textInput, `onEndEditing`, startValue);
157
+ fireEvent(textInput, `onEndEditing`, startValue);
163
158
  expect(onEndMock).toBeCalledWith(expected);
164
159
  });
165
160
  });
@@ -1,52 +1,47 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const types_1 = require("@hedia/types");
7
- const react_1 = require("@lingui/react");
8
- const react_2 = __importDefault(require("react"));
9
- const react_native_testing_library_1 = require("react-native-testing-library");
10
- const LimitationMessage_1 = __importDefault(require("../../components/LimitationMessage"));
11
- const i18nUtils_1 = require("../../locale/i18nUtils");
12
- const enum_1 = require("../../types/enum");
13
- const AttentionMessages_1 = require("../../utils/AttentionMessages");
14
- const utils_1 = require("../utils");
15
- const SAFETY_INSULIN_LIMIT = types_1.BolusCalculator.Constants.SAFETY_INSULIN_LIMIT;
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 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
+ const SAFETY_INSULIN_LIMIT = BolusCalculator.Constants.SAFETY_INSULIN_LIMIT;
16
11
  describe(`Info Bars Component`, () => {
17
- afterEach(react_native_testing_library_1.cleanup);
12
+ afterEach(cleanup);
18
13
  beforeEach(() => {
19
- i18nUtils_1.i18n.activate(types_1.Languages.en);
14
+ i18n.activate(Languages.en);
20
15
  });
21
16
  test(`Can call the callback`, () => {
22
17
  const onPressNextButton = jest.fn();
23
18
  const props = {
24
- limitationMessage: AttentionMessages_1.Messages.RecommendationWasLimited(),
19
+ limitationMessage: Messages.RecommendationWasLimited(),
25
20
  onPressNextButton,
26
21
  };
27
- const limitationMessage = react_native_testing_library_1.render(<LimitationMessage_1.default {...props}/>);
28
- const nextButton = limitationMessage.getByTestId(enum_1.LimitationMessageTestIds.OkButton);
29
- react_native_testing_library_1.fireEvent(nextButton, `onPress`);
22
+ const limitationMessage = render(<LimitationMessage {...props}/>);
23
+ const nextButton = limitationMessage.getByTestId(LimitationMessageTestIds.OkButton);
24
+ fireEvent(nextButton, `onPress`);
30
25
  expect(onPressNextButton).toBeCalled();
31
26
  });
32
27
  test.each `
33
28
  language | locale | message
34
- ${`English`} | ${types_1.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`} | ${types_1.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`} | ${types_1.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`} | ${types_1.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`} | ${types_1.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`} | ${types_1.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.`}
29
+ ${`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.`}
30
+ ${`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.`}
31
+ ${`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.`}
32
+ ${`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.`}
33
+ ${`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.`}
34
+ ${`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
35
  `(`Can display limitation message in $language`, ({ message, locale }) => {
41
- i18nUtils_1.i18n.activate(locale);
36
+ i18n.activate(locale);
42
37
  const onPressNextButton = jest.fn();
43
38
  const props = {
44
- limitationMessage: AttentionMessages_1.Messages.RecommendationWasLimited(),
39
+ limitationMessage: Messages.RecommendationWasLimited(),
45
40
  onPressNextButton,
46
41
  };
47
- const limitationMessage = react_native_testing_library_1.render(<react_1.I18nProvider language={locale} i18n={i18nUtils_1.i18n}>
48
- <LimitationMessage_1.default {...props}/>,
49
- </react_1.I18nProvider>);
50
- utils_1.expectTextExists(limitationMessage, message);
42
+ const limitationMessage = render(<I18nProvider language={locale} i18n={i18n}>
43
+ <LimitationMessage {...props}/>,
44
+ </I18nProvider>);
45
+ expectTextExists(limitationMessage, message);
51
46
  });
52
47
  });
@@ -1,15 +1,10 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
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 MoodIcon_1 = __importDefault(require("../../components/mood/MoodIcon"));
10
- const MoodEnum = types_1.Logbook.Enums.MoodEnum;
1
+ import { Logbook } from "@hedia/types";
2
+ import React from "react";
3
+ import { cleanup, fireEvent, render } from "react-native-testing-library";
4
+ import MoodIcon from "../../components/mood/MoodIcon";
5
+ const MoodEnum = Logbook.Enums.MoodEnum;
11
6
  describe(`MoodIcon - Component`, () => {
12
- afterEach(react_native_testing_library_1.cleanup);
7
+ afterEach(cleanup);
13
8
  test.each `
14
9
  mood | moodName
15
10
  ${MoodEnum.Happy} | ${MoodEnum[MoodEnum.Happy]}
@@ -20,16 +15,16 @@ describe(`MoodIcon - Component`, () => {
20
15
  `(`Mounting $moodName smiley is mounted inactive and can be toggled on`, ({ mood, moodName }) => {
21
16
  let active = false;
22
17
  const onPressMock = jest.fn((toggle) => (active = toggle));
23
- const wrapper = react_native_testing_library_1.render(<MoodIcon_1.default active={active} mood={mood} onPress={onPressMock}/>);
18
+ const wrapper = render(<MoodIcon active={active} mood={mood} onPress={onPressMock}/>);
24
19
  const getButton = (isActive) => wrapper.getByA11yLabel(`${moodName}_${isActive}`);
25
20
  const button = getButton(false);
26
21
  if (button === null) {
27
22
  return fail(`No button found for getByA11yLabel: ${moodName}_${false}`);
28
23
  }
29
- react_native_testing_library_1.fireEvent(button, `onPress`);
24
+ fireEvent(button, `onPress`);
30
25
  expect(onPressMock).toBeCalledWith(true);
31
26
  expect(active).toBe(true);
32
- wrapper.rerender(<MoodIcon_1.default active={active} mood={mood} onPress={onPressMock}/>);
27
+ wrapper.rerender(<MoodIcon active={active} mood={mood} onPress={onPressMock}/>);
33
28
  expect(getButton(true)).not.toBeNull();
34
29
  });
35
30
  });
@@ -1,102 +1,97 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const types_1 = require("@hedia/types");
7
- const react_1 = require("@lingui/react");
8
- const react_2 = __importDefault(require("react"));
9
- const react_native_testing_library_1 = require("react-native-testing-library");
10
- const RecommendationModal_1 = __importDefault(require("../../components/RecommendationModal"));
11
- const i18nUtils_1 = require("../../locale/i18nUtils");
12
- const enum_1 = require("../../types/enum");
13
- const AttentionMessages_1 = require("../../utils/AttentionMessages");
14
- const utils_1 = require("../utils");
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";
15
10
  describe(`RecommendationModal Component`, () => {
16
- afterEach(react_native_testing_library_1.cleanup);
11
+ afterEach(cleanup);
17
12
  beforeEach(() => {
18
- i18nUtils_1.i18n.activate(types_1.Languages.en);
13
+ i18n.activate(Languages.en);
19
14
  });
20
15
  test(`start display with the second page`, () => {
21
16
  const acceptMock = jest.fn();
22
17
  const declineMock = jest.fn();
23
18
  const onClickOkMock = jest.fn();
24
- const wrapper = react_native_testing_library_1.render(<RecommendationModal_1.default isVisible={true} attentionMessage={null} limitationMessage={null} suggestedCarbohydrates={2} onClickOkButton={onClickOkMock} onAcceptCarbohydrates={acceptMock} onDeclineCarbohydrates={declineMock}/>);
25
- utils_1.expectTextExists(wrapper, `We recommend eating an additional:`);
26
- utils_1.expectTextExists(wrapper, `2 `);
27
- utils_1.expectTextExists(wrapper, `grams of carbohydrates`);
28
- utils_1.expectTextExists(wrapper, `Instead of taking insulin`);
19
+ const wrapper = render(<RecommendationModal isVisible={true} attentionMessage={null} limitationMessage={null} suggestedCarbohydrates={2} onClickOkButton={onClickOkMock} onAcceptCarbohydrates={acceptMock} onDeclineCarbohydrates={declineMock}/>);
20
+ expectTextExists(wrapper, `We recommend eating an additional:`);
21
+ expectTextExists(wrapper, `2 `);
22
+ expectTextExists(wrapper, `grams of carbohydrates`);
23
+ expectTextExists(wrapper, `Instead of taking insulin`);
29
24
  });
30
25
  test(`accept carbs from second page`, () => {
31
26
  const acceptMock = jest.fn();
32
27
  const declineMock = jest.fn();
33
28
  const onClickOkMock = jest.fn();
34
- const wrapper = react_native_testing_library_1.render(<RecommendationModal_1.default isVisible={true} attentionMessage={null} limitationMessage={null} suggestedCarbohydrates={5} onClickOkButton={onClickOkMock} onAcceptCarbohydrates={acceptMock} onDeclineCarbohydrates={declineMock}/>);
35
- utils_1.expectTextExists(wrapper, `We recommend eating an additional:`);
36
- utils_1.expectTextExists(wrapper, `5 `);
37
- utils_1.expectTextExists(wrapper, `grams of carbohydrates`);
38
- const yesButtonModal = wrapper.getByTestId(enum_1.RecommendationModalTestIds.AcceptCarbs);
39
- react_native_testing_library_1.fireEvent(yesButtonModal, `onPress`);
29
+ const wrapper = render(<RecommendationModal isVisible={true} attentionMessage={null} limitationMessage={null} suggestedCarbohydrates={5} onClickOkButton={onClickOkMock} onAcceptCarbohydrates={acceptMock} onDeclineCarbohydrates={declineMock}/>);
30
+ expectTextExists(wrapper, `We recommend eating an additional:`);
31
+ expectTextExists(wrapper, `5 `);
32
+ expectTextExists(wrapper, `grams of carbohydrates`);
33
+ const yesButtonModal = wrapper.getByTestId(RecommendationModalTestIds.AcceptCarbs);
34
+ fireEvent(yesButtonModal, `onPress`);
40
35
  expect(acceptMock).toBeCalled();
41
36
  });
42
37
  test(`decline carbs from second page`, () => {
43
38
  const acceptMock = jest.fn();
44
39
  const declineMock = jest.fn();
45
40
  const onClickOkMock = jest.fn();
46
- const wrapper = react_native_testing_library_1.render(<RecommendationModal_1.default isVisible={true} attentionMessage={null} limitationMessage={null} suggestedCarbohydrates={5} onClickOkButton={onClickOkMock} onAcceptCarbohydrates={acceptMock} onDeclineCarbohydrates={declineMock}/>);
47
- utils_1.expectTextExists(wrapper, `We recommend eating an additional:`);
48
- utils_1.expectTextExists(wrapper, `grams of carbohydrates`);
49
- const noButtonModal = wrapper.getByTestId(enum_1.RecommendationModalTestIds.DeclineCarbs);
50
- react_native_testing_library_1.fireEvent(noButtonModal, `onPress`);
41
+ const wrapper = render(<RecommendationModal isVisible={true} attentionMessage={null} limitationMessage={null} suggestedCarbohydrates={5} onClickOkButton={onClickOkMock} onAcceptCarbohydrates={acceptMock} onDeclineCarbohydrates={declineMock}/>);
42
+ expectTextExists(wrapper, `We recommend eating an additional:`);
43
+ expectTextExists(wrapper, `grams of carbohydrates`);
44
+ const noButtonModal = wrapper.getByTestId(RecommendationModalTestIds.DeclineCarbs);
45
+ fireEvent(noButtonModal, `onPress`);
51
46
  expect(declineMock).toBeCalled();
52
47
  });
53
48
  test(`test opens with first page and navigate to second`, () => {
54
49
  const acceptMock = jest.fn();
55
50
  const declineMock = jest.fn();
56
51
  const onClickOkMock = jest.fn();
57
- const limitation = AttentionMessages_1.Messages.RecommendationWasLimited();
58
- const attention = AttentionMessages_1.Messages.VeryLowBGL();
59
- const wrapper = react_native_testing_library_1.render(<RecommendationModal_1.default isVisible={true} attentionMessage={attention} limitationMessage={limitation} suggestedCarbohydrates={0} onClickOkButton={onClickOkMock} onAcceptCarbohydrates={acceptMock} onDeclineCarbohydrates={declineMock}/>);
60
- utils_1.expectTextExists(wrapper, limitation);
61
- utils_1.expectTextExists(wrapper, `OK`);
62
- const nextButton = wrapper.getByTestId(enum_1.LimitationMessageTestIds.OkButton);
63
- react_native_testing_library_1.fireEvent(nextButton, `onPress`);
64
- utils_1.expectTextExists(wrapper, attention);
65
- utils_1.expectTextExists(wrapper, `OK`);
66
- utils_1.expectTextNotExists(wrapper, `We recommend eating an additional:`);
67
- const okayButton = wrapper.getByTestId(enum_1.RecommendationModalTestIds.OkButton);
68
- react_native_testing_library_1.fireEvent(okayButton, `onPress`);
52
+ const limitation = Messages.RecommendationWasLimited();
53
+ const attention = Messages.VeryLowBGL();
54
+ const wrapper = render(<RecommendationModal isVisible={true} attentionMessage={attention} limitationMessage={limitation} suggestedCarbohydrates={0} onClickOkButton={onClickOkMock} onAcceptCarbohydrates={acceptMock} onDeclineCarbohydrates={declineMock}/>);
55
+ expectTextExists(wrapper, limitation);
56
+ expectTextExists(wrapper, `OK`);
57
+ const nextButton = wrapper.getByTestId(LimitationMessageTestIds.OkButton);
58
+ fireEvent(nextButton, `onPress`);
59
+ expectTextExists(wrapper, attention);
60
+ expectTextExists(wrapper, `OK`);
61
+ expectTextNotExists(wrapper, `We recommend eating an additional:`);
62
+ const okayButton = wrapper.getByTestId(RecommendationModalTestIds.OkButton);
63
+ fireEvent(okayButton, `onPress`);
69
64
  expect(onClickOkMock).toBeCalled();
70
65
  });
71
66
  test(`close modal from first page if ther are no carbs or attention messages on second page`, () => {
72
67
  const acceptMock = jest.fn();
73
68
  const declineMock = jest.fn();
74
69
  const onClickOkMock = jest.fn();
75
- const limitation = AttentionMessages_1.Messages.RecommendationWasLimited();
76
- const wrapper = react_native_testing_library_1.render(<RecommendationModal_1.default isVisible={true} attentionMessage={null} limitationMessage={limitation} suggestedCarbohydrates={0} onClickOkButton={onClickOkMock} onAcceptCarbohydrates={acceptMock} onDeclineCarbohydrates={declineMock}/>);
77
- utils_1.expectTextExists(wrapper, limitation);
78
- utils_1.expectTextExists(wrapper, `OK`);
79
- const nextButton = wrapper.getByTestId(enum_1.LimitationMessageTestIds.OkButton);
80
- react_native_testing_library_1.fireEvent(nextButton, `onPress`);
70
+ const limitation = Messages.RecommendationWasLimited();
71
+ const wrapper = render(<RecommendationModal isVisible={true} attentionMessage={null} limitationMessage={limitation} suggestedCarbohydrates={0} onClickOkButton={onClickOkMock} onAcceptCarbohydrates={acceptMock} onDeclineCarbohydrates={declineMock}/>);
72
+ expectTextExists(wrapper, limitation);
73
+ expectTextExists(wrapper, `OK`);
74
+ const nextButton = wrapper.getByTestId(LimitationMessageTestIds.OkButton);
75
+ fireEvent(nextButton, `onPress`);
81
76
  expect(onClickOkMock).toBeCalled();
82
77
  });
83
78
  test.each `
84
79
  language | locale | message
85
- ${`English`} | ${types_1.Languages.en} | ${`We recommend eating an additional:`}
86
- ${`Danish`} | ${types_1.Languages.da} | ${`Vi anbefaler at spise yderligere:`}
87
- ${`German`} | ${types_1.Languages.de} | ${`Wir empfehlen Ihnen, zusätzlich Folgendes zu essen:`}
88
- ${`Spanish`} | ${types_1.Languages.es} | ${`Recomendamos comer adicionalmente:`}
89
- ${`Italian`} | ${types_1.Languages.it} | ${`Consigliamo di ingerire una quantità supplementare:`}
90
- ${`French`} | ${types_1.Languages.fr} | ${`Nous vous recommandons de manger en plus :`}
80
+ ${`English`} | ${Languages.en} | ${`We recommend eating an additional:`}
81
+ ${`Danish`} | ${Languages.da} | ${`Vi anbefaler at spise yderligere:`}
82
+ ${`German`} | ${Languages.de} | ${`Wir empfehlen Ihnen, zusätzlich Folgendes zu essen:`}
83
+ ${`Spanish`} | ${Languages.es} | ${`Recomendamos comer adicionalmente:`}
84
+ ${`Italian`} | ${Languages.it} | ${`Consigliamo di ingerire una quantità supplementare:`}
85
+ ${`French`} | ${Languages.fr} | ${`Nous vous recommandons de manger en plus :`}
91
86
  `(`Modal renders attention messages in $language`, ({ message, locale }) => {
92
- i18nUtils_1.i18n.activate(locale);
87
+ i18n.activate(locale);
93
88
  const acceptMock = jest.fn();
94
89
  const declineMock = jest.fn();
95
90
  const onClickOkMock = jest.fn();
96
- const wrapper = react_native_testing_library_1.render(<react_1.I18nProvider language={locale} i18n={i18nUtils_1.i18n}>
97
- <RecommendationModal_1.default isVisible={true} attentionMessage={null} limitationMessage={null} suggestedCarbohydrates={2} onClickOkButton={onClickOkMock} onAcceptCarbohydrates={acceptMock} onDeclineCarbohydrates={declineMock}/>
91
+ const wrapper = render(<I18nProvider language={locale} i18n={i18n}>
92
+ <RecommendationModal isVisible={true} attentionMessage={null} limitationMessage={null} suggestedCarbohydrates={2} onClickOkButton={onClickOkMock} onAcceptCarbohydrates={acceptMock} onDeclineCarbohydrates={declineMock}/>
98
93
  ,
99
- </react_1.I18nProvider>);
100
- utils_1.expectTextExists(wrapper, message);
94
+ </I18nProvider>);
95
+ expectTextExists(wrapper, message);
101
96
  });
102
97
  });
@@ -1,124 +1,119 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const react_1 = __importDefault(require("react"));
7
- const react_native_testing_library_1 = require("react-native-testing-library");
8
- const InvisibleNumberInput_1 = __importDefault(require("../../components/InvisibleNumberInput"));
9
- const RecommendedCarbs_1 = __importDefault(require("../../components/RecommendedCarbs"));
10
- const enum_1 = require("../../types/enum");
11
- const utils_1 = require("../utils");
1
+ import React from "react";
2
+ import { cleanup, fireEvent, render } from "react-native-testing-library";
3
+ import InvisibleNumberInput from "../../components/InvisibleNumberInput";
4
+ import RecommendedCarbs from "../../components/RecommendedCarbs";
5
+ import { RecommendedCarbsTestIds } from "../../types/enum";
6
+ import { expectTextExists, expectTextNotExists } from "../utils";
12
7
  describe(`Calculation Component`, () => {
13
- afterEach(react_native_testing_library_1.cleanup);
8
+ afterEach(cleanup);
14
9
  test(`calculate total carbs`, () => {
15
10
  const removeMock = jest.fn();
16
11
  const changeMock = jest.fn();
17
12
  const newValue = 40;
18
- const wrapper = react_native_testing_library_1.render(<RecommendedCarbs_1.default enteredCarbs={`10`} recommendedCarbs={`25`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock}/>);
19
- utils_1.expectTextExists(wrapper, `Food`);
20
- utils_1.expectTextExists(wrapper, `Additional`);
21
- utils_1.expectTextExists(wrapper, `10`);
22
- utils_1.expectTextExists(wrapper, `25`);
23
- utils_1.expectTextExists(wrapper, `35`);
24
- const invisInput = wrapper.getByTestId(enum_1.RecommendedCarbsTestIds.InvisibleCarbInput);
25
- react_native_testing_library_1.fireEvent(invisInput, `onEnd`, newValue);
13
+ const wrapper = render(<RecommendedCarbs enteredCarbs={`10`} recommendedCarbs={`25`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock}/>);
14
+ expectTextExists(wrapper, `Food`);
15
+ expectTextExists(wrapper, `Additional`);
16
+ expectTextExists(wrapper, `10`);
17
+ expectTextExists(wrapper, `25`);
18
+ expectTextExists(wrapper, `35`);
19
+ const invisInput = wrapper.getByTestId(RecommendedCarbsTestIds.InvisibleCarbInput);
20
+ fireEvent(invisInput, `onEnd`, newValue);
26
21
  expect(changeMock).toBeCalledWith(newValue);
27
- wrapper.rerender(<RecommendedCarbs_1.default enteredCarbs={`10`} recommendedCarbs={`${newValue}`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock}/>);
28
- utils_1.expectTextExists(wrapper, `10`);
29
- utils_1.expectTextExists(wrapper, `${newValue}`);
30
- utils_1.expectTextExists(wrapper, `50`);
31
- utils_1.expectTextNotExists(wrapper, `35`);
22
+ wrapper.rerender(<RecommendedCarbs enteredCarbs={`10`} recommendedCarbs={`${newValue}`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock}/>);
23
+ expectTextExists(wrapper, `10`);
24
+ expectTextExists(wrapper, `${newValue}`);
25
+ expectTextExists(wrapper, `50`);
26
+ expectTextNotExists(wrapper, `35`);
32
27
  });
33
28
  test(`25 recommended carbs`, () => {
34
29
  const removeMock = jest.fn();
35
30
  const changeMock = jest.fn();
36
- const wrapper = react_native_testing_library_1.render(<RecommendedCarbs_1.default enteredCarbs={`0`} recommendedCarbs={`25`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock}/>);
37
- utils_1.expectTextExists(wrapper, `Food`);
38
- utils_1.expectTextExists(wrapper, `Additional`);
31
+ const wrapper = render(<RecommendedCarbs enteredCarbs={`0`} recommendedCarbs={`25`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock}/>);
32
+ expectTextExists(wrapper, `Food`);
33
+ expectTextExists(wrapper, `Additional`);
39
34
  expect(wrapper.getAllByText(`25`).length).toBe(2);
40
35
  });
41
36
  test(`25.5 recommended carbs get rounded to 26`, () => {
42
37
  const removeMock = jest.fn();
43
38
  const changeMock = jest.fn();
44
- const wrapper = react_native_testing_library_1.render(<RecommendedCarbs_1.default enteredCarbs={`0`} recommendedCarbs={`25.5`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock}/>);
45
- utils_1.expectTextExists(wrapper, `Food`);
46
- utils_1.expectTextExists(wrapper, `Additional`);
39
+ const wrapper = render(<RecommendedCarbs enteredCarbs={`0`} recommendedCarbs={`25.5`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock}/>);
40
+ expectTextExists(wrapper, `Food`);
41
+ expectTextExists(wrapper, `Additional`);
47
42
  expect(wrapper.getAllByText(`26`).length).toBe(2);
48
43
  });
49
44
  test(`Negative recommended carbs does not render 'recommended additional g carbs'`, () => {
50
45
  const removeMock = jest.fn();
51
46
  const changeMock = jest.fn();
52
- const wrapper = react_native_testing_library_1.render(<RecommendedCarbs_1.default enteredCarbs={`0`} recommendedCarbs={`-25`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock}/>);
53
- utils_1.expectTextExists(wrapper, `Food`);
54
- utils_1.expectTextNotExists(wrapper, `Additional`);
55
- utils_1.expectTextNotExists(wrapper, `-25`);
47
+ const wrapper = render(<RecommendedCarbs enteredCarbs={`0`} recommendedCarbs={`-25`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock}/>);
48
+ expectTextExists(wrapper, `Food`);
49
+ expectTextNotExists(wrapper, `Additional`);
50
+ expectTextNotExists(wrapper, `-25`);
56
51
  });
57
52
  test(`No recommended carbs does not render 'recommended additional g carbs'`, () => {
58
53
  const removeMock = jest.fn();
59
54
  const changeMock = jest.fn();
60
- const wrapper = react_native_testing_library_1.render(<RecommendedCarbs_1.default enteredCarbs={`0`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock}/>);
61
- utils_1.expectTextExists(wrapper, `Food`);
62
- utils_1.expectTextNotExists(wrapper, `Additional`);
55
+ const wrapper = render(<RecommendedCarbs enteredCarbs={`0`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock}/>);
56
+ expectTextExists(wrapper, `Food`);
57
+ expectTextNotExists(wrapper, `Additional`);
63
58
  });
64
59
  test(`Editing recommended carbs`, () => {
65
60
  const removeMock = jest.fn();
66
61
  const changeMock = jest.fn();
67
- const wrapper = react_native_testing_library_1.render(<RecommendedCarbs_1.default enteredCarbs={`0`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock} recommendedCarbs={`12`}/>);
68
- utils_1.expectTextExists(wrapper, `Food`);
69
- utils_1.expectTextExists(wrapper, `Additional`);
62
+ const wrapper = render(<RecommendedCarbs enteredCarbs={`0`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock} recommendedCarbs={`12`}/>);
63
+ expectTextExists(wrapper, `Food`);
64
+ expectTextExists(wrapper, `Additional`);
70
65
  expect(wrapper.getAllByText(`12`).length).toBe(2);
71
- const carbButton = wrapper.getByTestId(enum_1.RecommendedCarbsTestIds.EditRecommendedCarbs);
72
- react_native_testing_library_1.fireEvent(carbButton, `onPress`);
66
+ const carbButton = wrapper.getByTestId(RecommendedCarbsTestIds.EditRecommendedCarbs);
67
+ fireEvent(carbButton, `onPress`);
73
68
  expect(wrapper.getAllByText(`12`).length).toBe(2);
74
69
  });
75
70
  test(`Finished editing recommended carbs with carbs >= 0`, () => {
76
71
  const removeMock = jest.fn();
77
72
  const changeMock = jest.fn();
78
- const wrapper = react_native_testing_library_1.render(<RecommendedCarbs_1.default enteredCarbs={`0`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock} recommendedCarbs={`12`}/>);
79
- utils_1.expectTextExists(wrapper, `Food`);
80
- utils_1.expectTextExists(wrapper, `Additional`);
81
- const carbButton = wrapper.getByTestId(enum_1.RecommendedCarbsTestIds.EditRecommendedCarbs);
82
- react_native_testing_library_1.fireEvent(carbButton, `onPress`);
83
- const invisInput = wrapper.getByTestId(enum_1.RecommendedCarbsTestIds.InvisibleCarbInput);
84
- react_native_testing_library_1.fireEvent(invisInput, `onEndEditing`);
73
+ const wrapper = render(<RecommendedCarbs enteredCarbs={`0`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock} recommendedCarbs={`12`}/>);
74
+ expectTextExists(wrapper, `Food`);
75
+ expectTextExists(wrapper, `Additional`);
76
+ const carbButton = wrapper.getByTestId(RecommendedCarbsTestIds.EditRecommendedCarbs);
77
+ fireEvent(carbButton, `onPress`);
78
+ const invisInput = wrapper.getByTestId(RecommendedCarbsTestIds.InvisibleCarbInput);
79
+ fireEvent(invisInput, `onEndEditing`);
85
80
  expect(changeMock).toBeCalledWith(Number(`12`));
86
81
  });
87
82
  test(`Negative recommendedCarbs removes recommendedCarbs render`, () => {
88
83
  const removeMock = jest.fn();
89
84
  const changeMock = jest.fn();
90
- const wrapper = react_native_testing_library_1.render(<RecommendedCarbs_1.default enteredCarbs={`0`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock} recommendedCarbs={`-12`}/>);
91
- utils_1.expectTextExists(wrapper, `Food`);
92
- utils_1.expectTextNotExists(wrapper, `Additional`);
93
- const carbButton = wrapper.queryByTestId(enum_1.RecommendedCarbsTestIds.EditRecommendedCarbs);
85
+ const wrapper = render(<RecommendedCarbs enteredCarbs={`0`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock} recommendedCarbs={`-12`}/>);
86
+ expectTextExists(wrapper, `Food`);
87
+ expectTextNotExists(wrapper, `Additional`);
88
+ const carbButton = wrapper.queryByTestId(RecommendedCarbsTestIds.EditRecommendedCarbs);
94
89
  expect(carbButton).toBeNull();
95
90
  });
96
91
  test(`Negative carbs doesn't invoke changedRecommendedCarbs callback`, () => {
97
92
  const removeMock = jest.fn();
98
93
  const changeMock = jest.fn();
99
- const wrapper = react_native_testing_library_1.render(<RecommendedCarbs_1.default enteredCarbs={`0`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock} recommendedCarbs={`1`}/>);
100
- const numberInput = wrapper.UNSAFE_getByType(InvisibleNumberInput_1.default);
101
- react_native_testing_library_1.fireEvent(numberInput, `onEnd`, -12);
94
+ const wrapper = render(<RecommendedCarbs enteredCarbs={`0`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock} recommendedCarbs={`1`}/>);
95
+ const numberInput = wrapper.UNSAFE_getByType(InvisibleNumberInput);
96
+ fireEvent(numberInput, `onEnd`, -12);
102
97
  expect(removeMock).not.toBeCalled();
103
98
  expect(changeMock).not.toBeCalled();
104
99
  });
105
100
  test(`Carb error limit is > 300`, () => {
106
101
  const removeMock = jest.fn();
107
102
  const changeMock = jest.fn();
108
- const wrapper = react_native_testing_library_1.render(<RecommendedCarbs_1.default enteredCarbs={`0`} recommendedCarbs={`25`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock}/>);
103
+ const wrapper = render(<RecommendedCarbs enteredCarbs={`0`} recommendedCarbs={`25`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock}/>);
109
104
  expect(wrapper.getAllByText(`25`).length).toBe(2);
110
- const invisInput = wrapper.getByTestId(enum_1.RecommendedCarbsTestIds.InvisibleCarbInput);
111
- react_native_testing_library_1.fireEvent(invisInput, `onEnd`, 302);
105
+ const invisInput = wrapper.getByTestId(RecommendedCarbsTestIds.InvisibleCarbInput);
106
+ fireEvent(invisInput, `onEnd`, 302);
112
107
  expect(wrapper.getAllByText(`25`).length).toBe(2);
113
- utils_1.expectTextNotExists(wrapper, `302`);
108
+ expectTextNotExists(wrapper, `302`);
114
109
  });
115
110
  test(`Pressing on the remove button invokes the removeRecommendedCarbs callback`, () => {
116
111
  const removeMock = jest.fn();
117
112
  const changeMock = jest.fn();
118
- const wrapper = react_native_testing_library_1.render(<RecommendedCarbs_1.default enteredCarbs={`0`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock} recommendedCarbs={`1`}/>);
113
+ const wrapper = render(<RecommendedCarbs enteredCarbs={`0`} changedRecommendedCarbs={changeMock} removeRecommendedCarbs={removeMock} recommendedCarbs={`1`}/>);
119
114
  expect(removeMock).not.toBeCalled();
120
115
  const removeButton = wrapper.getByA11yLabel(`removeRecommendedCarbs`);
121
- react_native_testing_library_1.fireEvent(removeButton, `onPress`);
116
+ fireEvent(removeButton, `onPress`);
122
117
  expect(removeMock).toBeCalled();
123
118
  });
124
119
  });