@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
@@ -1,23 +1,31 @@
1
- import { IRecommendationParams } from "@hedia/recommendation-calculator";
2
- import { ActivityIntensity, IActivityParams } from "@hedia/recommendation-calculator/src/RecommendationCalculator";
3
- import { BloodGlucoseUnit, BloodKetonesUnit } from "@hedia/types";
1
+ import { Activity, BloodGlucoseUnit, BloodKetonesUnit, Languages, UserSettings } from "@hedia/types";
4
2
  import { I18nProvider } from "@lingui/react";
5
3
  import React from "react";
6
4
  import { RenderAPI } from "react-native-testing-library";
5
+ import { ReactTestInstance } from "react-test-renderer";
7
6
  import { i18n } from "../locale/i18nUtils";
8
7
  import { IRecommendationProps } from "../RecommendationScreen";
9
- import { ActivityEnum, InjectionMethod, Language } from "../types/enum";
8
+ import { TestIdEnum } from "../types/enum";
9
+ import { IActivityParams, IRecommendationParams, logbookEntry } from "../types/types";
10
+
11
+ const ActivityEnum = Activity.Enums.ActivityEnum;
12
+ const ActivityIntensity = Activity.Enums.ActivityIntensity;
13
+ const InjectionMethod = UserSettings.Enums.InjectionMethod;
14
+
15
+ const { Run } = ActivityEnum;
16
+ const { moderate } = ActivityIntensity;
17
+ const { PenHalf } = InjectionMethod;
10
18
 
11
19
  export function getRecommendationProps(partials?: Partial<IRecommendationProps>): IRecommendationProps {
12
20
  return {
13
21
  currentBKL: partials?.currentBKL ?? 0.1,
14
22
  bloodKetoneUnit: partials?.bloodKetoneUnit ?? BloodKetonesUnit.MMOL_L,
15
23
  bloodGlucoseUnit: partials?.bloodGlucoseUnit ?? BloodGlucoseUnit.MMOL_L,
16
- language: partials?.language ?? Language.en,
24
+ language: partials?.language ?? Languages.en,
17
25
  userReminder: partials?.userReminder ?? 1.5,
18
- latestLogbookFrom6Hours: partials?.latestLogbookFrom6Hours,
26
+ latestLogbookFrom6Hours: partials?.latestLogbookFrom6Hours ?? generateDefaultLogbook(),
19
27
  calculatorParams: partials?.calculatorParams ?? generateDefaultCalculatorParams(),
20
- injectionMethod: partials?.injectionMethod ?? InjectionMethod.PenHalf,
28
+ injectionMethod: partials?.injectionMethod ?? PenHalf,
21
29
  transferToLogbook: partials?.transferToLogbook ?? jest.fn(),
22
30
  onError: partials?.onError ?? jest.fn(),
23
31
  onRecentInsulinYes: partials?.onRecentInsulinYes ?? jest.fn(),
@@ -28,7 +36,7 @@ export function getRecommendationProps(partials?: Partial<IRecommendationProps>)
28
36
  restartCalculation: partials?.restartCalculation ?? jest.fn(),
29
37
  activityDisplayProps: partials?.activityDisplayProps ?? {
30
38
  activityTitle: `Activity Title Test`,
31
- activityType: ActivityEnum.Run,
39
+ activityType: Run,
32
40
  },
33
41
  };
34
42
  }
@@ -50,6 +58,7 @@ export function generateDefaultCalculatorParams(): IRecommendationParams {
50
58
  secondsPassed: 10000,
51
59
  },
52
60
  ],
61
+ activity: null,
53
62
  };
54
63
  }
55
64
 
