@hedia/recommendation-screen 2.1.34-alpha.9 → 2.1.34

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 (234) hide show
  1. package/{src → dist/src}/RecommendationScreen.d.ts +3 -3
  2. package/{src → dist/src}/RecommendationScreen.js +6 -6
  3. package/{src → dist/src}/locale/da/messages.po +92 -92
  4. package/{src → dist/src}/locale/de/messages.po +92 -92
  5. package/{src → dist/src}/locale/en/messages.po +92 -92
  6. package/{src → dist/src}/locale/es/messages.js +1 -1
  7. package/{src → dist/src}/locale/es/messages.po +92 -92
  8. package/{src → dist/src}/locale/fr/messages.po +92 -92
  9. package/{src → dist/src}/locale/it/messages.po +92 -92
  10. package/package.json +22 -21
  11. package/.flowconfig +0 -65
  12. package/.github/pull_request_template.md +0 -6
  13. package/.github/workflows/ci.yaml +0 -17
  14. package/.github/workflows/publish-release-package.yaml +0 -17
  15. package/.github/workflows/validate-pr-title.yaml +0 -20
  16. package/.linguirc +0 -6
  17. package/.npmpackagejsonlintrc.json +0 -12
  18. package/.prettierignore +0 -2
  19. package/.prettierrc +0 -25
  20. package/Changelog.md +0 -9
  21. package/android/app/BUCK +0 -55
  22. package/android/app/build.gradle +0 -228
  23. package/android/app/build_defs.bzl +0 -19
  24. package/android/app/debug.keystore +0 -0
  25. package/android/app/proguard-rules.pro +0 -10
  26. package/android/app/src/debug/AndroidManifest.xml +0 -13
  27. package/android/app/src/debug/java/com/hediarecommendationscreen/ReactNativeFlipper.java +0 -72
  28. package/android/app/src/main/AndroidManifest.xml +0 -25
  29. package/android/app/src/main/assets/fonts/AntDesign.ttf +0 -0
  30. package/android/app/src/main/assets/fonts/Entypo.ttf +0 -0
  31. package/android/app/src/main/assets/fonts/EvilIcons.ttf +0 -0
  32. package/android/app/src/main/assets/fonts/Feather.ttf +0 -0
  33. package/android/app/src/main/assets/fonts/FontAwesome.ttf +0 -0
  34. package/android/app/src/main/assets/fonts/FontAwesome5_Brands.ttf +0 -0
  35. package/android/app/src/main/assets/fonts/FontAwesome5_Regular.ttf +0 -0
  36. package/android/app/src/main/assets/fonts/FontAwesome5_Solid.ttf +0 -0
  37. package/android/app/src/main/assets/fonts/Fontisto.ttf +0 -0
  38. package/android/app/src/main/assets/fonts/Foundation.ttf +0 -0
  39. package/android/app/src/main/assets/fonts/Ionicons.ttf +0 -0
  40. package/android/app/src/main/assets/fonts/MaterialCommunityIcons.ttf +0 -0
  41. package/android/app/src/main/assets/fonts/MaterialIcons.ttf +0 -0
  42. package/android/app/src/main/assets/fonts/Octicons.ttf +0 -0
  43. package/android/app/src/main/assets/fonts/Roboto-Black.ttf +0 -0
  44. package/android/app/src/main/assets/fonts/Roboto-BlackItalic.ttf +0 -0
  45. package/android/app/src/main/assets/fonts/Roboto-Bold.ttf +0 -0
  46. package/android/app/src/main/assets/fonts/Roboto-BoldItalic.ttf +0 -0
  47. package/android/app/src/main/assets/fonts/Roboto-Italic.ttf +0 -0
  48. package/android/app/src/main/assets/fonts/Roboto-Light.ttf +0 -0
  49. package/android/app/src/main/assets/fonts/Roboto-LightItalic.ttf +0 -0
  50. package/android/app/src/main/assets/fonts/Roboto-Medium.ttf +0 -0
  51. package/android/app/src/main/assets/fonts/Roboto-MediumItalic.ttf +0 -0
  52. package/android/app/src/main/assets/fonts/Roboto-Regular.ttf +0 -0
  53. package/android/app/src/main/assets/fonts/Roboto-Thin.ttf +0 -0
  54. package/android/app/src/main/assets/fonts/Roboto-ThinItalic.ttf +0 -0
  55. package/android/app/src/main/assets/fonts/SimpleLineIcons.ttf +0 -0
  56. package/android/app/src/main/assets/fonts/Zocial.ttf +0 -0
  57. package/android/app/src/main/java/com/hediarecommendationscreen/MainActivity.java +0 -15
  58. package/android/app/src/main/java/com/hediarecommendationscreen/MainApplication.java +0 -80
  59. package/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  60. package/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  61. package/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  62. package/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  63. package/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  64. package/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  65. package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  66. package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  67. package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  68. package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  69. package/android/app/src/main/res/values/color.xml +0 -3
  70. package/android/app/src/main/res/values/strings.xml +0 -3
  71. package/android/app/src/main/res/values/styles.xml +0 -11
  72. package/android/build.gradle +0 -38
  73. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  74. package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  75. package/android/gradle.properties +0 -28
  76. package/android/gradlew +0 -185
  77. package/android/gradlew.bat +0 -89
  78. package/android/settings.gradle +0 -3
  79. package/assets/fonts/Roboto/LICENSE.txt +0 -202
  80. package/assets/fonts/Roboto/Roboto-Black.ttf +0 -0
  81. package/assets/fonts/Roboto/Roboto-BlackItalic.ttf +0 -0
  82. package/assets/fonts/Roboto/Roboto-Bold.ttf +0 -0
  83. package/assets/fonts/Roboto/Roboto-BoldItalic.ttf +0 -0
  84. package/assets/fonts/Roboto/Roboto-Italic.ttf +0 -0
  85. package/assets/fonts/Roboto/Roboto-Light.ttf +0 -0
  86. package/assets/fonts/Roboto/Roboto-LightItalic.ttf +0 -0
  87. package/assets/fonts/Roboto/Roboto-Medium.ttf +0 -0
  88. package/assets/fonts/Roboto/Roboto-MediumItalic.ttf +0 -0
  89. package/assets/fonts/Roboto/Roboto-Regular.ttf +0 -0
  90. package/assets/fonts/Roboto/Roboto-Thin.ttf +0 -0
  91. package/assets/fonts/Roboto/Roboto-ThinItalic.ttf +0 -0
  92. package/babel.config.js +0 -18
  93. package/ignore-git.sh +0 -46
  94. package/ignore-publish.sh +0 -33
  95. package/index-git.sh +0 -5
  96. package/ios/HediaRecommendationScreen/AppDelegate.h +0 -8
  97. package/ios/HediaRecommendationScreen/AppDelegate.m +0 -61
  98. package/ios/HediaRecommendationScreen/Images.xcassets/AppIcon.appiconset/Contents.json +0 -38
  99. package/ios/HediaRecommendationScreen/Images.xcassets/Contents.json +0 -6
  100. package/ios/HediaRecommendationScreen/Info.plist +0 -90
  101. package/ios/HediaRecommendationScreen/LaunchScreen.storyboard +0 -47
  102. package/ios/HediaRecommendationScreen/main.m +0 -9
  103. package/ios/HediaRecommendationScreen.xcodeproj/project.pbxproj +0 -778
  104. package/ios/HediaRecommendationScreen.xcodeproj/xcshareddata/xcschemes/HediaRecommendationScreen-tvOS.xcscheme +0 -88
  105. package/ios/HediaRecommendationScreen.xcodeproj/xcshareddata/xcschemes/HediaRecommendationScreen.xcscheme +0 -88
  106. package/ios/HediaRecommendationScreen.xcworkspace/contents.xcworkspacedata +0 -10
  107. package/ios/HediaRecommendationScreen.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  108. package/ios/HediaRecommendationScreenTests/HediaRecommendationScreenTests.m +0 -65
  109. package/ios/HediaRecommendationScreenTests/Info.plist +0 -24
  110. package/ios/Podfile +0 -32
  111. package/ios/Podfile.lock +0 -544
  112. package/jest.config.js +0 -197
  113. package/jest.mock.js +0 -1
  114. package/metro.config.js +0 -17
  115. package/react-native.config.js +0 -7
  116. package/src/__tests__/RecommendationScreen.test.d.ts +0 -1
  117. package/src/__tests__/RecommendationScreen.test.js +0 -965
  118. package/src/__tests__/RecommendationUtils.test.d.ts +0 -1
  119. package/src/__tests__/RecommendationUtils.test.js +0 -216
  120. package/src/__tests__/Translate.test.d.ts +0 -1
  121. package/src/__tests__/Translate.test.js +0 -27
  122. package/src/__tests__/Utils.test.d.ts +0 -1
  123. package/src/__tests__/Utils.test.js +0 -66
  124. package/src/__tests__/Validations.test.d.ts +0 -1
  125. package/src/__tests__/Validations.test.js +0 -465
  126. package/src/__tests__/components/Activity.test.d.ts +0 -1
  127. package/src/__tests__/components/Activity.test.js +0 -86
  128. package/src/__tests__/components/Emotion.test.d.ts +0 -1
  129. package/src/__tests__/components/Emotion.test.js +0 -70
  130. package/src/__tests__/components/Header.test.d.ts +0 -1
  131. package/src/__tests__/components/Header.test.js +0 -36
  132. package/src/__tests__/components/InfoBars.test.d.ts +0 -1
  133. package/src/__tests__/components/InfoBars.test.js +0 -130
  134. package/src/__tests__/components/InvisibleNumberInput.test.d.ts +0 -1
  135. package/src/__tests__/components/InvisibleNumberInput.test.js +0 -160
  136. package/src/__tests__/components/LimitationMessage.test.d.ts +0 -1
  137. package/src/__tests__/components/LimitationMessage.test.js +0 -47
  138. package/src/__tests__/components/MoodIcon.test.d.ts +0 -1
  139. package/src/__tests__/components/MoodIcon.test.js +0 -30
  140. package/src/__tests__/components/RecommendationModal.test.d.ts +0 -1
  141. package/src/__tests__/components/RecommendationModal.test.js +0 -98
  142. package/src/__tests__/components/RecommendedCarbs.test.d.ts +0 -1
  143. package/src/__tests__/components/RecommendedCarbs.test.js +0 -120
  144. package/src/__tests__/components/RecommendedInsulin.test.d.ts +0 -1
  145. package/src/__tests__/components/RecommendedInsulin.test.js +0 -154
  146. package/src/__tests__/components/Remeasure.test.d.ts +0 -1
  147. package/src/__tests__/components/Remeasure.test.js +0 -78
  148. package/src/__tests__/components/TransferToLogbook.test.d.ts +0 -1
  149. package/src/__tests__/components/TransferToLogbook.test.js +0 -30
  150. package/src/__tests__/components/TwoOptionModal.test.d.ts +0 -1
  151. package/src/__tests__/components/TwoOptionModal.test.js +0 -65
  152. package/src/__tests__/utils.d.ts +0 -16
  153. package/src/__tests__/utils.js +0 -126
  154. package/tsconfig.json +0 -72
  155. package/tslint.json +0 -193
  156. package/typedoc.json +0 -13
  157. /package/{index.d.ts → dist/index.d.ts} +0 -0
  158. /package/{index.js → dist/index.js} +0 -0
  159. /package/{src → dist/src}/assets/activity/Cyclist.png +0 -0
  160. /package/{src → dist/src}/assets/activity/Other.png +0 -0
  161. /package/{src → dist/src}/assets/activity/Runner.png +0 -0
  162. /package/{src → dist/src}/assets/activity/Swimmer.png +0 -0
  163. /package/{src → dist/src}/assets/activity/Walk.png +0 -0
  164. /package/{src → dist/src}/assets/mood/happy.png +0 -0
  165. /package/{src → dist/src}/assets/mood/happy_active.png +0 -0
  166. /package/{src → dist/src}/assets/mood/neutral.png +0 -0
  167. /package/{src → dist/src}/assets/mood/neutral_active.png +0 -0
  168. /package/{src → dist/src}/assets/mood/sad.png +0 -0
  169. /package/{src → dist/src}/assets/mood/sad_active.png +0 -0
  170. /package/{src → dist/src}/assets/mood/semi_happy.png +0 -0
  171. /package/{src → dist/src}/assets/mood/semi_happy_active.png +0 -0
  172. /package/{src → dist/src}/assets/mood/semi_sad.png +0 -0
  173. /package/{src → dist/src}/assets/mood/semi_sad_active.png +0 -0
  174. /package/{src → dist/src}/components/Header.d.ts +0 -0
  175. /package/{src → dist/src}/components/Header.js +0 -0
  176. /package/{src → dist/src}/components/Icon.d.ts +0 -0
  177. /package/{src → dist/src}/components/Icon.js +0 -0
  178. /package/{src → dist/src}/components/InfoBars.d.ts +0 -0
  179. /package/{src → dist/src}/components/InfoBars.js +0 -0
  180. /package/{src → dist/src}/components/InvisibleNumberInput.d.ts +0 -0
  181. /package/{src → dist/src}/components/InvisibleNumberInput.js +0 -0
  182. /package/{src → dist/src}/components/LimitationMessage.d.ts +0 -0
  183. /package/{src → dist/src}/components/LimitationMessage.js +0 -0
  184. /package/{src → dist/src}/components/LineSeparator.d.ts +0 -0
  185. /package/{src → dist/src}/components/LineSeparator.js +0 -0
  186. /package/{src → dist/src}/components/RecentInsulin.d.ts +0 -0
  187. /package/{src → dist/src}/components/RecentInsulin.js +0 -0
  188. /package/{src → dist/src}/components/RecommendationModal.d.ts +0 -0
  189. /package/{src → dist/src}/components/RecommendationModal.js +0 -0
  190. /package/{src → dist/src}/components/RecommendedCarbs.d.ts +0 -0
  191. /package/{src → dist/src}/components/RecommendedCarbs.js +0 -0
  192. /package/{src → dist/src}/components/RecommendedInsulin.d.ts +0 -0
  193. /package/{src → dist/src}/components/RecommendedInsulin.js +0 -0
  194. /package/{src → dist/src}/components/Remeasure.d.ts +0 -0
  195. /package/{src → dist/src}/components/Remeasure.js +0 -0
  196. /package/{src → dist/src}/components/TransferToLogbook.d.ts +0 -0
  197. /package/{src → dist/src}/components/TransferToLogbook.js +0 -0
  198. /package/{src → dist/src}/components/TwoOptionModal.d.ts +0 -0
  199. /package/{src → dist/src}/components/TwoOptionModal.js +0 -0
  200. /package/{src → dist/src}/components/activity/Activity.d.ts +0 -0
  201. /package/{src → dist/src}/components/activity/Activity.js +0 -0
  202. /package/{src → dist/src}/components/activity/ActivityIcon.d.ts +0 -0
  203. /package/{src → dist/src}/components/activity/ActivityIcon.js +0 -0
  204. /package/{src → dist/src}/components/activity/ActivityIntensity.d.ts +0 -0
  205. /package/{src → dist/src}/components/activity/ActivityIntensity.js +0 -0
  206. /package/{src → dist/src}/components/mood/Emotion.d.ts +0 -0
  207. /package/{src → dist/src}/components/mood/Emotion.js +0 -0
  208. /package/{src → dist/src}/components/mood/MoodIcon.d.ts +0 -0
  209. /package/{src → dist/src}/components/mood/MoodIcon.js +0 -0
  210. /package/{src → dist/src}/locale/da/messages.js +0 -0
  211. /package/{src → dist/src}/locale/de/messages.js +0 -0
  212. /package/{src → dist/src}/locale/en/messages.js +0 -0
  213. /package/{src → dist/src}/locale/fr/messages.js +0 -0
  214. /package/{src → dist/src}/locale/i18nUtils.d.ts +0 -0
  215. /package/{src → dist/src}/locale/i18nUtils.js +0 -0
  216. /package/{src → dist/src}/locale/it/messages.js +0 -0
  217. /package/{src → dist/src}/types/enum.d.ts +0 -0
  218. /package/{src → dist/src}/types/enum.js +0 -0
  219. /package/{src → dist/src}/types/types.d.ts +0 -0
  220. /package/{src → dist/src}/types/types.js +0 -0
  221. /package/{src → dist/src}/utils/AttentionMessages.d.ts +0 -0
  222. /package/{src → dist/src}/utils/AttentionMessages.js +0 -0
  223. /package/{src → dist/src}/utils/Constants.d.ts +0 -0
  224. /package/{src → dist/src}/utils/Constants.js +0 -0
  225. /package/{src → dist/src}/utils/RecommendationError.d.ts +0 -0
  226. /package/{src → dist/src}/utils/RecommendationError.js +0 -0
  227. /package/{src → dist/src}/utils/RecommendationUtils.d.ts +0 -0
  228. /package/{src → dist/src}/utils/RecommendationUtils.js +0 -0
  229. /package/{src → dist/src}/utils/Translations.d.ts +0 -0
  230. /package/{src → dist/src}/utils/Translations.js +0 -0
  231. /package/{src → dist/src}/utils/Utils.d.ts +0 -0
  232. /package/{src → dist/src}/utils/Utils.js +0 -0
  233. /package/{src → dist/src}/utils/Validations.d.ts +0 -0
  234. /package/{src → dist/src}/utils/Validations.js +0 -0
