@hedia/recommendation-screen 1.8.2 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/.github/workflows/ci.yml +0 -0
  2. package/.github/workflows/publish.yml +48 -0
  3. package/.github/workflows/version-check.yml +45 -0
  4. package/.linguirc +0 -0
  5. package/.npmpackagejsonlintrc.json +0 -0
  6. package/.prettierignore +0 -0
  7. package/.prettierrc +0 -0
  8. package/App.d.ts +4 -5
  9. package/App.jsx +23 -34
  10. package/App.tsx +36 -41
  11. package/Changelog.md +0 -0
  12. package/README.md +0 -0
  13. package/android/app/BUCK +0 -0
  14. package/android/app/build.gradle +0 -0
  15. package/android/app/build_defs.bzl +0 -0
  16. package/android/app/debug.keystore +0 -0
  17. package/android/app/proguard-rules.pro +0 -0
  18. package/android/app/src/debug/AndroidManifest.xml +0 -0
  19. package/android/app/src/debug/java/com/hediarecommendationscreen/ReactNativeFlipper.java +0 -0
  20. package/android/app/src/main/AndroidManifest.xml +0 -0
  21. package/android/app/src/main/assets/fonts/AntDesign.ttf +0 -0
  22. package/android/app/src/main/assets/fonts/Entypo.ttf +0 -0
  23. package/android/app/src/main/assets/fonts/EvilIcons.ttf +0 -0
  24. package/android/app/src/main/assets/fonts/Feather.ttf +0 -0
  25. package/android/app/src/main/assets/fonts/FontAwesome.ttf +0 -0
  26. package/android/app/src/main/assets/fonts/FontAwesome5_Brands.ttf +0 -0
  27. package/android/app/src/main/assets/fonts/FontAwesome5_Regular.ttf +0 -0
  28. package/android/app/src/main/assets/fonts/FontAwesome5_Solid.ttf +0 -0
  29. package/android/app/src/main/assets/fonts/Foundation.ttf +0 -0
  30. package/android/app/src/main/assets/fonts/Ionicons.ttf +0 -0
  31. package/android/app/src/main/assets/fonts/MaterialCommunityIcons.ttf +0 -0
  32. package/android/app/src/main/assets/fonts/MaterialIcons.ttf +0 -0
  33. package/android/app/src/main/assets/fonts/Octicons.ttf +0 -0
  34. package/android/app/src/main/assets/fonts/Roboto-Black.ttf +0 -0
  35. package/android/app/src/main/assets/fonts/Roboto-BlackItalic.ttf +0 -0
  36. package/android/app/src/main/assets/fonts/Roboto-Bold.ttf +0 -0
  37. package/android/app/src/main/assets/fonts/Roboto-BoldItalic.ttf +0 -0
  38. package/android/app/src/main/assets/fonts/Roboto-Italic.ttf +0 -0
  39. package/android/app/src/main/assets/fonts/Roboto-Light.ttf +0 -0
  40. package/android/app/src/main/assets/fonts/Roboto-LightItalic.ttf +0 -0
  41. package/android/app/src/main/assets/fonts/Roboto-Medium.ttf +0 -0
  42. package/android/app/src/main/assets/fonts/Roboto-MediumItalic.ttf +0 -0
  43. package/android/app/src/main/assets/fonts/Roboto-Regular.ttf +0 -0
  44. package/android/app/src/main/assets/fonts/Roboto-Thin.ttf +0 -0
  45. package/android/app/src/main/assets/fonts/Roboto-ThinItalic.ttf +0 -0
  46. package/android/app/src/main/assets/fonts/SimpleLineIcons.ttf +0 -0
  47. package/android/app/src/main/assets/fonts/Zocial.ttf +0 -0
  48. package/android/app/src/main/java/com/hediarecommendationscreen/MainActivity.java +0 -0
  49. package/android/app/src/main/java/com/hediarecommendationscreen/MainApplication.java +0 -0
  50. package/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  51. package/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  52. package/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  53. package/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  54. package/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  55. package/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  56. package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  57. package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  58. package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  59. package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  60. package/android/app/src/main/res/values/color.xml +0 -0
  61. package/android/app/src/main/res/values/strings.xml +0 -0
  62. package/android/app/src/main/res/values/styles.xml +0 -0
  63. package/android/build.gradle +0 -0
  64. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  65. package/android/gradle/wrapper/gradle-wrapper.properties +0 -0
  66. package/android/gradle.properties +0 -0
  67. package/android/gradlew.bat +0 -0
  68. package/android/settings.gradle +0 -0
  69. package/app.json +0 -0
  70. package/assets/fonts/Roboto/LICENSE.txt +0 -0
  71. package/assets/fonts/Roboto/Roboto-Black.ttf +0 -0
  72. package/assets/fonts/Roboto/Roboto-BlackItalic.ttf +0 -0
  73. package/assets/fonts/Roboto/Roboto-Bold.ttf +0 -0
  74. package/assets/fonts/Roboto/Roboto-BoldItalic.ttf +0 -0
  75. package/assets/fonts/Roboto/Roboto-Italic.ttf +0 -0
  76. package/assets/fonts/Roboto/Roboto-Light.ttf +0 -0
  77. package/assets/fonts/Roboto/Roboto-LightItalic.ttf +0 -0
  78. package/assets/fonts/Roboto/Roboto-Medium.ttf +0 -0
  79. package/assets/fonts/Roboto/Roboto-MediumItalic.ttf +0 -0
  80. package/assets/fonts/Roboto/Roboto-Regular.ttf +0 -0
  81. package/assets/fonts/Roboto/Roboto-Thin.ttf +0 -0
  82. package/assets/fonts/Roboto/Roboto-ThinItalic.ttf +0 -0
  83. package/babel.config.js +0 -0
  84. package/ignore-git.sh +1 -1
  85. package/ignore-publish.sh +2 -1
  86. package/index.d.ts +2 -2
  87. package/index.js +2 -3
  88. package/index.ts +2 -2
  89. package/ios/HediaRecommendationScreen/AppDelegate.h +0 -0
  90. package/ios/HediaRecommendationScreen/AppDelegate.m +0 -0
  91. package/ios/HediaRecommendationScreen/Base.lproj/LaunchScreen.xib +0 -0
  92. package/ios/HediaRecommendationScreen/Images.xcassets/AppIcon.appiconset/Contents.json +0 -0
  93. package/ios/HediaRecommendationScreen/Images.xcassets/Contents.json +0 -0
  94. package/ios/HediaRecommendationScreen/Info.plist +0 -0
  95. package/ios/HediaRecommendationScreen/main.m +0 -0
  96. package/ios/HediaRecommendationScreen-tvOS/Info.plist +0 -0
  97. package/ios/HediaRecommendationScreen-tvOSTests/Info.plist +0 -0
  98. package/ios/HediaRecommendationScreen.xcodeproj/project.pbxproj +0 -0
  99. package/ios/HediaRecommendationScreen.xcodeproj/xcshareddata/xcschemes/HediaRecommendationScreen-tvOS.xcscheme +0 -0
  100. package/ios/HediaRecommendationScreen.xcodeproj/xcshareddata/xcschemes/HediaRecommendationScreen.xcscheme +0 -0
  101. package/ios/HediaRecommendationScreen.xcworkspace/contents.xcworkspacedata +0 -0
  102. package/ios/HediaRecommendationScreen.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
  103. package/ios/HediaRecommendationScreenTests/HediaRecommendationScreenTests.m +0 -0
  104. package/ios/HediaRecommendationScreenTests/Info.plist +0 -0
  105. package/ios/Podfile +0 -0
  106. package/ios/Podfile.lock +0 -0
  107. package/jest.config.js +0 -0
  108. package/jest.mock.js +0 -0
  109. package/metro.config.js +0 -0
  110. package/package.json +8 -10
  111. package/react-native.config.js +0 -0
  112. package/src/RecommendationScreen.d.ts +18 -20
  113. package/src/RecommendationScreen.jsx +26 -15
  114. package/src/RecommendationScreen.tsx +60 -37
  115. package/src/__tests__/RecommendationScreen.test.d.ts +0 -0
  116. package/src/__tests__/RecommendationScreen.test.jsx +163 -138
  117. package/src/__tests__/RecommendationScreen.test.tsx +256 -159
  118. package/src/__tests__/RecommendationUtils.test.d.ts +0 -0
  119. package/src/__tests__/RecommendationUtils.test.js +30 -39
  120. package/src/__tests__/RecommendationUtils.test.ts +38 -43
  121. package/src/__tests__/Translate.test.d.ts +0 -0
  122. package/src/__tests__/Translate.test.jsx +13 -12
  123. package/src/__tests__/Translate.test.tsx +15 -14
  124. package/src/__tests__/Utils.test.d.ts +0 -0
  125. package/src/__tests__/Utils.test.js +22 -20
  126. package/src/__tests__/Utils.test.ts +32 -21
  127. package/src/__tests__/Validations.test.d.ts +0 -0
  128. package/src/__tests__/Validations.test.js +59 -33
  129. package/src/__tests__/Validations.test.ts +83 -41
  130. package/src/__tests__/components/Activity.test.d.ts +0 -0
  131. package/src/__tests__/components/Activity.test.jsx +39 -18
  132. package/src/__tests__/components/Activity.test.tsx +99 -45
  133. package/src/__tests__/components/Emotion.test.d.ts +0 -0
  134. package/src/__tests__/components/Emotion.test.jsx +34 -25
  135. package/src/__tests__/components/Emotion.test.tsx +41 -24
  136. package/src/__tests__/components/Header.test.d.ts +0 -0
  137. package/src/__tests__/components/Header.test.jsx +10 -9
  138. package/src/__tests__/components/Header.test.tsx +12 -11
  139. package/src/__tests__/components/InfoBars.test.d.ts +0 -0
  140. package/src/__tests__/components/InfoBars.test.jsx +1 -0
  141. package/src/__tests__/components/InfoBars.test.tsx +7 -6
  142. package/src/__tests__/components/InvisibleNumberInput.test.d.ts +0 -0
  143. package/src/__tests__/components/InvisibleNumberInput.test.jsx +40 -24
  144. package/src/__tests__/components/InvisibleNumberInput.test.tsx +41 -17
  145. package/src/__tests__/components/LimitationMessage.test.d.ts +0 -0
  146. package/src/__tests__/components/LimitationMessage.test.jsx +11 -30
  147. package/src/__tests__/components/LimitationMessage.test.tsx +15 -13
  148. package/src/__tests__/components/MoodIcon.test.d.ts +0 -0
  149. package/src/__tests__/components/MoodIcon.test.jsx +12 -8
  150. package/src/__tests__/components/MoodIcon.test.tsx +13 -5
  151. package/src/__tests__/components/RecommendationModal.test.d.ts +0 -0
  152. package/src/__tests__/components/RecommendationModal.test.jsx +22 -21
  153. package/src/__tests__/components/RecommendationModal.test.tsx +29 -27
  154. package/src/__tests__/components/RecommendedCarbs.test.d.ts +0 -0
  155. package/src/__tests__/components/RecommendedCarbs.test.jsx +7 -10
  156. package/src/__tests__/components/RecommendedCarbs.test.tsx +9 -10
  157. package/src/__tests__/components/RecommendedInsulin.test.d.ts +0 -0
  158. package/src/__tests__/components/RecommendedInsulin.test.jsx +57 -41
  159. package/src/__tests__/components/RecommendedInsulin.test.tsx +57 -31
  160. package/src/__tests__/components/Remeasure.test.d.ts +0 -0
  161. package/src/__tests__/components/Remeasure.test.jsx +7 -3
  162. package/src/__tests__/components/Remeasure.test.tsx +11 -3
  163. package/src/__tests__/components/TransferToLogbook.test.d.ts +0 -0
  164. package/src/__tests__/components/TransferToLogbook.test.jsx +2 -2
  165. package/src/__tests__/components/TransferToLogbook.test.tsx +2 -2
  166. package/src/__tests__/components/TwoOptionModal.test.d.ts +0 -0
  167. package/src/__tests__/components/TwoOptionModal.test.jsx +5 -4
  168. package/src/__tests__/components/TwoOptionModal.test.tsx +6 -4
  169. package/src/__tests__/utils.d.ts +7 -2
  170. package/src/__tests__/utils.jsx +59 -15
  171. package/src/__tests__/utils.tsx +63 -16
  172. package/src/assets/activity/Cyclist.png +0 -0
  173. package/src/assets/activity/Other.png +0 -0
  174. package/src/assets/activity/Runner.png +0 -0
  175. package/src/assets/activity/Swimmer.png +0 -0
  176. package/src/assets/activity/Walk.png +0 -0
  177. package/src/assets/mood/happy.png +0 -0
  178. package/src/assets/mood/happy_active.png +0 -0
  179. package/src/assets/mood/neutral.png +0 -0
  180. package/src/assets/mood/neutral_active.png +0 -0
  181. package/src/assets/mood/sad.png +0 -0
  182. package/src/assets/mood/sad_active.png +0 -0
  183. package/src/assets/mood/semi_happy.png +0 -0
  184. package/src/assets/mood/semi_happy_active.png +0 -0
  185. package/src/assets/mood/semi_sad.png +0 -0
  186. package/src/assets/mood/semi_sad_active.png +0 -0
  187. package/src/components/Header.d.ts +0 -0
  188. package/src/components/Header.jsx +2 -1
  189. package/src/components/Header.tsx +2 -1
  190. package/src/components/Icon.js +0 -0
  191. package/src/components/InfoBars.d.ts +1 -1
  192. package/src/components/InfoBars.jsx +0 -0
  193. package/src/components/InfoBars.tsx +1 -1
  194. package/src/components/InvisibleNumberInput.d.ts +2 -1
  195. package/src/components/InvisibleNumberInput.jsx +7 -2
  196. package/src/components/InvisibleNumberInput.tsx +10 -3
  197. package/src/components/LimitationMessage.d.ts +1 -1
  198. package/src/components/LimitationMessage.jsx +3 -2
  199. package/src/components/LimitationMessage.tsx +3 -1
  200. package/src/components/LineSeparator.d.ts +0 -0
  201. package/src/components/LineSeparator.jsx +0 -0
  202. package/src/components/LineSeparator.tsx +0 -0
  203. package/src/components/RecentInsulin.d.ts +0 -0
  204. package/src/components/RecentInsulin.jsx +3 -2
  205. package/src/components/RecentInsulin.tsx +3 -0
  206. package/src/components/RecommendationModal.d.ts +4 -4
  207. package/src/components/RecommendationModal.jsx +10 -9
  208. package/src/components/RecommendationModal.tsx +19 -8
  209. package/src/components/RecommendedCarbs.d.ts +4 -3
  210. package/src/components/RecommendedCarbs.jsx +12 -9
  211. package/src/components/RecommendedCarbs.tsx +31 -16
  212. package/src/components/RecommendedInsulin.d.ts +7 -7
  213. package/src/components/RecommendedInsulin.jsx +11 -7
  214. package/src/components/RecommendedInsulin.tsx +24 -12
  215. package/src/components/Remeasure.d.ts +2 -2
  216. package/src/components/Remeasure.jsx +7 -2
  217. package/src/components/Remeasure.tsx +10 -4
  218. package/src/components/TransferToLogbook.d.ts +0 -0
  219. package/src/components/TransferToLogbook.jsx +2 -1
  220. package/src/components/TransferToLogbook.tsx +2 -0
  221. package/src/components/TwoOptionModal.d.ts +5 -3
  222. package/src/components/TwoOptionModal.jsx +44 -13
  223. package/src/components/TwoOptionModal.tsx +50 -14
  224. package/src/components/activity/Activity.d.ts +2 -3
  225. package/src/components/activity/Activity.jsx +5 -2
  226. package/src/components/activity/Activity.tsx +7 -5
  227. package/src/components/activity/ActivityIcon.d.ts +1 -1
  228. package/src/components/activity/ActivityIcon.jsx +9 -8
  229. package/src/components/activity/ActivityIcon.tsx +12 -10
  230. package/src/components/activity/ActivityIntensity.d.ts +1 -1
  231. package/src/components/activity/ActivityIntensity.jsx +2 -8
  232. package/src/components/activity/ActivityIntensity.tsx +3 -12
  233. package/src/components/mood/Emotion.d.ts +5 -4
  234. package/src/components/mood/Emotion.jsx +4 -3
  235. package/src/components/mood/Emotion.tsx +9 -7
  236. package/src/components/mood/MoodIcon.d.ts +2 -2
  237. package/src/components/mood/MoodIcon.jsx +3 -2
  238. package/src/components/mood/MoodIcon.tsx +4 -2
  239. package/src/locale/CleanLanguage.ts +0 -0
  240. package/src/locale/da/messages.js +1 -1
  241. package/src/locale/da/messages.po +115 -107
  242. package/src/locale/de/messages.js +1 -1
  243. package/src/locale/de/messages.po +115 -107
  244. package/src/locale/en/messages.js +1 -1
  245. package/src/locale/en/messages.po +118 -110
  246. package/src/locale/es/messages.js +1 -1
  247. package/src/locale/es/messages.po +112 -104
  248. package/src/locale/fr/messages.js +1 -1
  249. package/src/locale/fr/messages.po +111 -103
  250. package/src/locale/i18nUtils.d.ts +3 -4
  251. package/src/locale/i18nUtils.js +13 -12
  252. package/src/locale/i18nUtils.ts +14 -14
  253. package/src/locale/it/messages.js +1 -1
  254. package/src/locale/it/messages.po +113 -105
  255. package/src/types/enum.d.ts +52 -44
  256. package/src/types/enum.js +67 -56
  257. package/src/types/enum.ts +58 -34
  258. package/src/types/types.d.ts +9 -23
  259. package/src/types/types.js +0 -0
  260. package/src/types/types.ts +9 -25
  261. package/src/utils/AttentionMessages.d.ts +1 -4
  262. package/src/utils/AttentionMessages.jsx +8 -30
  263. package/src/utils/AttentionMessages.tsx +11 -16
  264. package/src/utils/Constants.d.ts +0 -0
  265. package/src/utils/Constants.js +0 -0
  266. package/src/utils/Constants.ts +0 -0
  267. package/src/utils/RecommendationError.d.ts +2 -0
  268. package/src/utils/RecommendationError.jsx +45 -40
  269. package/src/utils/RecommendationError.tsx +17 -4
  270. package/src/utils/RecommendationUtils.d.ts +7 -8
  271. package/src/utils/RecommendationUtils.js +15 -7
  272. package/src/utils/RecommendationUtils.ts +24 -14
  273. package/src/utils/Translations.d.ts +2 -0
  274. package/src/utils/Translations.js +10 -0
  275. package/src/utils/Translations.ts +9 -0
  276. package/src/utils/Utils.d.ts +4 -5
  277. package/src/utils/Utils.js +6 -5
  278. package/src/utils/Utils.ts +10 -8
  279. package/src/utils/Validations.d.ts +10 -9
  280. package/src/utils/Validations.js +61 -65
  281. package/src/utils/Validations.ts +76 -81
  282. package/tsconfig.json +2 -2
  283. package/tslint.json +0 -0