@@ -57,14 +66,42 @@ export function generateActivityProps(): IActivityParams {
57
66
  return {
58
67
  activityDate: new Date(),
59
68
  activityDuration: 30,
60
- activityIntensity: ActivityIntensity.Moderate,
61
- activitySettings: {
62
- hard: { fromFortysix: null, fromThirty: 0.25, fromZero: 1 },
63
- light: { fromFortysix: 0.5, fromThirty: 0.75, fromZero: 1 },
64
- moderate: { fromFortysix: 0.25, fromThirty: 0.5, fromZero: 1 },
65
- post: { fromFortysix: 0.5, fromThirty: 0.5, fromZero: 1 },
66
- target: 9,
67
- },
69
+ activityIntensity: moderate,
70
+ activitySettings: generateDefaultActivitySettings(),
71
+ };
72
+ }
73
+
74
+ export function generateDefaultActivitySettings(): IActivityParams["activitySettings"] {
75
+ return {
76
+ hard: { fromFortysix: null, fromThirty: 0.25, fromZero: 1 },
77
+ light: { fromFortysix: 0.5, fromThirty: 0.75, fromZero: 1 },
78
+ moderate: { fromFortysix: 0.25, fromThirty: 0.5, fromZero: 1 },
79
+ post: { fromFortysix: 0.5, fromThirty: 0.5, fromZero: 1 },
80
+ target: 9,
81
+ };
82
+ }
83
+ export function generateDefaultLogbook(): logbookEntry {
84
+ return {
85
+ blood_glucose_millimolar: 6,
86
+ carbohydrates_entered_grams: 25,
87
+ carbohydrates_suggested_grams: 25,
88
+ client_timestamp: `25`,
89
+ client_version: `25`,
90
+ entry_timestamp: `25`,
91
+ event_uuid: null,
92
+ insulin_entered_units: 25,
93
+ insulin_suggested_units: 25,
94
+ is_deleted: null,
95
+ mood: 2,
96
+ settings_uuid: `25`,
97
+ uuid: `aaa`,
98
+ device_and_os: `ios 12.1.2`,
99
+ overwritten_by_id: null,
100
+ server_timestamp: null,
101
+ server_version: null,
102
+ utc_timezone_offset: null,
103
+ blood_ketones_millimolar: null,
104
+ carbohydrates_modified_suggested_grams: null,
68
105
  };
69
106
  }
70
107
 
@@ -78,6 +115,12 @@ export function expectTextExists(component: RenderAPI, text: string | RegExp): v
78
115
  return expect(element).not.toBeNull();
79
116
  }
80
117
 
