@hedia/recommendation-screen 2.0.2 → 2.1.1

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 (116) hide show
  1. package/coverage/clover.xml +700 -0
  2. package/coverage/coverage-final.json +28 -0
  3. package/coverage/lcov-report/base.css +224 -0
  4. package/coverage/lcov-report/block-navigation.js +79 -0
  5. package/coverage/lcov-report/favicon.png +0 -0
  6. package/coverage/lcov-report/index.html +201 -0
  7. package/coverage/lcov-report/prettify.css +1 -0
  8. package/coverage/lcov-report/prettify.js +2 -0
  9. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  10. package/coverage/lcov-report/sorter.js +170 -0
  11. package/coverage/lcov-report/src/RecommendationScreen.tsx.html +1460 -0
  12. package/coverage/lcov-report/src/__tests__/index.html +111 -0
  13. package/coverage/lcov-report/src/__tests__/utils.tsx.html +512 -0
  14. package/coverage/lcov-report/src/components/Header.tsx.html +347 -0
  15. package/coverage/lcov-report/src/components/InfoBars.tsx.html +404 -0
  16. package/coverage/lcov-report/src/components/InvisibleNumberInput.tsx.html +374 -0
  17. package/coverage/lcov-report/src/components/LimitationMessage.tsx.html +191 -0
  18. package/coverage/lcov-report/src/components/LineSeparator.tsx.html +152 -0
  19. package/coverage/lcov-report/src/components/RecentInsulin.tsx.html +383 -0
  20. package/coverage/lcov-report/src/components/RecommendationModal.tsx.html +737 -0
  21. package/coverage/lcov-report/src/components/RecommendedCarbs.tsx.html +857 -0
  22. package/coverage/lcov-report/src/components/RecommendedInsulin.tsx.html +605 -0
  23. package/coverage/lcov-report/src/components/Remeasure.tsx.html +440 -0
  24. package/coverage/lcov-report/src/components/TransferToLogbook.tsx.html +380 -0
  25. package/coverage/lcov-report/src/components/TwoOptionModal.tsx.html +635 -0
  26. package/coverage/lcov-report/src/components/activity/Activity.tsx.html +311 -0
  27. package/coverage/lcov-report/src/components/activity/ActivityIcon.tsx.html +242 -0
  28. package/coverage/lcov-report/src/components/activity/ActivityIntensity.tsx.html +257 -0
  29. package/coverage/lcov-report/src/components/activity/index.html +141 -0
  30. package/coverage/lcov-report/src/components/index.html +276 -0
  31. package/coverage/lcov-report/src/components/mood/Emotion.tsx.html +278 -0
  32. package/coverage/lcov-report/src/components/mood/MoodIcon.tsx.html +260 -0
  33. package/coverage/lcov-report/src/components/mood/index.html +126 -0
  34. package/coverage/lcov-report/src/index.html +111 -0
  35. package/coverage/lcov-report/src/locale/i18nUtils.ts.html +161 -0
  36. package/coverage/lcov-report/src/locale/index.html +111 -0
  37. package/coverage/lcov-report/src/utils/AttentionMessages.tsx.html +326 -0
  38. package/coverage/lcov-report/src/utils/Constants.ts.html +176 -0
  39. package/coverage/lcov-report/src/utils/RecommendationError.tsx.html +500 -0
  40. package/coverage/lcov-report/src/utils/RecommendationUtils.ts.html +467 -0
  41. package/coverage/lcov-report/src/utils/Translations.ts.html +107 -0
  42. package/coverage/lcov-report/src/utils/Utils.ts.html +263 -0
  43. package/coverage/lcov-report/src/utils/Validations.ts.html +815 -0
  44. package/coverage/lcov-report/src/utils/index.html +201 -0
  45. package/coverage/lcov.info +1581 -0
  46. package/jest.config.js +2 -1
  47. package/package.json +2 -2
  48. package/src/RecommendationScreen.d.ts +2 -3
  49. package/src/__tests__/components/Emotion.test.jsx +7 -8
  50. package/src/components/Icon.d.ts +13 -0
  51. package/src/components/Icon.jsx +42 -0
  52. package/src/components/LimitationMessage.d.ts +1 -2
  53. package/src/components/RecommendationModal.d.ts +2 -3
  54. package/src/components/RecommendationModal.jsx +2 -1
  55. package/src/components/activity/ActivityIntensity.jsx +4 -3
  56. package/src/utils/AttentionMessages.d.ts +16 -10
  57. package/src/utils/AttentionMessages.jsx +15 -10
  58. package/src/utils/RecommendationUtils.d.ts +2 -3
  59. package/src/utils/RecommendationUtils.js +10 -6
  60. package/src/utils/Utils.d.ts +1 -0
  61. package/src/utils/Utils.js +4 -0
  62. package/tsconfig.json +7 -5
  63. package/App.d.ts +0 -27
  64. package/App.jsx +0 -98
  65. package/App.tsx +0 -140
  66. package/app.json +0 -4
  67. package/index.ts +0 -6
  68. package/src/RecommendationScreen.tsx +0 -461
  69. package/src/__tests__/RecommendationScreen.test.tsx +0 -1231
  70. package/src/__tests__/RecommendationUtils.test.ts +0 -332
  71. package/src/__tests__/Translate.test.tsx +0 -31
  72. package/src/__tests__/Utils.test.ts +0 -91
  73. package/src/__tests__/Validations.test.ts +0 -648
  74. package/src/__tests__/components/Activity.test.tsx +0 -163
  75. package/src/__tests__/components/Emotion.test.tsx +0 -110
  76. package/src/__tests__/components/Header.test.tsx +0 -44
  77. package/src/__tests__/components/InfoBars.test.tsx +0 -152
  78. package/src/__tests__/components/InvisibleNumberInput.test.tsx +0 -294
  79. package/src/__tests__/components/LimitationMessage.test.tsx +0 -58
  80. package/src/__tests__/components/MoodIcon.test.tsx +0 -45
  81. package/src/__tests__/components/RecommendationModal.test.tsx +0 -169
  82. package/src/__tests__/components/RecommendedCarbs.test.tsx +0 -234
  83. package/src/__tests__/components/RecommendedInsulin.test.tsx +0 -241
  84. package/src/__tests__/components/Remeasure.test.tsx +0 -97
  85. package/src/__tests__/components/TransferToLogbook.test.tsx +0 -38
  86. package/src/__tests__/components/TwoOptionModal.test.tsx +0 -72
  87. package/src/__tests__/utils.tsx +0 -144
  88. package/src/components/Header.tsx +0 -89
  89. package/src/components/Icon.js +0 -41
  90. package/src/components/InfoBars.tsx +0 -108
  91. package/src/components/InvisibleNumberInput.tsx +0 -98
  92. package/src/components/LimitationMessage.tsx +0 -38
  93. package/src/components/LineSeparator.tsx +0 -24
  94. package/src/components/RecentInsulin.tsx +0 -101
  95. package/src/components/RecommendationModal.tsx +0 -224
  96. package/src/components/RecommendedCarbs.tsx +0 -259
  97. package/src/components/RecommendedInsulin.tsx +0 -175
  98. package/src/components/Remeasure.tsx +0 -120
  99. package/src/components/TransferToLogbook.tsx +0 -100
  100. package/src/components/TwoOptionModal.tsx +0 -185
  101. package/src/components/activity/Activity.tsx +0 -77
  102. package/src/components/activity/ActivityIcon.tsx +0 -54
  103. package/src/components/activity/ActivityIntensity.tsx +0 -58
  104. package/src/components/mood/Emotion.tsx +0 -66
  105. package/src/components/mood/MoodIcon.tsx +0 -60
  106. package/src/locale/CleanLanguage.ts +0 -13
  107. package/src/locale/i18nUtils.ts +0 -27
  108. package/src/types/enum.ts +0 -108
  109. package/src/types/types.ts +0 -16
  110. package/src/utils/AttentionMessages.tsx +0 -75
  111. package/src/utils/Constants.ts +0 -32
  112. package/src/utils/RecommendationError.tsx +0 -140
  113. package/src/utils/RecommendationUtils.ts +0 -125
  114. package/src/utils/Translations.ts +0 -9
  115. package/src/utils/Utils.ts +0 -57
  116. package/src/utils/Validations.ts +0 -245