@@ -12,10 +12,12 @@ describe(`InvisibleNumberInput Component`, () => {
12
12
  const onEndMock = jest.fn();
13
13
  const partialInputMock = jest.fn();
14
14
  let callbackInput;
15
+ const TEST_ID = `invisible-number-input-test-id`;
15
16
  const startValue = `24`;
16
- 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}/>);
17
- callbackInput();
18
- const textInput = NumberInput.queryByA11yLabel(`InvisibleNumberInput`);
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}/>);
18
+ // @ts-ignore
19
+ callbackInput?.();
20
+ const textInput = NumberInput.getByTestId(TEST_ID);
19
21
  react_native_testing_library_1.fireEvent(textInput, `onEndEditing`);
20
22
  expect(partialInputMock).not.toBeCalled();
21
23
  expect(onEndMock).toBeCalledWith(Number(startValue));
@@ -24,9 +26,11 @@ describe(`InvisibleNumberInput Component`, () => {
24
26
  const onEndMock = jest.fn();
25
27
  const partialInputMock = jest.fn();
26
28
  let callbackInput;
27
- 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)}/>);
28
- callbackInput();
29
- const textInput = NumberInput.queryByA11yLabel(`InvisibleNumberInput`);
29
+ 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}/>);
31
+ // @ts-ignore
32
+ callbackInput?.();
33
+ const textInput = NumberInput.getByTestId(TEST_ID);
30
34
  react_native_testing_library_1.fireEvent(textInput, `onEndEditing`);