118
+ export function queryTextFromComponent(wrapper: RenderAPI, testID: TestIdEnum): string {
119
+ const component = wrapper.getByTestId(testID);
120
+ const values = component.children;
121
+ return values.join(``);
122
+ }
123
+
81
124
  export function expectTextNotExists(component: RenderAPI, text: string | RegExp): void {
82
125
  const element = component.queryByText(text);
83
126
  /*
@@ -95,3 +138,7 @@ export function i18nProvided(element: JSX.Element): JSX.Element {
95
138
  </I18nProvider>
96
139
  );
97
140
  }
141
+
142
+ export function getIcon(wrapper: RenderAPI, name: string, active: boolean): ReactTestInstance | null {
143
+ return wrapper.queryByA11yLabel(`${name}_${active}`);
144
+ }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -8,6 +8,7 @@ const macro_1 = require("@lingui/macro");
8
8
  const react_1 = __importDefault(require("react"));
9
9
  const react_native_1 = require("react-native");
10
10
  const i18nUtils_1 = require("../locale/i18nUtils");
11
+ const enum_1 = require("../types/enum");
11
12
  const Constants_1 = require("../utils/Constants");
12
13
  const Icon_1 = __importDefault(require("./Icon"));
13
14
  class Header extends react_1.default.Component {
@@ -18,7 +19,7 @@ class Header extends react_1.default.Component {
18
19
  <react_native_1.View style={exports.headerStyles.margin}>
19
20
  <react_native_1.View style={exports.headerStyles.exitButtonContainer}>
20
21
  <react_native_1.View style={exports.headerStyles.exitButton}>
21
- <react_native_1.TouchableOpacity testID="closeCalc" accessibilityLabel="exitButton" style={exports.headerStyles.exitButton} onPress={this.props.exitCallback}>
22
+ <react_native_1.TouchableOpacity testID={enum_1.HeaderTestIds.ExitCalculation} accessibilityLabel="exitButton" style={exports.headerStyles.exitButton} onPress={this.props.exitCallback}>
22
23
  <Icon_1.default iconIdentifier={`Ionicons/ios-close-circle-outline`} style={exports.headerStyles.iconStyle}/>
23
24
  </react_native_1.TouchableOpacity>
24
25
  <react_native_1.View style={exports.headerStyles.headerFiller}/>
@@ -2,6 +2,7 @@ import { t } from "@lingui/macro";
2
2
  import React from "react";
3
3
  import { Dimensions, SafeAreaView, StyleSheet, Text, TouchableOpacity, View } from "react-native";
4
4
  import { i18n } from "../locale/i18nUtils";
5
+ import { HeaderTestIds } from "../types/enum";
5
6
  import { BACKGROUND_COLOUR_PURPLE, BORDER_COLOUR_GREY } from "../utils/Constants";
6
7
  import Icon from "./Icon";
7
8
 
@@ -19,7 +20,7 @@ export default class Header extends React.Component<IProps> {
19
20
  <View style={headerStyles.exitButtonContainer}>
20
21
  <View style={headerStyles.exitButton}>
21
22
  <TouchableOpacity
22
- testID="closeCalc"
23
+ testID={HeaderTestIds.ExitCalculation}
23
24
  accessibilityLabel="exitButton"
24
25
  style={headerStyles.exitButton}
25
26
  onPress={this.props.exitCallback}
File without changes
@@ -2,7 +2,7 @@ import { BloodGlucoseUnit, BloodKetonesUnit } from "@hedia/types";
2
2
  import React from "react";
3
3
  export interface IProps {
4
4
  label: string;
5
- value?: string;
5
+ value: string | null;
6
6
  unit: string | BloodGlucoseUnit | BloodKetonesUnit;
7
7
  showNullAsDash: boolean;
8
8
  }
File without changes
@@ -8,7 +8,7 @@ import { Utils } from "../utils/Utils";
8
8
 
9
9
  export interface IProps {
10
10
  label: string;
11
- value?: string;
11
+ value: string | null;
12
12
  unit: string | BloodGlucoseUnit | BloodKetonesUnit;
13
13
  showNullAsDash: boolean;
14
14
  }
@@ -6,6 +6,7 @@ interface IProps {
6
6
  cleanPartialInput: boolean;
7
7
  negativeAllowed: boolean;
8
8
  maxLength?: number;
9
+ testID: string;
9
10
  visible(toggle: () => void): void;
10
11
  onEnd?(value: number): void;
11
12
  partialInput?(value: string): void;
@@ -14,7 +15,7 @@ interface IState {
14
15
  value: string;
15
16
  }
16
17
  export default class InvisibleNumberInput extends React.Component<IProps, IState> {
17
- textInput: TextInput;
18
+ textInput?: TextInput;
18
19
  state: IState;
19
20
  componentDidMount(): void;
20
21
  cleanInput: (text: string) => string;
@@ -47,11 +47,16 @@ class InvisibleNumberInput extends react_1.default.Component {
47
47
  this.setState({
48
48
  value: this.props.startValue ?? `0`,
49
49
  });
50
- return this.textInput.focus();
50
+ return this.textInput?.focus();
51
51
  });
52
52
  }
53
53
  render() {
54
- return (<react_native_1.TextInput accessibilityLabel="InvisibleNumberInput" value={`${this.state.value}`} ref={(textInput) => (this.textInput = textInput)} style={inputStyles.textInput} keyboardType="numeric" onChangeText={this.handleOnChangeText} onEndEditing={this.onEndEdit} maxLength={this.props.maxLength} selectTextOnFocus/>);
54
+ const { testID } = this.props;
55
+ return (<react_native_1.TextInput testID={testID} accessibilityLabel="InvisibleNumberInput" value={`${this.state.value}`} ref={(textInput) => {
56
+ if (textInput !== null) {
57
+ this.textInput = textInput;
58
+ }
59
+ }} style={inputStyles.textInput} keyboardType="numeric" onChangeText={this.handleOnChangeText} onEndEditing={this.onEndEdit} maxLength={this.props.maxLength} selectTextOnFocus/>);
55
60
  }
56
61
  }
57
62
  exports.default = InvisibleNumberInput;
@@ -7,6 +7,7 @@ interface IProps {
7
7
  cleanPartialInput: boolean;
8
8
  negativeAllowed: boolean;
9
9
  maxLength?: number;
10
+ testID: string;
10
11
  visible(toggle: () => void): void;
11
12
  onEnd?(value: number): void;
12
13
  partialInput?(value: string): void;
@@ -17,7 +18,7 @@ interface IState {
17
18
  }
18
19
 
19
20
  export default class InvisibleNumberInput extends React.Component<IProps, IState> {
20
- public textInput: TextInput;
21
+ public textInput?: TextInput;
21
22
 
22
23
  public state: IState = {
23
24
  value: `0`,
@@ -31,7 +32,7 @@ export default class InvisibleNumberInput extends React.Component<IProps, IState
31
32
  this.setState({
32
33
  value: this.props.startValue ?? `0`,
33
34
  });
34
- return this.textInput.focus();
35
+ return this.textInput?.focus();
35
36
  });
36
37
  }
37
38
 
@@ -66,11 +67,17 @@ export default class InvisibleNumberInput extends React.Component<IProps, IState
66
67
  };
67
68
 
68
69
  public render(): JSX.Element {
70
+ const { testID } = this.props;
69
71
  return (
70
72
  <TextInput
73
+ testID={testID}
71
74
  accessibilityLabel="InvisibleNumberInput"
72
75
  value={`${this.state.value}`}
73
- ref={(textInput): TextInput => (this.textInput = textInput)}
76
+ ref={(textInput): void => {
77
+ if (textInput !== null) {
78
+ this.textInput = textInput;
79
+ }
80
+ }}
74
81
  style={inputStyles.textInput}
75
82
  keyboardType="numeric"
76
83
  onChangeText={this.handleOnChangeText}
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { AttentionMessage } from "../utils/AttentionMessages";
3
3
  export interface ILimitationMessageProps {
4
- limitationMessage: AttentionMessage;
4
+ limitationMessage: AttentionMessage | null;
5
5
  onPressNextButton(): void;
6
6
  }
7
7
  export default class LimitationMessage extends React.Component<ILimitationMessageProps> {
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -23,6 +23,7 @@ const macro_1 = require("@lingui/macro");
23
23
  const React = __importStar(require("react"));
24
24
  const react_native_1 = require("react-native");
25
25
  const i18nUtils_1 = require("../locale/i18nUtils");
26
+ const enum_1 = require("../types/enum");
26
27
  const RecommendationModal_1 = require("./RecommendationModal");
27
28
  class LimitationMessage extends React.Component {
28
29
  constructor() {
@@ -37,7 +38,7 @@ class LimitationMessage extends React.Component {
37
38
  <react_native_1.Text style={RecommendationModal_1.stylesModal.textMessage}>{limitationMessage}</react_native_1.Text>
38
39
  </react_native_1.View>
39
40
  <react_native_1.View style={RecommendationModal_1.stylesModal.containerAcceptButton}>
40
- <react_native_1.TouchableOpacity accessibilityLabel="nextButtonModal" style={RecommendationModal_1.stylesModal.okButton} onPress={this.props.onPressNextButton}>
41
+ <react_native_1.TouchableOpacity testID={enum_1.LimitationMessageTestIds.OkButton} accessibilityLabel="nextButtonModal" style={RecommendationModal_1.stylesModal.okButton} onPress={this.props.onPressNextButton}>
41
42
  <react_native_1.Text style={RecommendationModal_1.stylesModal.buttonText}>{i18nUtils_1.i18n._(macro_1.t `OK`)}</react_native_1.Text>
42
43
  </react_native_1.TouchableOpacity>
43
44
  </react_native_1.View>
@@ -2,11 +2,12 @@ import { t } from "@lingui/macro";
2
2
  import * as React from "react";
3
3
  import { Text, TouchableOpacity, View } from "react-native";
4
4
  import { i18n } from "../locale/i18nUtils";
5
+ import { LimitationMessageTestIds } from "../types/enum";
5
6
  import { AttentionMessage } from "../utils/AttentionMessages";
6
7
  import { stylesModal } from "./RecommendationModal";
7
8
 
8
9
  export interface ILimitationMessageProps {
9
- limitationMessage: AttentionMessage;
10
+ limitationMessage: AttentionMessage | null;
10
11
  onPressNextButton(): void;
11
12
  }
12
13
 
@@ -23,6 +24,7 @@ export default class LimitationMessage extends React.Component<ILimitationMessag
23
24
  </View>
24
25
  <View style={stylesModal.containerAcceptButton}>
25
26
  <TouchableOpacity
27
+ testID={LimitationMessageTestIds.OkButton}
26
28
  accessibilityLabel="nextButtonModal"
27
29
  style={stylesModal.okButton}
28
30
  onPress={this.props.onPressNextButton}
File without changes
File without changes
File without changes
File without changes
@@ -7,6 +7,7 @@ const macro_1 = require("@lingui/macro");
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const react_native_1 = require("react-native");
9
9
  const i18nUtils_1 = require("../locale/i18nUtils");
10
+ const enum_1 = require("../types/enum");
10
11
  const InfoBars_1 = require("./InfoBars");
11
12
  class RecentInsulin extends react_1.default.Component {
12
13
  constructor() {
@@ -23,10 +24,10 @@ class RecentInsulin extends react_1.default.Component {
23
24
  </react_native_1.View>
24
25
  <react_native_1.View style={recentInsulinStyles.buttonContainer}>
25
26
  <react_native_1.View style={recentInsulinStyles.filler}/>
26
- <react_native_1.TouchableOpacity onPress={this.props.onRecentInsulinYes} style={[recentInsulinStyles.yesNoContainer, { marginRight: `2%` }]}>
27
+ <react_native_1.TouchableOpacity testID={enum_1.RecentInsulinTestIds.Yes} onPress={this.props.onRecentInsulinYes} style={[recentInsulinStyles.yesNoContainer, { marginRight: `2%` }]}>
27
28
  <react_native_1.Text style={recentInsulinStyles.yesNoText}>{i18nUtils_1.i18n._(macro_1.t `Yes`)}</react_native_1.Text>
28
29
  </react_native_1.TouchableOpacity>
29
- <react_native_1.TouchableOpacity onPress={this.props.onRecentInsulinNo} style={[recentInsulinStyles.yesNoContainer, { marginLeft: `2%` }]}>
30
+ <react_native_1.TouchableOpacity testID={enum_1.RecentInsulinTestIds.No} onPress={this.props.onRecentInsulinNo} style={[recentInsulinStyles.yesNoContainer, { marginLeft: `2%` }]}>
30
31
  <react_native_1.Text style={recentInsulinStyles.yesNoText}>{i18nUtils_1.i18n._(macro_1.t `No`)}</react_native_1.Text>
31
32
  </react_native_1.TouchableOpacity>
32
33
  <react_native_1.View style={recentInsulinStyles.filler}/>
@@ -2,6 +2,7 @@ import { t } from "@lingui/macro";
2
2
  import React from "react";
3
3
  import { Dimensions, StyleSheet, Text, TouchableOpacity, View } from "react-native";
4
4
  import { i18n } from "../locale/i18nUtils";
5
+ import { RecentInsulinTestIds } from "../types/enum";
5
6
  import { infoStyles } from "./InfoBars";
6
7
 
7
8
  interface IProps {
@@ -24,12 +25,14 @@ export default class RecentInsulin extends React.Component<IProps> {
24
25
  <View style={recentInsulinStyles.buttonContainer}>
25
26
  <View style={recentInsulinStyles.filler} />
26
27
  <TouchableOpacity
28
+ testID={RecentInsulinTestIds.Yes}
27
29
  onPress={this.props.onRecentInsulinYes}
28
30
  style={[recentInsulinStyles.yesNoContainer, { marginRight: `2%` }]}
29
31
  >
30
32
  <Text style={recentInsulinStyles.yesNoText}>{i18n._(t`Yes`)}</Text>
31
33
  </TouchableOpacity>
32
34
  <TouchableOpacity
35
+ testID={RecentInsulinTestIds.No}
33
36
  onPress={this.props.onRecentInsulinNo}
34
37
  style={[recentInsulinStyles.yesNoContainer, { marginLeft: `2%` }]}
35
38
  >
@@ -2,9 +2,9 @@ import * as React from "react";
2
2
  import { AttentionMessage } from "../utils/AttentionMessages";
3
3
  interface IModalProps {
4
4
  isVisible: boolean;
5
- suggestedCarbohydrates?: number;
6
- attentionMessage: AttentionMessage;
7
- limitationMessage: AttentionMessage;
5
+ suggestedCarbohydrates: number | null;
6
+ attentionMessage: AttentionMessage | null;
7
+ limitationMessage: AttentionMessage | null;
8
8
  onClickOkButton(): void;
9
9
  onAcceptCarbohydrates(): void;
10
10
  onDeclineCarbohydrates(): void;
@@ -16,7 +16,7 @@ export default class RecommendationModal extends React.Component<IModalProps, IM
16
16
  constructor(props: IModalProps);
17
17
  onPressNextButton: () => void;
18
18
  recommendationButtons: () => JSX.Element;
19
- recommendCarbohydrates: () => JSX.Element;
19
+ recommendCarbohydrates: (suggestedCarbohydrates: number) => JSX.Element;
20
20
  secondPage: () => JSX.Element;
21
21
  firstPage: () => JSX.Element;
22
22
  render(): JSX.Element;
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -28,6 +28,7 @@ const React = __importStar(require("react"));
28
28
  const react_native_1 = require("react-native");
29
29
  const react_native_modal_1 = __importDefault(require("react-native-modal"));
30
30
  const i18nUtils_1 = require("../locale/i18nUtils");
31
+ const enum_1 = require("../types/enum");
31
32
  const Constants_1 = require("../utils/Constants");
32
33
  const LimitationMessage_1 = __importDefault(require("./LimitationMessage"));
33
34
  class RecommendationModal extends React.Component {
@@ -40,16 +41,16 @@ class RecommendationModal extends React.Component {
40
41
  };
41
42
  this.recommendationButtons = () => {
42
43
  return (<react_native_1.View style={exports.stylesModal.recommendationButtonsContainer}>
43
- <react_native_1.TouchableOpacity accessibilityLabel="yesButtonModal" style={exports.stylesModal.affirmativeCarbsButton} onPress={this.props.onAcceptCarbohydrates}>
44
+ <react_native_1.TouchableOpacity testID={enum_1.RecommendationModalTestIds.AcceptCarbs} accessibilityLabel="yesButtonModal" style={exports.stylesModal.affirmativeCarbsButton} onPress={this.props.onAcceptCarbohydrates}>
44
45
  <react_native_1.Text style={exports.stylesModal.affirmativeCarbsText}>{i18nUtils_1.i18n._(macro_1.t `OK`)}</react_native_1.Text>
45
46
  </react_native_1.TouchableOpacity>
46
- <react_native_1.TouchableOpacity accessibilityLabel="noButtonModal" style={exports.stylesModal.negativeCarbsButton} onPress={this.props.onDeclineCarbohydrates}>
47
+ <react_native_1.TouchableOpacity testID={enum_1.RecommendationModalTestIds.DeclineCarbs} accessibilityLabel="noButtonModal" style={exports.stylesModal.negativeCarbsButton} onPress={this.props.onDeclineCarbohydrates}>
47
48
  <react_native_1.Text style={exports.stylesModal.negativeCarbsText}>{i18nUtils_1.i18n._(macro_1.t `NO`)}</react_native_1.Text>
48
49
  </react_native_1.TouchableOpacity>
49
50
  </react_native_1.View>);
50
51
  };
51
- this.recommendCarbohydrates = () => {
52
- const { suggestedCarbohydrates } = this.props;
52
+ this.recommendCarbohydrates = (suggestedCarbohydrates) => {
53
+ const displayCarbs = Math.round(suggestedCarbohydrates);
53
54
  return (<React.Fragment>
54
55
  <react_native_1.View style={exports.stylesModal.innerView}>
55
56
  <react_native_1.View style={exports.stylesModal.recommendationRow}>
@@ -59,7 +60,7 @@ class RecommendationModal extends React.Component {
59
60
  </react_native_1.View>
60
61
  <react_native_1.View style={exports.stylesModal.suggestedContainer}>
61
62
  <react_native_1.Text style={exports.stylesModal.textCenter}>
62
- <react_native_1.Text style={exports.stylesModal.suggestedCarbs}>{`${Math.round(suggestedCarbohydrates)} `}</react_native_1.Text>
63
+ <react_native_1.Text style={exports.stylesModal.suggestedCarbs} testID={enum_1.RecommendationModalTestIds.SuggestedCarbs}>{`${displayCarbs} `}</react_native_1.Text>
63
64
  <react_native_1.Text style={exports.stylesModal.carbohydrateText}>{i18nUtils_1.i18n._(macro_1.t `grams of carbohydrates`)}</react_native_1.Text>
64
65
  </react_native_1.Text>
65
66
  </react_native_1.View>
@@ -77,17 +78,17 @@ class RecommendationModal extends React.Component {
77
78
  };
78
79
  this.secondPage = () => {
79
80
  const { attentionMessage, suggestedCarbohydrates } = this.props;
80
- const willRecommendCarbs = suggestedCarbohydrates && suggestedCarbohydrates > 0;
81
+ const willRecommendCarbs = suggestedCarbohydrates !== null && suggestedCarbohydrates > 0;
81
82
  return (<React.Fragment>
82
83
  <react_native_1.View style={exports.stylesModal.container}>
83
84
  <react_native_1.View style={exports.stylesModal.titleContainer}>
84
85
  <react_native_1.Text style={exports.stylesModal.textTittleMessage}>{i18nUtils_1.i18n._(macro_1.t `Attention`)}</react_native_1.Text>
85
86
  </react_native_1.View>
86
87
  <react_native_1.Text style={exports.stylesModal.textMessage}>{attentionMessage}</react_native_1.Text>
87
- {willRecommendCarbs ? this.recommendCarbohydrates() : null}
88
+ {willRecommendCarbs ? this.recommendCarbohydrates(suggestedCarbohydrates) : null}
88
89
  </react_native_1.View>
89
90
  {willRecommendCarbs ? null : (<react_native_1.View style={exports.stylesModal.containerAcceptButton}>
90
- <react_native_1.TouchableOpacity accessibilityLabel="okayButtonModal" style={exports.stylesModal.okButton} onPress={this.props.onClickOkButton}>
91
+ <react_native_1.TouchableOpacity testID={enum_1.RecommendationModalTestIds.OkButton} accessibilityLabel="okayButtonModal" style={exports.stylesModal.okButton} onPress={this.props.onClickOkButton}>
91
92
  <react_native_1.Text style={exports.stylesModal.buttonText}>{i18nUtils_1.i18n._(macro_1.t `OK`)}</react_native_1.Text>
92
93
  </react_native_1.TouchableOpacity>
93
94
  </react_native_1.View>)}
@@ -3,15 +3,16 @@ import * as React from "react";
3
3
  import { Dimensions, StyleSheet, Text, TouchableOpacity, View } from "react-native";
4
4
  import ReactNativeModal from "react-native-modal";
5
5
  import { i18n } from "../locale/i18nUtils";
6
+ import { RecommendationModalTestIds } from "../types/enum";
6
7
  import { AttentionMessage } from "../utils/AttentionMessages";
7
8
  import { BORDER_COLOUR_TEAL } from "../utils/Constants";
8
9
  import LimitationMessage from "./LimitationMessage";
9
10
 
10
11
  interface IModalProps {
11
12
  isVisible: boolean;
12
- suggestedCarbohydrates?: number;
13
- attentionMessage: AttentionMessage;
14
- limitationMessage: AttentionMessage;
13
+ suggestedCarbohydrates: number | null;
14
+ attentionMessage: AttentionMessage | null;
15
+ limitationMessage: AttentionMessage | null;
15
16
  onClickOkButton(): void;
16
17
  onAcceptCarbohydrates(): void;
17
18
  onDeclineCarbohydrates(): void;
@@ -26,15 +27,18 @@ export default class RecommendationModal extends React.Component<IModalProps, IM
26
27
  firstPageVisible: !!this.props.limitationMessage,
27
28
  };
28
29
  }
30
+
29
31
  public onPressNextButton = (): void => {
30
32
  const { attentionMessage, suggestedCarbohydrates } = this.props;
31
33
  const isPageVisible = !!attentionMessage || !!suggestedCarbohydrates;
32
34
  return isPageVisible ? this.setState({ firstPageVisible: false }) : this.props.onClickOkButton();
33
35
  };
36
+
34
37
  public recommendationButtons = (): JSX.Element => {
35
38
  return (
36
39
  <View style={stylesModal.recommendationButtonsContainer}>
37
40
  <TouchableOpacity
41
+ testID={RecommendationModalTestIds.AcceptCarbs}
38
42
  accessibilityLabel="yesButtonModal"
39
43
  style={stylesModal.affirmativeCarbsButton}
40
44
  onPress={this.props.onAcceptCarbohydrates}
@@ -42,6 +46,7 @@ export default class RecommendationModal extends React.Component<IModalProps, IM
42
46
  <Text style={stylesModal.affirmativeCarbsText}>{i18n._(t`OK`)}</Text>
43
47
  </TouchableOpacity>
44
48
  <TouchableOpacity
49
+ testID={RecommendationModalTestIds.DeclineCarbs}
45
50
  accessibilityLabel="noButtonModal"
46
51
  style={stylesModal.negativeCarbsButton}
47
52
  onPress={this.props.onDeclineCarbohydrates}
@@ -52,8 +57,9 @@ export default class RecommendationModal extends React.Component<IModalProps, IM
52
57
  );
53
58
  };
54
59
 
55
- public recommendCarbohydrates = (): JSX.Element => {
56
- const { suggestedCarbohydrates } = this.props;
60
+ public recommendCarbohydrates = (suggestedCarbohydrates: number): JSX.Element => {
61
+ const displayCarbs = Math.round(suggestedCarbohydrates);
62
+
57
63
  return (
58
64
  <React.Fragment>
59
65
  <View style={stylesModal.innerView}>
@@ -64,7 +70,10 @@ export default class RecommendationModal extends React.Component<IModalProps, IM
64
70
  </View>
65
71
  <View style={stylesModal.suggestedContainer}>
66
72
  <Text style={stylesModal.textCenter}>
67
- <Text style={stylesModal.suggestedCarbs}>{`${Math.round(suggestedCarbohydrates)} `}</Text>
73
+ <Text
74
+ style={stylesModal.suggestedCarbs}
75
+ testID={RecommendationModalTestIds.SuggestedCarbs}
76
+ >{`${displayCarbs} `}</Text>
68
77
  <Text style={stylesModal.carbohydrateText}>{i18n._(t`grams of carbohydrates`)}</Text>
69
78
  </Text>
70
79
  </View>
@@ -84,7 +93,7 @@ export default class RecommendationModal extends React.Component<IModalProps, IM
84
93
 
85
94
  public secondPage = (): JSX.Element => {
86
95
  const { attentionMessage, suggestedCarbohydrates } = this.props;
87
- const willRecommendCarbs = suggestedCarbohydrates && suggestedCarbohydrates > 0;
96
+ const willRecommendCarbs = suggestedCarbohydrates !== null && suggestedCarbohydrates > 0;
88
97
 
89
98
  return (
90
99
  <React.Fragment>
@@ -93,11 +102,12 @@ export default class RecommendationModal extends React.Component<IModalProps, IM
93
102
  <Text style={stylesModal.textTittleMessage}>{i18n._(t`Attention`)}</Text>
94
103
  </View>
95
104
  <Text style={stylesModal.textMessage}>{attentionMessage}</Text>
96
- {willRecommendCarbs ? this.recommendCarbohydrates() : null}
105
+ {willRecommendCarbs ? this.recommendCarbohydrates(suggestedCarbohydrates!) : null}
97
106
  </View>
98
107
  {willRecommendCarbs ? null : (
99
108
  <View style={stylesModal.containerAcceptButton}>
100
109
  <TouchableOpacity
110
+ testID={RecommendationModalTestIds.OkButton}
101
111
  accessibilityLabel="okayButtonModal"
102
112
  style={stylesModal.okButton}
103
113
  onPress={this.props.onClickOkButton}
@@ -109,6 +119,7 @@ export default class RecommendationModal extends React.Component<IModalProps, IM
109
119
  </React.Fragment>
110
120
  );
111
121
  };
122
+
112
123
  public firstPage = (): JSX.Element => {
113
124
  return (
114
125
  <LimitationMessage
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import { RecommendedCarbsTestIds } from "../types/enum";
2
3
  interface ICalculationRow {
3
4
  label: string;
4
5
  value: string;
@@ -11,16 +12,16 @@ interface IProps {
11
12
  changedRecommendedCarbs(value: number): void;
12
13
  }
13
14
  interface IState {
14
- partialInput: string;
15
+ partialInput?: string;
15
16
  }
16
17
  export default class RecommendedCarbs extends React.Component<IProps, IState> {
17
18
  state: IState;
18
- callbackInput: () => void;
19
+ callbackInput?: () => void;
19
20
  showTextInput: () => void;
20
21
  handlePartialInput: (partialInput: string) => void;
21
22
  handleChangedCarbs: (carbs: number) => void;
22
23
  renderRecommendedCarbs: () => JSX.Element;
23
- renderRow: (row: ICalculationRow) => JSX.Element;
24
+ renderRow: (row: ICalculationRow, testID: RecommendedCarbsTestIds) => JSX.Element;
24
25
  render(): JSX.Element;
25
26
  }
26
27
  export {};