@@ -1,154 +0,0 @@
1
- import { BolusCalculator, UserSettings } from "@hedia/types";
2
- import React from "react";
3
- import { Platform } from "react-native";
4
- import { cleanup, fireEvent, render } from "react-native-testing-library";
5
- import RecommendedInsulin from "../../components/RecommendedInsulin";
6
- import { Testing } from "../../types/enum";
7
- import { expectTextExists, expectTextNotExists } from "../utils";
8
- const { RecommendedInsulinTestIds } = Testing.Id;
9
- const SAFETY_INSULIN_LIMIT = BolusCalculator.Constants.SAFETY_INSULIN_LIMIT;
10
- const InjectionMethod = UserSettings.Enums.InjectionMethod;
11
- const { PenHalf, PenWhole, Pump } = InjectionMethod;
12
- describe(`RecommendedInsulin - Component`, () => {
13
- afterEach(cleanup);
14
- test(`Component is rendered`, () => {
15
- const updateMock = jest.fn();
16
- const method = Pump;
17
- const wrapper = render(<RecommendedInsulin insulinRecommendation={2.3} updateRecommendedInsulin={updateMock} injectionMethod={method} activityReduction={null} enteredInsulin={null}/>);
18
- expectTextExists(wrapper, `Recommended amount of insulin`);
19
- expectTextExists(wrapper, `2.3`);
20
- expectTextExists(wrapper, `Units`);
21
- });
22
- test(`Insulin props defaults to 0`, () => {
23
- const updateMock = jest.fn();
24
- const method = PenHalf;
25
- // @ts-ignore
26
- const wrapper = render(<RecommendedInsulin updateRecommendedInsulin={updateMock} injectionMethod={method}/>);
27
- expectTextExists(wrapper, `Recommended amount of insulin`);
28
- expectTextExists(wrapper, `0`);
29
- expectTextExists(wrapper, `Units`);
30
- });
31
- test.each `
32
- method | amount | result
33
- ${PenWhole} | ${1} | ${1}
34
- ${PenWhole} | ${1.49} | ${1}
35
- ${PenWhole} | ${1.5} | ${2}
36
- ${PenHalf} | ${1.24} | ${1}
37
- ${PenHalf} | ${1.25} | ${1.5}
38
- ${PenHalf} | ${1.74} | ${1.5}
39
- ${Pump} | ${1.14} | ${1.1}
40
- ${Pump} | ${1.15} | ${1.2}
41
- ${Pump} | ${12.35} | ${12.4}
42
- `(`Rounding $amount using $method to $result`, ({ amount, method, result, }) => {
43
- const updateMock = jest.fn();
44
- const wrapper = render(
45
- // @ts-ignore
46
- <RecommendedInsulin updateRecommendedInsulin={updateMock} injectionMethod={method}/>);
47
- expectTextExists(wrapper, `Recommended amount of insulin`);
48
- const input = wrapper.getByTestId(RecommendedInsulinTestIds.InvisibleInsulinInput);
49
- fireEvent(input, `onEnd`, amount);
50
- expectTextExists(wrapper, `${result}`);
51
- expect(updateMock).toBeCalledWith(result);
52
- });
53
- test(`Throw error on Unsupported InjectMethod`, () => {
54
- const updateMock = jest.fn();
55
- const wrapper = render(
56
- // @ts-ignore
57
- <RecommendedInsulin updateRecommendedInsulin={updateMock} injectionMethod={`Error`}/>);
58
- expectTextExists(wrapper, `Recommended amount of insulin`);
59
- const input = wrapper.getByTestId(RecommendedInsulinTestIds.InvisibleInsulinInput);
60
- expect(() => fireEvent(input, `onEnd`)).toThrowError(`Unsupported InjectionMethod: Error`);
61
- });
62
- test.each `
63
- value | result
64
- ${0.0} | ${0}
65
- ${0.1} | ${0.1}
66
- `(`Will not remove leading zero from $value`, ({ result, value }) => {
67
- const updateMock = jest.fn();
68
- const wrapper = render(
69
- // @ts-ignore
70
- <RecommendedInsulin updateRecommendedInsulin={updateMock} injectionMethod={Pump}/>);
71
- expectTextExists(wrapper, `Recommended amount of insulin`);
72
- const input = wrapper.getByTestId(RecommendedInsulinTestIds.InvisibleInsulinInput);
73
- fireEvent(input, `onEnd`, value);
74
- expectTextExists(wrapper, `${result}`);
75
- });
76
- test.each `
77
- value | result
78
- ${`09`} | ${9}
79
- ${`09.1`} | ${9.1}
80
- `(`Will remove leading zero from $value`, ({ result, value }) => {
81
- const updateMock = jest.fn();
82
- const wrapper = render(
83
- // @ts-ignore
84
- <RecommendedInsulin updateRecommendedInsulin={updateMock} injectionMethod={Pump}/>);
85
- expectTextExists(wrapper, `Recommended amount of insulin`);
86
- const input = wrapper.getByTestId(RecommendedInsulinTestIds.InvisibleInsulinInput);
87
- fireEvent(input, `partialInput`, value);
88
- expectTextExists(wrapper, `${result}`);
89
- });
90
- test(`Pressing on TouchableOpacity will callback on the invisible text input`, () => {
91
- const updateMock = jest.fn();
92
- const wrapper = render(
93
- // @ts-ignore
94
- <RecommendedInsulin updateRecommendedInsulin={updateMock} injectionMethod={Pump}/>);
95
- expectTextExists(wrapper, `Recommended amount of insulin`);
96
- const button = wrapper.getByTestId(RecommendedInsulinTestIds.EditRecommendedInsulin);
97
- fireEvent(button, `onPress`);
98
- });
99
- test.each `
100
- value | reduction | isCorrect
101
- ${`50`} | ${0} | ${true}
102
- ${`${SAFETY_INSULIN_LIMIT}`} | ${0} | ${true}
103
- ${`${SAFETY_INSULIN_LIMIT + 1}`} | ${0} | ${false}
104
- ${`24`} | ${0.5} | ${true}
105
- ${`${(SAFETY_INSULIN_LIMIT + 1) * 0.5}`} | ${0.5} | ${false}
106
- ${`10`} | ${0.75} | ${true}
107
- ${`${(SAFETY_INSULIN_LIMIT + 1) * 0.25}`} | ${0.75} | ${false}
108
- `(`Throws an error at insulin limits`, ({ reduction, isCorrect, value }) => {
109
- const updateMock = jest.fn();
110
- const wrapper = render(
111
- // @ts-ignore
112
- <RecommendedInsulin activityReduction={reduction} updateRecommendedInsulin={updateMock} injectionMethod={Pump}/>);
113
- expectTextExists(wrapper, `Recommended amount of insulin`);
114
- const input = wrapper.getByTestId(RecommendedInsulinTestIds.InvisibleInsulinInput);
115
- fireEvent(input, `onEnd`, value);
116
- if (isCorrect) {
117
- expectTextExists(wrapper, value);
118
- }
119
- else {
120
- expectTextNotExists(wrapper, value);
121
- expectTextNotExists(wrapper, `OK`);
122
- }
123
- });
124
- test.each `
125
- reduction | expected | reductionPercent
126
- ${null} | ${SAFETY_INSULIN_LIMIT * (1 - 0)} | ${`${0 * 100}%`}
127
- ${undefined} | ${SAFETY_INSULIN_LIMIT * (1 - 0)} | ${`${0 * 100}%`}
128
- ${0} | ${SAFETY_INSULIN_LIMIT * (1 - 0)} | ${`${0 * 100}%`}
129
- ${0.1} | ${SAFETY_INSULIN_LIMIT * (1 - 0.1)} | ${`${0.1 * 100}%`}
130
- ${0.25} | ${SAFETY_INSULIN_LIMIT * (1 - 0.25)} | ${`${0.25 * 100}%`}
131
- ${0.5} | ${SAFETY_INSULIN_LIMIT * (1 - 0.5)} | ${`${0.5 * 100}%`}
132
- ${0.75} | ${SAFETY_INSULIN_LIMIT * (1 - 0.75)} | ${`${0.75 * 100}%`}
133
- ${0.9} | ${SAFETY_INSULIN_LIMIT * (1 - 0.9)} | ${`${0.9 * 100}%`}
134
- `(`Recommendation is limited when entering over the maximum safety threshold of insulin when activity reduction is $reductionPercent`, ({ expected, reduction }) => {
135
- const updateMock = jest.fn();
136
- const wrapper = render(<RecommendedInsulin insulinRecommendation={expected} updateRecommendedInsulin={updateMock} injectionMethod={Pump} activityReduction={reduction} enteredInsulin={null}/>);
137
- const input = wrapper.getByTestId(RecommendedInsulinTestIds.InvisibleInsulinInput);
138
- const INVALID_INSULIN = SAFETY_INSULIN_LIMIT + 1;
139
- fireEvent(input, `onEnd`, INVALID_INSULIN);
140
- expect(updateMock).toBeCalledWith(expected);
141
- });
142
- test.each `
143
- platform | padding
144
- ${`ios`} | ${`3%`}
145
- ${`android`} | ${`1%`}
146
- `(`On $platform the component has $padding paddingBottom`, ({ padding, platform }) => {
147
- Platform.OS = platform;
148
- const updateMock = jest.fn();
149
- const wrapper = render(
150
- // @ts-ignore
151
- <RecommendedInsulin updateRecommendedInsulin={updateMock} injectionMethod={Pump}/>);
152
- expect(!!new RegExp(`"paddingBottom":"${padding}"`).exec(JSON.stringify(wrapper.toJSON()))).toBeTruthy();
153
- });
154
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,78 +0,0 @@
1
- import React from "react";
2
- import { Platform } from "react-native";
3
- import { cleanup, fireEvent, render } from "react-native-testing-library";
4
- import Remeasure from "../../components/Remeasure";
5
- import { Testing } from "../../types/enum";
6
- import { expectTextExists, expectTextNotExists } from "../utils";
7
- const { RemeasureTestIds } = Testing.Id;
8
- describe(`Remeasure Component`, () => {
9
- afterEach(cleanup);
10
- test.each `
11
- value | expected
12
- ${0} | ${`OFF`}
13
- ${1} | ${`1`}
14
- ${1.0} | ${`1`}
15
- ${2.3} | ${`2.3`}
16
- ${3.8} | ${`3.8`}
17
- `(`Setting slider to $value displays $expected`, ({ value, expected }) => {
18
- const onChange = jest.fn();
19
- const wrapper = render(<Remeasure remeasureTime={1.5} onSliderChange={onChange}/>);
20
- expectTextExists(wrapper, `1.5`);
21
- const slider = wrapper.getByTestId(RemeasureTestIds.RemeasureSlider);
22
- fireEvent(slider, `onValueChange`, value);
23
- wrapper.rerender(<Remeasure remeasureTime={value} onSliderChange={onChange}/>);
24
- expectTextExists(wrapper, `Remind me to remeasure in`);
25
- expectTextNotExists(wrapper, `1.5`);
26
- expectTextExists(wrapper, expected);
27
- expect(onChange).toBeCalledWith(value);
28
- });
29
- test.each `
30
- value | expected | callbackValue
31
- ${0} | ${`OFF`} | ${0}
32
- ${-0.1} | ${`OFF`} | ${0}
33
- ${-100} | ${`OFF`} | ${0}
34
- ${4.5} | ${`4.5`} | ${4.5}
35
- ${6.1} | ${`6`} | ${6}
36
- ${6.5} | ${`6`} | ${6}
37
- ${12} | ${`6`} | ${6}
38
- ${55} | ${`6`} | ${6}
39
- `(`Setting slider to edge-case $value displays $expected`, ({ value, expected, callbackValue }) => {
40
- const onChange = jest.fn();
41
- const wrapper = render(<Remeasure remeasureTime={1.5} onSliderChange={onChange}/>);
42
- expectTextExists(wrapper, `1.5`);
43
- const slider = wrapper.getByTestId(RemeasureTestIds.RemeasureSlider);
44
- fireEvent(slider, `onValueChange`, value);
45
- wrapper.rerender(<Remeasure remeasureTime={value} onSliderChange={onChange}/>);
46
- expectTextNotExists(wrapper, `1.5`);
47
- expectTextExists(wrapper, expected);
48
- if (isNaN(Number(expected))) {
49
- expectTextNotExists(wrapper, `hours`);
50
- }
51
- else {
52
- expectTextExists(wrapper, `hours`);
53
- }
54
- expect(onChange).toBeCalledWith(callbackValue);
55
- });
56
- test(`Setting it to default 1.5 still calls callback function`, () => {
57
- const value = 1.5;
58
- const expected = `1.5`;
59
- const onChange = jest.fn();
60
- const wrapper = render(<Remeasure remeasureTime={1.5} onSliderChange={onChange}/>);
61
- expectTextExists(wrapper, `1.5`);
62
- const slider = wrapper.getByTestId(RemeasureTestIds.RemeasureSlider);
63
- fireEvent(slider, `onValueChange`, value);
64
- wrapper.rerender(<Remeasure remeasureTime={value} onSliderChange={onChange}/>);
65
- expectTextExists(wrapper, expected);
66
- expect(onChange).toBeCalledWith(value);
67
- });
68
- test.each `
69
- platform | margin
70
- ${`ios`} | ${`3%`}
71
- ${`android`} | ${`0%`}
72
- `(`On $platform the slider has $margin marginHorizontal`, ({ margin, platform }) => {
73
- Platform.OS = platform;
74
- const onChange = jest.fn();
75
- const wrapper = render(<Remeasure remeasureTime={1.5} onSliderChange={onChange}/>);
76
- expect(!!new RegExp(`RNCSlider",.*marginHorizontal":"${margin}"`).exec(JSON.stringify(wrapper.toJSON()))).toBeTruthy();
77
- });
78
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,30 +0,0 @@
1
- import React from "react";
2
- import { fireEvent, render } from "react-native-testing-library";
3
- import TransferToLogbook from "../../components/TransferToLogbook";
4
- import { Testing } from "../../types/enum";
5
- import { expectTextExists, expectTextNotExists } from "../utils";
6
- describe(`TransferToLogbook - Component`, () => {
7
- test(`Is null when visible not visible`, () => {
8
- const transferMock = jest.fn();
9
- const wrapper = render(<TransferToLogbook visible={false} transfer={transferMock}/>);
10
- expectTextNotExists(wrapper, `Transfer to logbook`);
11
- expect(transferMock).not.toBeCalled();
12
- });
13
- test(`Mounts with "transfer to logbook" text when visible`, () => {
14
- const transferMock = jest.fn();
15
- const wrapper = render(<TransferToLogbook visible={true} transfer={transferMock}/>);
16
- expectTextExists(wrapper, `Transfer to logbook`);
17
- expect(transferMock).not.toBeCalled();
18
- });
19
- test(`Pressing the button will trigger the callback`, () => {
20
- const transferMock = jest.fn();
21
- const wrapper = render(<TransferToLogbook visible={true} transfer={transferMock}/>);
22
- expectTextExists(wrapper, `Transfer to logbook`);
23
- const button = wrapper.getByTestId(Testing.Id.TransferToLogbookTestIds.TransferButton);
24
- expect(transferMock).not.toBeCalled();
25
- fireEvent(button, `onPress`);
26
- expectTextNotExists(wrapper, `Transfer to logbook`);
27
- expectTextExists(wrapper, `Transferred to logbook`);
28
- expect(transferMock).toBeCalled();
29
- });
30
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,65 +0,0 @@
1
- import React from "react";
2
- import { cleanup, fireEvent, render } from "react-native-testing-library";
3
- import TwoOptionModal from "../../components/TwoOptionModal";
4
- import { Testing } from "../../types/enum";
5
- import { expectTextExists } from "../utils";
6
- const { TwoOptionModalTestIds } = Testing.Id;
7
- describe(`TwoOptionModal Component`, () => {
8
- afterEach(cleanup);
9
- test(`Can can show text `, () => {
10
- const props = {
11
- firstOption: jest.fn(),
12
- secondOption: jest.fn(),
13
- onClose: jest.fn(),
14
- rowAsButtonLayout: true,
15
- textFirstOption: `Gem i logbog`,
16
- message: `Dine gemte indtastninger vil blive brugt til fremtidige beregninger.`,
17
- textSecondOption: `Luk beregning`,
18
- title: `Vil du gemme din indtastning?`,
19
- };
20
- const wrapper = render(<TwoOptionModal {...props}/>);
21
- expectTextExists(wrapper, `Luk beregning`);
22
- expectTextExists(wrapper, `Dine gemte indtastninger vil blive brugt til fremtidige beregninger.`);
23
- expectTextExists(wrapper, `Gem i logbog`);
24
- expectTextExists(wrapper, `Vil du gemme din indtastning?`);
25
- });
26
- test(`Test that callbacks are called`, () => {
27
- const props = {
28
- firstOption: jest.fn(),
29
- secondOption: jest.fn(),
30
- onClose: jest.fn(),
31
- rowAsButtonLayout: true,
32
- isCancelable: true,
33
- textFirstOption: `Gem i logbog`,
34
- message: `Dine gemte indtastninger vil blive brugt til fremtidige beregninger.`,
35
- textSecondOption: `Luk beregning`,
36
- title: `Vil du gemme din indtastning?`,
37
- };
38
- const wrapper = render(<TwoOptionModal {...props}/>);
39
- expectTextExists(wrapper, `Luk beregning`);
40
- const modalExitIcon = wrapper.getByTestId(TwoOptionModalTestIds.ExitButton);
41
- fireEvent(modalExitIcon, `onPress`);
42
- expect(props.onClose).toBeCalled();
43
- const closeCalculation = wrapper.getByTestId(TwoOptionModalTestIds.SecondOption);
44
- fireEvent(closeCalculation, `onPress`);
45
- expect(props.secondOption).toBeCalled();
46
- const firstOptionButton = wrapper.getByTestId(TwoOptionModalTestIds.FirstOption);
47
- fireEvent(firstOptionButton, `onPress`);
48
- expect(props.firstOption).toBeCalled();
49
- });
50
- test(`Test it is not cancelable`, () => {
51
- const props = {
52
- firstOption: jest.fn(),
53
- secondOption: jest.fn(),
54
- rowAsButtonLayout: true,
55
- textFirstOption: `Gem i logbog`,
56
- message: `Dine gemte indtastninger vil blive brugt til fremtidige beregninger.`,
57
- textSecondOption: `Luk beregning`,
58
- title: `Vil du gemme din indtastning?`,
59
- };
60
- const wrapper = render(<TwoOptionModal {...props}/>);
61
- expectTextExists(wrapper, `Luk beregning`);
62
- const modalExitIcon = wrapper.queryByTestId(TwoOptionModalTestIds.ExitButton);
63
- expect(modalExitIcon).toBeNull();
64
- });
65
- });
@@ -1,16 +0,0 @@
1
- /// <reference types="react" />
2
- import { BolusCalculator, Logbook } from "@hedia/types";
3
- import { RenderAPI } from "react-native-testing-library";
4
- import { ReactTestInstance } from "react-test-renderer";
5
- import { IRecommendationProps } from "../RecommendationScreen";
6
- import { Testing } from "../types/enum";
7
- export declare function getRecommendationProps(partials?: Partial<IRecommendationProps>): IRecommendationProps;
8
- export declare function generateDefaultCalculatorParams(): BolusCalculator.Types.IRecommendationParams;
9
- export declare function generateActivityProps(): BolusCalculator.Types.IActivityParams;
10
- export declare function generateDefaultActivitySettings(): BolusCalculator.Types.IActivityParams["activitySettings"];
11
- export declare function generateDefaultLogbook(): Logbook.Types.ILogbookEntry;
12
- export declare function expectTextExists(component: RenderAPI, text: string | RegExp): void;
13
- export declare function queryTextFromComponent(wrapper: RenderAPI, testID: Testing.Types.TestIdEnum): string;
14
- export declare function expectTextNotExists(component: RenderAPI, text: string | RegExp): void;
15
- export declare function i18nProvided(element: JSX.Element): JSX.Element;
16
- export declare function getIcon(wrapper: RenderAPI, name: string, active: boolean): ReactTestInstance | null;
@@ -1,126 +0,0 @@
1
- import { Activity, BloodGlucoseUnit, BloodKetonesUnit, Languages, UserSettings, } from "@hedia/types";
2
- import { I18nProvider } from "@lingui/react";
3
- import React from "react";
4
- import { i18n } from "../locale/i18nUtils";
5
- const ActivityEnum = Activity.Enums.ActivityEnum;
6
- const ActivityIntensity = Activity.Enums.ActivityIntensity;
7
- const InjectionMethod = UserSettings.Enums.InjectionMethod;
8
- const { Run } = ActivityEnum;
9
- const { moderate } = ActivityIntensity;
10
- const { PenHalf } = InjectionMethod;
11
- export function getRecommendationProps(partials) {
12
- return {
13
- currentBKL: partials?.currentBKL ?? 0.1,
14
- bloodKetoneUnit: partials?.bloodKetoneUnit ?? BloodKetonesUnit.MMOL_L,
15
- bloodGlucoseUnit: partials?.bloodGlucoseUnit ?? BloodGlucoseUnit.MMOL_L,
16
- language: partials?.language ?? Languages.en,
17
- userReminder: partials?.userReminder ?? 1.5,
18
- latestLogbookFrom6Hours: partials?.latestLogbookFrom6Hours ?? generateDefaultLogbook(),
19
- calculatorParams: partials?.calculatorParams ?? generateDefaultCalculatorParams(),
20
- injectionMethod: partials?.injectionMethod ?? PenHalf,
21
- transferToLogbook: partials?.transferToLogbook ?? jest.fn(),
22
- onError: partials?.onError ?? jest.fn(),
23
- onRecentInsulinYes: partials?.onRecentInsulinYes ?? jest.fn(),
24
- exitCallback: partials?.exitCallback ?? jest.fn(),
25
- closeCalculationCallback: partials?.closeCalculationCallback ?? jest.fn(),
26
- carbRecommendationAnswer: partials?.carbRecommendationAnswer ?? jest.fn(),
27
- showBolusBar: partials?.showBolusBar ?? jest.fn(),
28
- restartCalculation: partials?.restartCalculation ?? jest.fn(),
29
- activityDisplayProps: partials?.activityDisplayProps ?? {
30
- activityTitle: `Activity Title Test`,
31
- activityType: Run,
32
- },
33
- };
34
- }
35
- export function generateDefaultCalculatorParams() {
36
- return {
37
- carbohydrateRatio: 10,
38
- carbohydrates: 4,
39
- currentBGL: 5,
40
- insulinSensitivity: 4,
41
- targetBGL: 6,
42
- recentBoluses: [
43
- {
44
- insulinDose: 2,
45
- secondsPassed: 1000,
46
- },
47
- {
48
- insulinDose: 1.7,
49
- secondsPassed: 10000,
50
- },
51
- ],
52
- activity: null,
53
- };
54
- }
55
- export function generateActivityProps() {
56
- return {
57
- activityDate: new Date(),
58
- activityDuration: 30,
59
- activityIntensity: moderate,
60
- activitySettings: generateDefaultActivitySettings(),
61
- };
62
- }
63
- export function generateDefaultActivitySettings() {
64
- return {
65
- hard: { fromFortysix: null, fromThirty: 0.25, fromZero: 1 },
66
- light: { fromFortysix: 0.5, fromThirty: 0.75, fromZero: 1 },
67
- moderate: { fromFortysix: 0.25, fromThirty: 0.5, fromZero: 1 },
68
- post: { fromFortysix: 0.5, fromThirty: 0.5, fromZero: 1 },
69
- target: 9,
70
- };
71
- }
72
- export function generateDefaultLogbook() {
73
- return {
74
- blood_glucose_millimolar: 6,
75
- carbohydrates_entered_grams: 25,
76
- carbohydrates_suggested_grams: 25,
77
- client_timestamp: new Date(),
78
- client_version: `25`,
79
- entry_timestamp: new Date(),
80
- event_uuid: null,
81
- insulin_entered_units: 25,
82
- insulin_suggested_units: 25,
83
- is_deleted: null,
84
- mood: 2,
85
- settings_uuid: `25`,
86
- uuid: `aaa`,
87
- device_and_os: `ios 12.1.2`,
88
- overwritten_by_id: null,
89
- server_timestamp: null,
90
- server_version: null,
91
- utc_timezone_offset: null,
92
- blood_ketones_millimolar: null,
93
- carbohydrates_modified_suggested_grams: null,
94
- };
95
- }
96
- export function expectTextExists(component, text) {
97
- const element = component.queryByText(text);
98
- /*
99
- if (!element) {
100
- throw Error(`element with text: ${text} does not exist`);
101
- }
102
- */
103
- return expect(element).not.toBeNull();
104
- }
105
- export function queryTextFromComponent(wrapper, testID) {
106
- const component = wrapper.getByTestId(testID);
107
- const values = component.children;
108
- return values.join(``);
109
- }
110
- export function expectTextNotExists(component, text) {
111
- const element = component.queryByText(text);
112
- /*
113
- if (element) {
114
- throw Error(`element with text: ${text} should not exist`);
115
- }
116
- */
117
- return expect(element).toBeNull();
118
- }
119
- export function i18nProvided(element) {
120
- return (<I18nProvider language={i18n.language} i18n={i18n}>
121
- {element}
122
- </I18nProvider>);
123
- }
124
- export function getIcon(wrapper, name, active) {
125
- return wrapper.queryByA11yLabel(`${name}_${active}`);
126
- }
package/tsconfig.json DELETED
@@ -1,72 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- // "experimentalDecorators": true,
4
- "target": "ESNEXT" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */,
5
- "module": "ESNext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
6
- //"jsx": "react", /* Use React to interpret JSX */
7
- "noEmit": false /* Do not emit outputs. */,
8
- "allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. */,
9
-
10
- //"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
11
- //"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
12
- "lib": ["es2015", "es7"] /* Specify library files to be included in the compilation. */,
13
- // "allowJs": true, /* Allow javascript files to be compiled. */
14
- // "checkJs": true, /* Report errors in .js files. */
15
- "jsx": "react-native" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */,
16
- "declaration": true /* Generates corresponding '.d.ts' file. */,
17
- // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
18
- "sourceMap": false /* Generates corresponding '.map' file. */,
19
- // "outFile": "./", /* Concatenate and emit output to single file. */
20
- //"outDir": "./dist/", /* Redirect output structure to the directory. */
21
- //"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
22
- // "composite": true, /* Enable project compilation */
23
- // "removeComments": true, /* Do not emit comments to output. */
24
- // "noEmit": true, /* Do not emit outputs. */
25
- // "importHelpers": true, /* Import emit helpers from 'tslib'. */
26
- // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
27
- // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
28
-
29
- /* Strict Type-Checking Options */
30
- //"strict": true, /* Enable all strict type-checking options. */
31
- "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
32
- "strictNullChecks": true, /* Enable strict null checks. */
33
- "strictFunctionTypes": true, /* Enable strict checking of function types. */
34
- "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
35
- "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
36
- "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
37
- "noStrictGenericChecks": true,
38
-
39
- /* Additional Checks */
40
- "noUnusedLocals": true, /* Report errors on unused locals. */
41
- "noUnusedParameters": true, /* Report errors on unused parameters. */
42
- "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
43
- // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
44
-
45
- /* Module Resolution Options */
46
- "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
47
- // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
48
- // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
49
- // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
50
- // "typeRoots": [], /* List of folders to include type definitions from. */
51
- // "types": [], /* Type declaration files to be included in compilation. */
52
- // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
53
- "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
54
- // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
55
- "preserveConstEnums": true,
56
- /* Source Map Options */
57
- // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
58
- // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
59
- // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
60
- // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
61
-
62
- /* Experimental Options */
63
- "experimentalDecorators": true /* Enables experimental support for ES7 decorators. */,
64
- "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */,
65
- "skipLibCheck": true,
66
- "noErrorTruncation": true
67
- },
68
- "exclude": [
69
- "src/locale/CleanLanguage.ts",
70
- ],
71
- "compileOnSave": true
72
- }