31
35
  expect(partialInputMock).not.toBeCalled();
32
36
  expect(onEndMock).toBeCalledWith(0);
@@ -43,9 +47,11 @@ describe(`InvisibleNumberInput Component`, () => {
43
47
  const onEndMock = jest.fn();
44
48
  const partialInputMock = jest.fn();
45
49
  let callbackInput;
46
- 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)}/>);
47
- callbackInput();
48
- const textInput = NumberInput.queryByA11yLabel(`InvisibleNumberInput`);
50
+ 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}/>);
52
+ // @ts-ignore
53
+ callbackInput?.();
54
+ const textInput = NumberInput.getByTestId(TEST_ID);
49
55
  react_native_testing_library_1.fireEvent(textInput, `onChangeText`, input);
50
56
  expect(partialInputMock).toBeCalledWith(`${result}`);
51
57
  expect(onEndMock).not.toBeCalled();
@@ -56,9 +62,11 @@ describe(`InvisibleNumberInput Component`, () => {
56
62
  const onEndMock = jest.fn();
57
63
  const partialInputMock = jest.fn();
58
64
  let callbackInput;
59
- 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)}/>);
60
- callbackInput();
61
- const textInput = NumberInput.queryByA11yLabel(`InvisibleNumberInput`);
65
+ 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}/>);
67
+ // @ts-ignore
68
+ callbackInput?.();
69
+ const textInput = NumberInput.getByTestId(TEST_ID);
62
70
  react_native_testing_library_1.fireEvent.changeText(textInput, `22`);