@@ -1,163 +0,0 @@
1
- import { Activity, Languages } from "@hedia/types";
2
- import { I18nProvider } from "@lingui/react";
3
- import React from "react";
4
- import { cleanup, render } from "react-native-testing-library";
5
- import { default as ActivityComponent } from "../../components/activity/Activity";
6
- import { i18n } from "../../locale/i18nUtils";
7
- import { ActivityTestIds } from "../../types/enum";
8
- import { ActivityIntensityTranslations } from "../../utils/Translations";
9
- import {
10
- expectTextExists,
11
- generateActivityProps,
12
- getRecommendationProps,
13
- i18nProvided,
14
- queryTextFromComponent,
15
- } from "../utils";
16
-
17
- const ActivityIntensity = Activity.Enums.ActivityIntensity;
18
- const { light, moderate, hard } = ActivityIntensity;
19
-
20
- describe(`Activity - Component`, (): void => {
21
- afterEach(cleanup);
22
-
23
- beforeEach((): void => {
24
- i18n.activate(Languages.en);
25
- });
26
-
27
- test.each`
28
- activityIntensity
29
- ${light}
30
- ${moderate}
31
- ${hard}
32
- `(
33
- `Renders $activityIntensity`,
34
- ({ activityIntensity }: { activityIntensity: Activity.Enums.ActivityIntensity }): void => {
35
- const { activityDisplayProps } = getRecommendationProps();
36
- const activity = generateActivityProps();
37
- const wrapper = render(
38
- i18nProvided(
39
- <ActivityComponent
40
- activity={{ ...activity, activityIntensity }}
41
- activityType={activityDisplayProps?.activityType ?? null}
42
- activityTitle={activityDisplayProps?.activityTitle ?? null}
43
- activityReduction={0}
44
- />,
45
- ),
46
- );
47
-
48
- expectTextExists(wrapper, `Activity`);
49
- expectTextExists(wrapper, `30`);
50
- expectTextExists(wrapper, `min`);
51
- expectTextExists(wrapper, `Based on the selected activity your insulin recommendation is reduced by:`);
52
- expectTextExists(wrapper, ActivityIntensityTranslations[activityIntensity]());
53
- },
54
- );
55
-
56
- test.each`
57
- reduction
58
- ${0}
59
- ${0.25}
60
- ${0.33}
61
- ${0.5}
62
- ${0.8}
63
- `(
64
- `Renders activity reduction from decimal: $reduction to percentage`,
65
- ({ reduction }: { reduction: number }): void => {
66
- const { activityDisplayProps } = getRecommendationProps();
67
- const activity = generateActivityProps();
68
- const wrapper = render(
69
- i18nProvided(
70
- <ActivityComponent
71
- activity={activity}
72
- activityType={activityDisplayProps?.activityType ?? null}
73
- activityReduction={reduction}
74
- activityTitle={activityDisplayProps?.activityTitle ?? null}
75
- />,
76
- ),
77
- );
78
-
79
- expectTextExists(wrapper, `${reduction * 100}%`);
80
- },
81
- );
82
-
83
- test(`Renders activity reduction as 0 when null is passed`, (): void => {
84
- const { activityDisplayProps } = getRecommendationProps();
85
- const activity = generateActivityProps();
86
- const reduction = null;
87
- const wrapper = render(
88
- i18nProvided(
89
- <ActivityComponent
90
- activity={activity}
91
- activityType={activityDisplayProps?.activityType ?? null}
92
- activityReduction={reduction}
93
- activityTitle={activityDisplayProps?.activityTitle ?? null}
94
- />,
95
- ),
96
- );
97
-
98
- const text = queryTextFromComponent(wrapper, ActivityTestIds.ActivityReduction);
99
- expect(text).toBe(`0%`);
100
- });
101
-
102
- test(`Can render activity title`, (): void => {
103
- const { activityDisplayProps } = getRecommendationProps();
104
- const activity = generateActivityProps();
105
- const wrapper = render(
106
- i18nProvided(
107
- <ActivityComponent
108
- activity={{ ...activity }}
109
- activityType={activityDisplayProps?.activityType ?? null}
110
- activityTitle={activityDisplayProps?.activityTitle ?? null}
111
- activityReduction={0}
112
- />,
113
- ),
114
- );
115
- expectTextExists(wrapper, activityDisplayProps?.activityTitle!);
116
- });
117
-
118
- test.each`
119
- language | locale | message
120
- ${`English`} | ${Languages.en} | ${`Activity`}
121
- ${`Danish`} | ${Languages.da} | ${`Aktivitet`}
122
- ${`German`} | ${Languages.de} | ${`Aktivität`}
123
- ${`Spanish`} | ${Languages.es} | ${`Actividad`}
124
- ${`Italian`} | ${Languages.it} | ${`Attività fisica`}
125
- ${`French`} | ${Languages.fr} | ${`Activité`}
126
- `(`Can render in $language`, ({ message, locale }: { locale: Languages; message: string }): void => {
127
- const { activityDisplayProps } = getRecommendationProps();
128
- const activity = generateActivityProps();
129
- i18n.activate(locale);
130
- const wrapper = render(
131
- <I18nProvider language={locale} i18n={i18n}>
132
- <ActivityComponent
133
- activity={activity}
134
- activityType={activityDisplayProps?.activityType ?? null}
135
- activityTitle={activityDisplayProps?.activityTitle ?? null}
136
- activityReduction={0}
137
- />
138
- </I18nProvider>,
139
- );
140
- expectTextExists(wrapper, message);
141
- });
142
-
143
- test(`ActivityIcon defaults to other if activityType is null`, (): void => {
144
- const { activityDisplayProps } = getRecommendationProps();
145
- const activity = generateActivityProps();
146
- const wrapper = render(
147
- i18nProvided(
148
- <ActivityComponent
149
- activity={{ ...activity }}
150
- activityType={null}
151
- activityTitle={activityDisplayProps?.activityTitle ?? null}
152
- activityReduction={0}
153
- />,
154
- ),
155
- );
156
- expectTextExists(wrapper, activityDisplayProps?.activityTitle!);
157
- const existingLabel = `${Activity.Enums.ActivityEnum[Activity.Enums.ActivityEnum.Other]}_activity`;
158
- const nonExistingLabel = `${Activity.Enums.ActivityEnum[Activity.Enums.ActivityEnum.Run]}_activity`;
159
-
160
- expect(wrapper.queryByA11yLabel(existingLabel)).not.toBeNull();
161
- expect(wrapper.queryByA11yLabel(nonExistingLabel)).toBeNull();
162
- });
163
- });
@@ -1,110 +0,0 @@
1
- import { Languages, Logbook } from "@hedia/types";
2
- import React from "react";
3
- import { cleanup, fireEvent, render } from "react-native-testing-library";
4
- import Emotion from "../../components/mood/Emotion";
5
- import { i18n } from "../../locale/i18nUtils";
6
- import { expectTextExists, getIcon, i18nProvided } from "../utils";
7
-
8
- const MoodEnum = Logbook.Enums.MoodEnum;
9
-
10
- describe(`Emotion - Component`, (): void => {
11
- afterEach(cleanup);
12
- beforeEach((): void => {
13
- i18n.activate(Languages.en);
14
- });
15
-
16
- test(`Can mount component in `, (): void => {
17
- const mockSelected = jest.fn();
18
- const wrapper = render(i18nProvided(<Emotion moodSelected={mockSelected} currentMood={null} />));
19
-
20
- expectTextExists(wrapper, `How are you feeling?`);
21
- });
22
-
23
- test.each`
24
- mood | moodName | preselected | preselectedName
25
- ${MoodEnum.Happy} | ${MoodEnum[MoodEnum.Happy]} | ${MoodEnum.Sad} | ${MoodEnum[MoodEnum.Sad]}
26
- ${MoodEnum.SemiHappy} | ${MoodEnum[MoodEnum.SemiHappy]} | ${MoodEnum.Happy} | ${MoodEnum[MoodEnum.Happy]}
27
- ${MoodEnum.Neutral} | ${MoodEnum[MoodEnum.Neutral]} | ${MoodEnum.SemiHappy} | ${MoodEnum[MoodEnum.SemiHappy]}
28
- ${MoodEnum.SemiSad} | ${MoodEnum[MoodEnum.SemiSad]} | ${MoodEnum.Neutral} | ${MoodEnum[MoodEnum.Neutral]}
29
- ${MoodEnum.Sad} | ${MoodEnum[MoodEnum.Sad]} | ${MoodEnum.SemiSad} | ${MoodEnum[MoodEnum.SemiSad]}
30
- `(
31
- `Pressing on $moodName icon deselects others`,
32
- ({
33
- mood,
34
- moodName,
35
- preselected,
36
- preselectedName,
37
- }: {
38
- mood: Logbook.Enums.MoodEnum;
39
- moodName: string;
40
- preselected: Logbook.Enums.MoodEnum;
41
- preselectedName: string;
42
- }): void => {
43
- let mockedStateMood: Logbook.Enums.MoodEnum = preselected;
44
- const mockSelected = jest.fn(
45
- (selectedMood: Logbook.Enums.MoodEnum): Logbook.Enums.MoodEnum => (mockedStateMood = selectedMood),
46
- );
47
-
48
- const wrapper = render(<Emotion moodSelected={mockSelected} currentMood={mockedStateMood} />);
49
-
50
- const preIcon = getIcon(wrapper, preselectedName, true);
51
-
52
- if (preIcon === null) {
53
- return fail(`No icon found for queryByA11yLabel: ${preselectedName}_${true}`);
54
- }
55
-
56
- const newIcon = getIcon(wrapper, moodName, false);
57
-
58
- if (newIcon === null) {
59
- return fail(`No icon found for queryByA11yLabel: ${moodName}_${false}`);
60
- }
61
-
62
- // Select a different mood
63
- fireEvent(newIcon, `onPress`);
64
-
65
- expect(mockedStateMood).toBe(mood);
66
-
67
- wrapper.update(<Emotion moodSelected={mockSelected} currentMood={mockedStateMood} />);
68
-
69
- Object.keys(MoodEnum)
70
- .filter((key): boolean => /[0-9]/.test(key))
71
- .forEach((key): void => {
72
- if (moodName === MoodEnum[key]) {
73
- expect(getIcon(wrapper, MoodEnum[key], true)).not.toBeNull();
74
- expect(getIcon(wrapper, MoodEnum[key], false)).toBeNull();
75
- } else {
76
- expect(getIcon(wrapper, MoodEnum[key], false)).not.toBeNull();
77
- expect(getIcon(wrapper, MoodEnum[key], true)).toBeNull();
78
- }
79
- });
80
- },
81
- );
82
-
83
- test(`Deselecting selected icon by pressing it again`, (): void => {
84
- let mockedStateMood: Logbook.Enums.MoodEnum = MoodEnum.Happy;
85
- const mockSelected = jest.fn(
86
- (newMood: Logbook.Enums.MoodEnum): Logbook.Enums.MoodEnum => (mockedStateMood = newMood),
87
- );
88
-
89
- const mood = MoodEnum[mockedStateMood];
90
-
91
- const wrapper = render(<Emotion moodSelected={mockSelected} currentMood={mockedStateMood} />);
92
-
93
- // current mood has already been selected: Happy
94
- expect(getIcon(wrapper, mood, true)).not.toBeNull();
95
- expect(getIcon(wrapper, mood, false)).toBeNull();
96
-
97
- const icon = getIcon(wrapper, mood, true);
98
-
99
- if (icon === null) {
100
- return fail(`No icon found for queryByA11yLabel: ${mood}_${true}`);
101
- }
102
-
103
- fireEvent(icon, `onPress`);
104
-
105
- wrapper.update(<Emotion moodSelected={mockSelected} currentMood={mockedStateMood} />);
106
-
107
- expect(getIcon(wrapper, mood, true)).toBeNull();
108
- expect(getIcon(wrapper, mood, false)).not.toBeNull();
109
- });
110
- });
@@ -1,44 +0,0 @@
1
- import React from "react";
2
- import { cleanup, fireEvent, render } from "react-native-testing-library";
3
- import { expectTextExists, getRecommendationProps } from "../utils";
4
-
5
- import { I18nProvider } from "@lingui/react";
6
- import Header from "../../components/Header";
7
-
8
- import { Languages } from "@hedia/types";
9
- import { i18n } from "../../locale/i18nUtils";
10
- import { HeaderTestIds } from "../../types/enum";
11
-
12
- describe(`Header Component`, (): void => {
13
- afterEach(cleanup);
14
-
15
- test(`Exit button calls exitCallback`, (): void => {
16
- const props = getRecommendationProps();
17
- const { getByTestId } = render(<Header exitCallback={props.exitCallback} />);
18
- expect(props.exitCallback).not.toBeCalled();
19
- fireEvent.press(getByTestId(HeaderTestIds.ExitCalculation));
20
- expect(props.exitCallback).toBeCalled();
21
- });
22
- test.each`
23
- language | locale | header
24
- ${`English`} | ${Languages.en} | ${`INSULIN\nRECOMMENDATION`}
25
- ${`Danish`} | ${Languages.da} | ${`INSULIN\nANBEFALING`}
26
- ${`German`} | ${Languages.de} | ${`INSULIN\nEMPFEHLUNG`}
27
- ${`Spanish`} | ${Languages.es} | ${`RECOMENDACIÓN\nDE INSULINA`}
28
- ${`Italian`} | ${Languages.it} | ${`PRESCRIZIONE DI\nINSULINA`}
29
- ${`French`} | ${Languages.fr} | ${`RECOMMANDATION\nD’INSULINE`}
30
- `(`Header is translated to $language`, ({ header, locale }: { locale: Languages; header: string }): void => {
31
- const props = getRecommendationProps({
32
- language: locale,
33
- });
34
-
35
- i18n.activate(locale);
36
- const wrapper = render(
37
- <I18nProvider language={locale} i18n={i18n}>
38
- <Header exitCallback={props.exitCallback} />
39
- </I18nProvider>,
40
- );
41
-
42
- expectTextExists(wrapper, header);
43
- });
44
- });
@@ -1,152 +0,0 @@
1
- import { BloodGlucoseUnit, BloodKetonesUnit } from "@hedia/types";
2
- import React from "react";
3
- import { cleanup, render } from "react-native-testing-library";
4
- import InfoBars, { IProps } from "../../components/InfoBars";
5
- import { expectTextExists, expectTextNotExists } from "../utils";
6
-
7
- enum DisplayedUnit {
8
- MG_DL = `mg/dL`,
9
- MMOL_L = `mmol/L`,
10
- }
11
-
12
- describe(`Info Bars Component`, (): void => {
13
- afterEach(cleanup);
14
-
15
- test(`Active Insulin info bar shows value`, (): void => {
16
- const props: IProps = {
17
- label: `Active Insulin`,
18
- unit: `units`,
19
- value: `4.5`,
20
- showNullAsDash: true,
21
- };
22
- const InfoBarsComponent = render(<InfoBars {...props} />);
23
- expectTextNotExists(InfoBarsComponent, `${BloodGlucoseUnit.MMOL_L}`);
24
- expectTextExists(InfoBarsComponent, props.label);
25
- expectTextExists(InfoBarsComponent, `${props.unit}`);
26
- expectTextExists(InfoBarsComponent, props.value!);
27
- });
28
-
29
- test(`Active Insulin info bar - showNullAsDash`, (): void => {
30
- const props: IProps = {
31
- label: `Active Insulin`,
32
- unit: `units`,
33
- showNullAsDash: true,
34
- value: null,
35
- };
36
- const InfoBarsComponent = render(<InfoBars {...props} />);
37
- expectTextNotExists(InfoBarsComponent, `${BloodGlucoseUnit.MG_DL}`);
38
- expectTextExists(InfoBarsComponent, props.label);
39
- expectTextExists(InfoBarsComponent, `${props.unit}`);
40
- expectTextExists(InfoBarsComponent, `-.-`);
41
- });
42
-
43
- test(`Active Insulin info bar - don't showNullAsDash`, (): void => {
44
- const props: IProps = {
45
- label: `Active Insulin`,
46
- unit: `units`,
47
- value: `3.5`,
48
- showNullAsDash: false,
49
- };
50
- const InfoBarsComponent = render(<InfoBars {...props} />);
51
- expectTextNotExists(InfoBarsComponent, `${BloodGlucoseUnit.MG_DL}`);
52
- expectTextExists(InfoBarsComponent, props.label);
53
- expectTextExists(InfoBarsComponent, `${props.unit}`);
54
- expectTextExists(InfoBarsComponent, props.value!);
55
- });
56
-
57
- test(`Blood Glucose mmol/l can be displayed`, (): void => {
58
- const props: IProps = {
59
- label: `Blood Glucose Levels`,
60
- unit: BloodGlucoseUnit.MMOL_L,
61
- value: `4.5`,
62
- showNullAsDash: true,
63
- };
64
- const InfoBarsComponent = render(<InfoBars {...props} />);
65
- expectTextNotExists(InfoBarsComponent, `${BloodGlucoseUnit.MG_DL}`);
66
- expectTextNotExists(InfoBarsComponent, `${BloodGlucoseUnit.MMOL_L}`);
67
-
68
- expectTextExists(InfoBarsComponent, props.label);
69
- expectTextExists(InfoBarsComponent, DisplayedUnit.MMOL_L);
70
- expectTextExists(InfoBarsComponent, props.value!);
71
- });
72
-
73
- test(`Blood Glucose mg/dl can be displayed`, (): void => {
74
- const props: IProps = {
75
- label: `Blood Glucose Levels`,
76
- unit: BloodGlucoseUnit.MG_DL,
77
- value: `135`,
78
- showNullAsDash: true,
79
- };
80
- const InfoBarsComponent = render(<InfoBars {...props} />);
81
- expectTextNotExists(InfoBarsComponent, `${BloodGlucoseUnit.MMOL_L}`);
82
- expectTextNotExists(InfoBarsComponent, `${BloodGlucoseUnit.MG_DL}`);
83
-
84
- expectTextExists(InfoBarsComponent, props.label);
85
- expectTextExists(InfoBarsComponent, DisplayedUnit.MG_DL);
86
- expectTextExists(InfoBarsComponent, props.value!);
87
- });
88
-
89
- test(`Blood Ketones mmol/l can be displayed`, (): void => {
90
- const props: IProps = {
91
- label: `Blood Ketone Level`,
92
- unit: BloodKetonesUnit.MMOL_L,
93
- value: `2.2`,
94
- showNullAsDash: true,
95
- };
96
- const InfoBarsComponent = render(<InfoBars {...props} />);
97
- expectTextNotExists(InfoBarsComponent, `${BloodKetonesUnit.MG_DL}`);
98
- expectTextNotExists(InfoBarsComponent, `${BloodKetonesUnit.MMOL_L}`);
99
-
100
- expectTextExists(InfoBarsComponent, props.label);
101
- expectTextExists(InfoBarsComponent, DisplayedUnit.MMOL_L);
102
- expectTextExists(InfoBarsComponent, props.value!);
103
- });
104
-
105
- test(`Blood Ketones mg/dl can be displayed`, (): void => {
106
- const props: IProps = {
107
- label: `Blood Ketone Level`,
108
- unit: BloodKetonesUnit.MG_DL,
109
- value: `10`,
110
- showNullAsDash: true,
111
- };
112
- const InfoBarsComponent = render(<InfoBars {...props} />);
113
- expectTextNotExists(InfoBarsComponent, `${BloodKetonesUnit.MMOL_L}`);
114
- expectTextNotExists(InfoBarsComponent, `${BloodKetonesUnit.MG_DL}`);
115
-
116
- expectTextExists(InfoBarsComponent, props.label);
117
- expectTextExists(InfoBarsComponent, DisplayedUnit.MG_DL);
118
- expectTextExists(InfoBarsComponent, props.value!);
119
- });
120
-
121
- interface IShowNullAsDash {
122
- value: string;
123
- expected: string;
124
- unit: string;
125
- showNullAsDash: boolean;
126
- }
127
- test.each`
128
- value | showNullAsDash | unit | expected
129
- ${null} | ${false} | ${`units`} | ${`0`}
130
- ${null} | ${false} | ${BloodGlucoseUnit.MG_DL} | ${`0`}
131
- ${null} | ${false} | ${BloodGlucoseUnit.MG_DL} | ${`0`}
132
- ${null} | ${false} | ${BloodKetonesUnit.MG_DL} | ${`0`}
133
- ${null} | ${false} | ${BloodKetonesUnit.MMOL_L} | ${`0`}
134
- ${null} | ${true} | ${`units`} | ${`-.-`}
135
- ${null} | ${true} | ${BloodGlucoseUnit.MG_DL} | ${`-`}
136
- ${null} | ${true} | ${BloodGlucoseUnit.MMOL_L} | ${`-.-`}
137
- ${null} | ${true} | ${BloodKetonesUnit.MG_DL} | ${`-`}
138
- ${null} | ${true} | ${BloodKetonesUnit.MMOL_L} | ${`-.-`}
139
- `(
140
- `$value will be displayed as $expected when showNullAsDash === $showNullAsDash`,
141
- ({ expected, showNullAsDash, unit, value }: IShowNullAsDash): void => {
142
- const props: IProps = {
143
- label: `Blood Glucose Levels`,
144
- unit,
145
- value,
146
- showNullAsDash,
147
- };
148
- const InfoBarsComponent = render(<InfoBars {...props} />);
149
- expectTextExists(InfoBarsComponent, expected);
150
- },
151
- );
152
- });