63
71
  expect(partialInputMock).toBeCalledWith(`22`);
64
72
  expect(onEndMock).not.toBeCalled();
@@ -79,9 +87,11 @@ describe(`InvisibleNumberInput Component`, () => {
79
87
  const onEndMock = jest.fn();
80
88
  const partialInputMock = jest.fn();
81
89
  let callbackInput;
82
- 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}/>);
83
- callbackInput();
84
- const textInput = NumberInput.queryByA11yLabel(`InvisibleNumberInput`);
90
+ 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}/>);
92
+ // @ts-ignore
93
+ callbackInput?.();
94
+ const textInput = NumberInput.getByTestId(TEST_ID);
85
95
  react_native_testing_library_1.fireEvent(textInput, `onChangeText`, startValue);
86
96
  expect(partialInputMock).toBeCalledWith(`${expected}`);
87
97
  });
@@ -104,9 +114,11 @@ describe(`InvisibleNumberInput Component`, () => {
104
114
  const onEndMock = jest.fn();
105
115
  const partialInputMock = jest.fn();
106
116
  let callbackInput;
107
- 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}/>);
108
- callbackInput();
109
- const textInput = NumberInput.queryByA11yLabel(`InvisibleNumberInput`);
117
+ 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}/>);
119
+ // @ts-ignore
120
+ callbackInput?.();
121
+ const textInput = NumberInput.getByTestId(TEST_ID);
110
122
  react_native_testing_library_1.fireEvent(textInput, `onChangeText`, startValue);
111
123
  expect(partialInputMock).toBeCalledWith(`${expected}`);
112
124
  });
@@ -121,9 +133,11 @@ describe(`InvisibleNumberInput Component`, () => {
121
133
  const onEndMock = jest.fn();
122
134
  const partialInputMock = jest.fn();
123
135
  let callbackInput;
124
- 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}/>);
125
- callbackInput();
126
- const textInput = NumberInput.queryByA11yLabel(`InvisibleNumberInput`);
136
+ 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}/>);
138
+ // @ts-ignore
139
+ callbackInput?.();
140
+ const textInput = NumberInput.getByTestId(TEST_ID);
127
141
  react_native_testing_library_1.fireEvent(textInput, `onChangeText`, startValue);
128
142
  expect(partialInputMock).toBeCalledWith(expected);
129
143
  });
@@ -138,9 +152,11 @@ describe(`InvisibleNumberInput Component`, () => {
138
152
  const onEndMock = jest.fn();
139
153
  const partialInputMock = jest.fn();
140
154
  let callbackInput;
141
- 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}/>);
142
- callbackInput();
143
- const textInput = NumberInput.queryByA11yLabel(`InvisibleNumberInput`);
155
+ 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}/>);
157
+ // @ts-ignore
158
+ callbackInput?.();
159
+ const textInput = NumberInput.getByTestId(TEST_ID);
144
160
  react_native_testing_library_1.fireEvent(textInput, `onChangeText`, startValue);
145
161
  expect(partialInputMock).toBeCalledWith(startValue);
146
162
  react_native_testing_library_1.fireEvent(textInput, `onEndEditing`, startValue);
@@ -9,7 +9,7 @@ describe(`InvisibleNumberInput Component`, (): void => {
9
9
  const onEndMock = jest.fn();
10
10
  const partialInputMock = jest.fn();
11
11
  let callbackInput: () => void;
12
-
12
+ const TEST_ID = `invisible-number-input-test-id`;
13
13
  const startValue = `24`;
14
14
 
15
15
  const NumberInput = render(
@@ -21,12 +21,14 @@ describe(`InvisibleNumberInput Component`, (): void => {
21
21
  partialInput={partialInputMock}
22
22
  visible={(e): (() => void) => (callbackInput = e)}
23
23
  startValue={startValue}
24
+ testID={TEST_ID}
24
25
  />,
25
26
  );
26
27
 
27
- callbackInput();
28
+ // @ts-ignore
29
+ callbackInput?.();
28
30
 
29
- const textInput = NumberInput.queryByA11yLabel(`InvisibleNumberInput`);
31
+ const textInput = NumberInput.getByTestId(TEST_ID);
30
32
  fireEvent(textInput, `onEndEditing`);
31
33
  expect(partialInputMock).not.toBeCalled();
32
34
  expect(onEndMock).toBeCalledWith(Number(startValue));
@@ -36,6 +38,7 @@ describe(`InvisibleNumberInput Component`, (): void => {
36
38
  const onEndMock = jest.fn();
37
39
  const partialInputMock = jest.fn();
38
40
  let callbackInput: () => void;
41
+ const TEST_ID = `invisible-number-input-test-id`;
39
42
 
40
43
  const NumberInput = render(
41
44
  <InvisibleNumberInput
@@ -45,12 +48,14 @@ describe(`InvisibleNumberInput Component`, (): void => {
45
48
  onEnd={onEndMock}
46
49
  partialInput={partialInputMock}
47
50
  visible={(e): (() => void) => (callbackInput = e)}
51
+ testID={TEST_ID}
48
52
  />,
49
53
  );
50
54
 
51
- callbackInput();
55
+ // @ts-ignore
56
+ callbackInput?.();
52
57
 
53
- const textInput = NumberInput.queryByA11yLabel(`InvisibleNumberInput`);
58
+ const textInput = NumberInput.getByTestId(TEST_ID);
54
59
  fireEvent(textInput, `onEndEditing`);
55
60
  expect(partialInputMock).not.toBeCalled();
56
61
  expect(onEndMock).toBeCalledWith(0);
@@ -68,6 +73,7 @@ describe(`InvisibleNumberInput Component`, (): void => {
68
73
  const onEndMock = jest.fn();
69
74
  const partialInputMock = jest.fn();
70
75
  let callbackInput: () => void;
76
+ const TEST_ID = `invisible-number-input-test-id`;
71
77
 
72
78
  const NumberInput = render(
73
79
  <InvisibleNumberInput
@@ -77,12 +83,14 @@ describe(`InvisibleNumberInput Component`, (): void => {
77
83
  onEnd={onEndMock}
78
84
  partialInput={partialInputMock}
79
85
  visible={(e): (() => void) => (callbackInput = e)}
86
+ testID={TEST_ID}
80
87
  />,
81
88
  );
82
89
 
83
- callbackInput();
90
+ // @ts-ignore
91
+ callbackInput?.();
84
92
 
85
- const textInput = NumberInput.queryByA11yLabel(`InvisibleNumberInput`);
93
+ const textInput = NumberInput.getByTestId(TEST_ID);
86
94
  fireEvent(textInput, `onChangeText`, input);
87
95
  expect(partialInputMock).toBeCalledWith(`${result}`);
88
96
  expect(onEndMock).not.toBeCalled();
@@ -94,6 +102,8 @@ describe(`InvisibleNumberInput Component`, (): void => {
94
102
  const onEndMock = jest.fn();
95
103
  const partialInputMock = jest.fn();
96
104
  let callbackInput: () => void;
105
+ const TEST_ID = `invisible-number-input-test-id`;
106
+
97
107
  const NumberInput = render(
98
108
  <InvisibleNumberInput
99
109
  negativeAllowed={false}
@@ -102,12 +112,14 @@ describe(`InvisibleNumberInput Component`, (): void => {
102
112
  onEnd={onEndMock}
103
113
  partialInput={partialInputMock}
104
114
  visible={(e): (() => void) => (callbackInput = e)}
115
+ testID={TEST_ID}
105
116
  />,
106
117
  );
107
118
 
108
- callbackInput();
119
+ // @ts-ignore
120
+ callbackInput?.();
109
121
 
110
- const textInput = NumberInput.queryByA11yLabel(`InvisibleNumberInput`);
122
+ const textInput = NumberInput.getByTestId(TEST_ID);
111
123
  fireEvent.changeText(textInput, `22`);
112
124
  expect(partialInputMock).toBeCalledWith(`22`);
113
125
  expect(onEndMock).not.toBeCalled();
@@ -137,6 +149,7 @@ describe(`InvisibleNumberInput Component`, (): void => {
137
149
  const onEndMock = jest.fn();
138
150
  const partialInputMock = jest.fn();
139
151
  let callbackInput: () => void;
152
+ const TEST_ID = `invisible-number-input-test-id`;
140
153
 
141
154
  const NumberInput = render(
142
155
  <InvisibleNumberInput
@@ -147,12 +160,14 @@ describe(`InvisibleNumberInput Component`, (): void => {
147
160
  partialInput={partialInputMock}
148
161
  visible={(e): (() => void) => (callbackInput = e)}
149
162
  startValue={startValue}
163
+ testID={TEST_ID}
150
164
  />,
151
165
  );
152
166
 
153
- callbackInput();
167
+ // @ts-ignore
168
+ callbackInput?.();
154
169
 
155
- const textInput = NumberInput.queryByA11yLabel(`InvisibleNumberInput`);
170
+ const textInput = NumberInput.getByTestId(TEST_ID);
156
171
  fireEvent(textInput, `onChangeText`, startValue);
157
172
  expect(partialInputMock).toBeCalledWith(`${expected}`);
158
173
  },
@@ -179,6 +194,7 @@ describe(`InvisibleNumberInput Component`, (): void => {
179
194
  const onEndMock = jest.fn();
180
195
  const partialInputMock = jest.fn();
181
196
  let callbackInput: () => void;
197
+ const TEST_ID = `invisible-number-input-test-id`;
182
198
 
183
199
  const NumberInput = render(
184
200
  <InvisibleNumberInput
@@ -189,12 +205,14 @@ describe(`InvisibleNumberInput Component`, (): void => {
189
205
  partialInput={partialInputMock}
190
206
  visible={(e): (() => void) => (callbackInput = e)}
191
207
  startValue={startValue}
208
+ testID={TEST_ID}
192
209
  />,
193
210
  );
194
211
 
195
- callbackInput();
212
+ // @ts-ignore
213
+ callbackInput?.();
196
214
 
197
- const textInput = NumberInput.queryByA11yLabel(`InvisibleNumberInput`);
215
+ const textInput = NumberInput.getByTestId(TEST_ID);
198
216
  fireEvent(textInput, `onChangeText`, startValue);
199
217
  expect(partialInputMock).toBeCalledWith(`${expected}`);
200
218
  },
@@ -211,6 +229,7 @@ describe(`InvisibleNumberInput Component`, (): void => {
211
229
  const onEndMock = jest.fn();
212
230
  const partialInputMock = jest.fn();
213
231
  let callbackInput: () => void;
232
+ const TEST_ID = `invisible-number-input-test-id`;
214
233
 
215
234
  const NumberInput = render(
216
235
  <InvisibleNumberInput
@@ -221,12 +240,14 @@ describe(`InvisibleNumberInput Component`, (): void => {
221
240
  partialInput={partialInputMock}
222
241
  visible={(e): (() => void) => (callbackInput = e)}
223
242
  startValue={startValue}
243
+ testID={TEST_ID}
224
244
  />,
225
245
  );
226
246
 
227
- callbackInput();
247
+ // @ts-ignore
248
+ callbackInput?.();
228
249
 
229
- const textInput = NumberInput.queryByA11yLabel(`InvisibleNumberInput`);
250
+ const textInput = NumberInput.getByTestId(TEST_ID);
230
251
  fireEvent(textInput, `onChangeText`, startValue);
231
252
  expect(partialInputMock).toBeCalledWith(expected);
232
253
  });
@@ -244,6 +265,7 @@ describe(`InvisibleNumberInput Component`, (): void => {
244
265
  const onEndMock = jest.fn();
245
266
  const partialInputMock = jest.fn();
246
267
  let callbackInput: () => void;
268
+ const TEST_ID = `invisible-number-input-test-id`;
247
269
 
248
270
  const NumberInput = render(
249
271
  <InvisibleNumberInput
@@ -254,12 +276,14 @@ describe(`InvisibleNumberInput Component`, (): void => {
254
276
  partialInput={partialInputMock}
255
277
  visible={(e): (() => void) => (callbackInput = e)}
256
278
  startValue={startValue}
279
+ testID={TEST_ID}
257
280
  />,
258
281
  );
259
282
 
260
- callbackInput();
283
+ // @ts-ignore
284
+ callbackInput?.();
261
285
 
262
- const textInput = NumberInput.queryByA11yLabel(`InvisibleNumberInput`);
286
+ const textInput = NumberInput.getByTestId(TEST_ID);
263
287
  fireEvent(textInput, `onChangeText`, startValue);
264
288
  expect(partialInputMock).toBeCalledWith(startValue);
265
289
 
@@ -1,28 +1,9 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
22
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
4
  };
24
5
  Object.defineProperty(exports, "__esModule", { value: true });
25
- const Calculator = __importStar(require("@hedia/recommendation-calculator"));
6
+ const types_1 = require("@hedia/types");
26
7
  const react_1 = require("@lingui/react");
27
8
  const react_2 = __importDefault(require("react"));
28
9
  const react_native_testing_library_1 = require("react-native-testing-library");
@@ -31,10 +12,11 @@ const i18nUtils_1 = require("../../locale/i18nUtils");
31
12
  const enum_1 = require("../../types/enum");
32
13
  const AttentionMessages_1 = require("../../utils/AttentionMessages");
33
14
  const utils_1 = require("../utils");
15
+ const SAFETY_INSULIN_LIMIT = types_1.BolusCalculator.Constants.SAFETY_INSULIN_LIMIT;
34
16
  describe(`Info Bars Component`, () => {
35
17
  afterEach(react_native_testing_library_1.cleanup);
36
18
  beforeEach(() => {
37
- i18nUtils_1.i18n.activate(enum_1.Language.en);
19
+ i18nUtils_1.i18n.activate(types_1.Languages.en);
38
20
  });
39
21
  test(`Can call the callback`, () => {
40
22
  const onPressNextButton = jest.fn();
@@ -43,19 +25,18 @@ describe(`Info Bars Component`, () => {
43
25
  onPressNextButton,
44
26
  };
45
27
  const limitationMessage = react_native_testing_library_1.render(<LimitationMessage_1.default {...props}/>);
46
- const nextButton = limitationMessage.queryByA11yLabel(`nextButtonModal`);
47
- expect(nextButton).not.toBeNull();
28
+ const nextButton = limitationMessage.getByTestId(enum_1.LimitationMessageTestIds.OkButton);
48
29
  react_native_testing_library_1.fireEvent(nextButton, `onPress`);
49
30
  expect(onPressNextButton).toBeCalled();
50
31
  });
51
32
  test.each `
52
- language | locale | message
53
- ${`English`} | ${enum_1.Language.en} | ${`Your recommendation would have been higher than ${Calculator.SAFETY_INSULIN_LIMIT} units of insulin, but it has been limited for safety reasons. Hedia never recommends more than ${Calculator.SAFETY_INSULIN_LIMIT} units of insulin per calculation.`}
54
- ${`Danish`} | ${enum_1.Language.da} | ${`Din anbefaling ville have været højere end ${Calculator.SAFETY_INSULIN_LIMIT} units af insulin, men den er blevet begrænset af sikkerhedshensyn. Hedia anbefaler aldrig mere end ${Calculator.SAFETY_INSULIN_LIMIT} units af insulin per beregning.`}
55
- ${`German`} | ${enum_1.Language.de} | ${`Ihre Empfehlung wäre höher als ${Calculator.SAFETY_INSULIN_LIMIT} Einheiten Insulin gewesen, aber sie wurde aus Sicherheitsgründen begrenzt. Hedia empfiehlt nie mehr als ${Calculator.SAFETY_INSULIN_LIMIT} Einheiten Insulin pro Berechnung.`}
56
- ${`Spanish`} | ${enum_1.Language.es} | ${`Su recomendación habría sido superior a ${Calculator.SAFETY_INSULIN_LIMIT} unidades de insulina, pero se ha limitado por razones de seguridad. Hedia nunca recomienda más de ${Calculator.SAFETY_INSULIN_LIMIT} unidades de insulina por calculación.`}
57
- ${`Italian`} | ${enum_1.Language.it} | ${`La tua prescrizione sarebbe stata superiore a ${Calculator.SAFETY_INSULIN_LIMIT} unità di insulina, ma è stata limitata per motivi di sicurezza. Hedia non prescrive mai più di ${Calculator.SAFETY_INSULIN_LIMIT} unità di insulina per calcolo.`}
58
- ${`French`} | ${enum_1.Language.fr} | ${`Votre recommandation aurait été supérieure à ${Calculator.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 ${Calculator.SAFETY_INSULIN_LIMIT} unités d’insuline par calcul.`}
33
+ 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.`}
59
40
  `(`Can display limitation message in $language`, ({ message, locale }) => {
60
41
  i18nUtils_1.i18n.activate(locale);
61
42
  const onPressNextButton = jest.fn();
@@ -1,17 +1,19 @@
1
- import * as Calculator from "@hedia/recommendation-calculator";
1
+ import { BolusCalculator, Languages } from "@hedia/types";
2
2
  import { I18nProvider } from "@lingui/react";
3
3
  import React from "react";
4
4
  import { cleanup, fireEvent, render } from "react-native-testing-library";
5
5
  import LimitationMessage, { ILimitationMessageProps } from "../../components/LimitationMessage";
6
6
  import { i18n } from "../../locale/i18nUtils";
7
- import { Language } from "../../types/enum";
7
+ import { LimitationMessageTestIds } from "../../types/enum";
8
8
  import { Messages } from "../../utils/AttentionMessages";
9
9
  import { expectTextExists } from "../utils";
10
10
 
11
+ const SAFETY_INSULIN_LIMIT = BolusCalculator.Constants.SAFETY_INSULIN_LIMIT;
12
+
11
13
  describe(`Info Bars Component`, (): void => {
12
14
  afterEach(cleanup);
13
15
  beforeEach((): void => {
14
- i18n.activate(Language.en);
16
+ i18n.activate(Languages.en);
15
17
  });
16
18
 
17
19
  test(`Can call the callback`, (): void => {
@@ -21,23 +23,23 @@ describe(`Info Bars Component`, (): void => {
21
23
  onPressNextButton,
22
24
  };
23
25
  const limitationMessage = render(<LimitationMessage {...props} />);
24
- const nextButton = limitationMessage.queryByA11yLabel(`nextButtonModal`);
25
- expect(nextButton).not.toBeNull();
26
+ const nextButton = limitationMessage.getByTestId(LimitationMessageTestIds.OkButton);
27
+
26
28
  fireEvent(nextButton, `onPress`);
27
29
  expect(onPressNextButton).toBeCalled();
28
30
  });
29
31
 
30
32
  test.each`
31
- language | locale | message
32
- ${`English`} | ${Language.en} | ${`Your recommendation would have been higher than ${Calculator.SAFETY_INSULIN_LIMIT} units of insulin, but it has been limited for safety reasons. Hedia never recommends more than ${Calculator.SAFETY_INSULIN_LIMIT} units of insulin per calculation.`}
33
- ${`Danish`} | ${Language.da} | ${`Din anbefaling ville have været højere end ${Calculator.SAFETY_INSULIN_LIMIT} units af insulin, men den er blevet begrænset af sikkerhedshensyn. Hedia anbefaler aldrig mere end ${Calculator.SAFETY_INSULIN_LIMIT} units af insulin per beregning.`}
34
- ${`German`} | ${Language.de} | ${`Ihre Empfehlung wäre höher als ${Calculator.SAFETY_INSULIN_LIMIT} Einheiten Insulin gewesen, aber sie wurde aus Sicherheitsgründen begrenzt. Hedia empfiehlt nie mehr als ${Calculator.SAFETY_INSULIN_LIMIT} Einheiten Insulin pro Berechnung.`}
35
- ${`Spanish`} | ${Language.es} | ${`Su recomendación habría sido superior a ${Calculator.SAFETY_INSULIN_LIMIT} unidades de insulina, pero se ha limitado por razones de seguridad. Hedia nunca recomienda más de ${Calculator.SAFETY_INSULIN_LIMIT} unidades de insulina por calculación.`}
36
- ${`Italian`} | ${Language.it} | ${`La tua prescrizione sarebbe stata superiore a ${Calculator.SAFETY_INSULIN_LIMIT} unità di insulina, ma è stata limitata per motivi di sicurezza. Hedia non prescrive mai più di ${Calculator.SAFETY_INSULIN_LIMIT} unità di insulina per calcolo.`}
37
- ${`French`} | ${Language.fr} | ${`Votre recommandation aurait été supérieure à ${Calculator.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 ${Calculator.SAFETY_INSULIN_LIMIT} unités d’insuline par calcul.`}
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.`}
38
40
  `(
39
41
  `Can display limitation message in $language`,
40
- ({ message, locale }: { locale: Language; message: string }): void => {
42
+ ({ message, locale }: { locale: Languages; message: string }): void => {
41
43
  i18n.activate(locale);
42
44
  const onPressNextButton = jest.fn();
43
45
  const props: ILimitationMessageProps = {
File without changes
@@ -3,26 +3,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const types_1 = require("@hedia/types");
6
7
  const react_1 = __importDefault(require("react"));
7
8
  const react_native_testing_library_1 = require("react-native-testing-library");
8
9
  const MoodIcon_1 = __importDefault(require("../../components/mood/MoodIcon"));
9
- const enum_1 = require("../../types/enum");
10
+ const MoodEnum = types_1.Logbook.Enums.MoodEnum;
10
11
  describe(`MoodIcon - Component`, () => {
11
12
  afterEach(react_native_testing_library_1.cleanup);
12
13
  test.each `
13
14
  mood | moodName
14
- ${enum_1.MoodEnum.Happy} | ${enum_1.MoodEnum[enum_1.MoodEnum.Happy]}
15
- ${enum_1.MoodEnum.SemiHappy} | ${enum_1.MoodEnum[enum_1.MoodEnum.SemiHappy]}
16
- ${enum_1.MoodEnum.Neutral} | ${enum_1.MoodEnum[enum_1.MoodEnum.Neutral]}
17
- ${enum_1.MoodEnum.SemiSad} | ${enum_1.MoodEnum[enum_1.MoodEnum.SemiSad]}
18
- ${enum_1.MoodEnum.Sad} | ${enum_1.MoodEnum[enum_1.MoodEnum.Sad]}
15
+ ${MoodEnum.Happy} | ${MoodEnum[MoodEnum.Happy]}
16
+ ${MoodEnum.SemiHappy} | ${MoodEnum[MoodEnum.SemiHappy]}
17
+ ${MoodEnum.Neutral} | ${MoodEnum[MoodEnum.Neutral]}
18
+ ${MoodEnum.SemiSad} | ${MoodEnum[MoodEnum.SemiSad]}
19
+ ${MoodEnum.Sad} | ${MoodEnum[MoodEnum.Sad]}
19
20
  `(`Mounting $moodName smiley is mounted inactive and can be toggled on`, ({ mood, moodName }) => {
20
21
  let active = false;
21
22
  const onPressMock = jest.fn((toggle) => (active = toggle));
22
23
  const wrapper = react_native_testing_library_1.render(<MoodIcon_1.default active={active} mood={mood} onPress={onPressMock}/>);
23
24
  const getButton = (isActive) => wrapper.getByA11yLabel(`${moodName}_${isActive}`);
24
- expect(getButton(false)).not.toBeNull();
25
- react_native_testing_library_1.fireEvent(getButton(false), `onPress`);
25
+ const button = getButton(false);
26
+ if (button === null) {
27
+ return fail(`No button found for getByA11yLabel: ${moodName}_${false}`);
28
+ }
29
+ react_native_testing_library_1.fireEvent(button, `onPress`);
26
30
  expect(onPressMock).toBeCalledWith(true);
27
31
  expect(active).toBe(true);
28
32
  wrapper.rerender(<MoodIcon_1.default active={active} mood={mood} onPress={onPressMock}/>);
@@ -1,7 +1,10 @@
1
+ import { Logbook } from "@hedia/types";
1
2
  import React from "react";
2
3
  import { cleanup, fireEvent, render } from "react-native-testing-library";
4
+ import { ReactTestInstance } from "react-test-renderer";
3
5
  import MoodIcon from "../../components/mood/MoodIcon";
4
- import { MoodEnum } from "../../types/enum";
6
+
7
+ const MoodEnum = Logbook.Enums.MoodEnum;
5
8
 
6
9
  describe(`MoodIcon - Component`, (): void => {
7
10
  afterEach(cleanup);
@@ -15,16 +18,21 @@ describe(`MoodIcon - Component`, (): void => {
15
18
  ${MoodEnum.Sad} | ${MoodEnum[MoodEnum.Sad]}
16
19
  `(
17
20
  `Mounting $moodName smiley is mounted inactive and can be toggled on`,
18
- ({ mood, moodName }: { mood: MoodEnum; moodName: string }): void => {
21
+ ({ mood, moodName }: { mood: Logbook.Enums.MoodEnum; moodName: string }): void => {
19
22
  let active = false;
20
23
  const onPressMock = jest.fn((toggle): boolean => (active = toggle));
21
24
  const wrapper = render(<MoodIcon active={active} mood={mood} onPress={onPressMock} />);
22
25
 
23
- const getButton = (isActive: boolean): void => wrapper.getByA11yLabel(`${moodName}_${isActive}`);
26
+ const getButton = (isActive: boolean): ReactTestInstance | null =>
27
+ wrapper.getByA11yLabel(`${moodName}_${isActive}`);
28
+
29
+ const button = getButton(false);
24
30
 
25
- expect(getButton(false)).not.toBeNull();
31
+ if (button === null) {
32
+ return fail(`No button found for getByA11yLabel: ${moodName}_${false}`);
33
+ }
26
34
 
27
- fireEvent(getButton(false), `onPress`);
35
+ fireEvent(button, `onPress`);
28
36
 
29
37
  expect(onPressMock).toBeCalledWith(true);
30
38
  expect(active).toBe(true);