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

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 (87) hide show
  1. package/coverage/clover.xml +2 -2
  2. package/coverage/lcov-report/index.html +1 -1
  3. package/coverage/lcov-report/src/RecommendationScreen.tsx.html +1 -1
  4. package/coverage/lcov-report/src/__tests__/index.html +1 -1
  5. package/coverage/lcov-report/src/__tests__/utils.tsx.html +1 -1
  6. package/coverage/lcov-report/src/components/Header.tsx.html +1 -1
  7. package/coverage/lcov-report/src/components/InfoBars.tsx.html +1 -1
  8. package/coverage/lcov-report/src/components/InvisibleNumberInput.tsx.html +1 -1
  9. package/coverage/lcov-report/src/components/LimitationMessage.tsx.html +1 -1
  10. package/coverage/lcov-report/src/components/LineSeparator.tsx.html +1 -1
  11. package/coverage/lcov-report/src/components/RecentInsulin.tsx.html +1 -1
  12. package/coverage/lcov-report/src/components/RecommendationModal.tsx.html +1 -1
  13. package/coverage/lcov-report/src/components/RecommendedCarbs.tsx.html +1 -1
  14. package/coverage/lcov-report/src/components/RecommendedInsulin.tsx.html +1 -1
  15. package/coverage/lcov-report/src/components/Remeasure.tsx.html +1 -1
  16. package/coverage/lcov-report/src/components/TransferToLogbook.tsx.html +1 -1
  17. package/coverage/lcov-report/src/components/TwoOptionModal.tsx.html +1 -1
  18. package/coverage/lcov-report/src/components/activity/Activity.tsx.html +1 -1
  19. package/coverage/lcov-report/src/components/activity/ActivityIcon.tsx.html +1 -1
  20. package/coverage/lcov-report/src/components/activity/ActivityIntensity.tsx.html +1 -1
  21. package/coverage/lcov-report/src/components/activity/index.html +1 -1
  22. package/coverage/lcov-report/src/components/index.html +1 -1
  23. package/coverage/lcov-report/src/components/mood/Emotion.tsx.html +1 -1
  24. package/coverage/lcov-report/src/components/mood/MoodIcon.tsx.html +1 -1
  25. package/coverage/lcov-report/src/components/mood/index.html +1 -1
  26. package/coverage/lcov-report/src/index.html +1 -1
  27. package/coverage/lcov-report/src/locale/i18nUtils.ts.html +1 -1
  28. package/coverage/lcov-report/src/locale/index.html +1 -1
  29. package/coverage/lcov-report/src/utils/AttentionMessages.tsx.html +1 -1
  30. package/coverage/lcov-report/src/utils/Constants.ts.html +1 -1
  31. package/coverage/lcov-report/src/utils/RecommendationError.tsx.html +1 -1
  32. package/coverage/lcov-report/src/utils/RecommendationUtils.ts.html +1 -1
  33. package/coverage/lcov-report/src/utils/Translations.ts.html +1 -1
  34. package/coverage/lcov-report/src/utils/Utils.ts.html +1 -1
  35. package/coverage/lcov-report/src/utils/Validations.ts.html +1 -1
  36. package/coverage/lcov-report/src/utils/index.html +1 -1
  37. package/index.js +5 -31
  38. package/package.json +2 -1
  39. package/src/RecommendationScreen.js +76 -101
  40. package/src/__tests__/RecommendationScreen.test.js +404 -409
  41. package/src/__tests__/RecommendationUtils.test.js +117 -119
  42. package/src/__tests__/Translate.test.js +14 -16
  43. package/src/__tests__/Utils.test.js +16 -18
  44. package/src/__tests__/Validations.test.js +30 -51
  45. package/src/__tests__/components/Activity.test.js +51 -56
  46. package/src/__tests__/components/Emotion.test.js +28 -33
  47. package/src/__tests__/components/Header.test.js +24 -29
  48. package/src/__tests__/components/InfoBars.test.js +59 -64
  49. package/src/__tests__/components/InvisibleNumberInput.test.js +22 -27
  50. package/src/__tests__/components/LimitationMessage.test.js +28 -33
  51. package/src/__tests__/components/MoodIcon.test.js +9 -14
  52. package/src/__tests__/components/RecommendationModal.test.js +56 -61
  53. package/src/__tests__/components/RecommendedCarbs.test.js +58 -63
  54. package/src/__tests__/components/RecommendedInsulin.test.js +60 -65
  55. package/src/__tests__/components/Remeasure.test.js +32 -37
  56. package/src/__tests__/components/TransferToLogbook.test.js +15 -20
  57. package/src/__tests__/components/TwoOptionModal.test.js +22 -27
  58. package/src/__tests__/utils.js +22 -38
  59. package/src/components/Header.js +34 -41
  60. package/src/components/Icon.js +2 -8
  61. package/src/components/InfoBars.js +36 -43
  62. package/src/components/InvisibleNumberInput.js +5 -11
  63. package/src/components/LimitationMessage.js +18 -40
  64. package/src/components/LineSeparator.js +7 -13
  65. package/src/components/RecentInsulin.js +33 -39
  66. package/src/components/RecommendationModal.js +59 -85
  67. package/src/components/RecommendedCarbs.js +93 -99
  68. package/src/components/RecommendedInsulin.js +46 -52
  69. package/src/components/Remeasure.js +36 -42
  70. package/src/components/TransferToLogbook.js +20 -26
  71. package/src/components/TwoOptionModal.js +39 -65
  72. package/src/components/activity/Activity.js +42 -48
  73. package/src/components/activity/ActivityIcon.js +15 -21
  74. package/src/components/activity/ActivityIntensity.js +19 -25
  75. package/src/components/mood/Emotion.js +17 -23
  76. package/src/components/mood/MoodIcon.js +11 -17
  77. package/src/locale/i18nUtils.js +17 -24
  78. package/src/types/enum.js +28 -31
  79. package/src/types/types.js +1 -2
  80. package/src/utils/AttentionMessages.js +24 -32
  81. package/src/utils/Constants.js +23 -26
  82. package/src/utils/RecommendationError.js +28 -54
  83. package/src/utils/RecommendationUtils.js +60 -72
  84. package/src/utils/Translations.js +6 -9
  85. package/src/utils/Utils.js +8 -12
  86. package/src/utils/Validations.js +77 -107
  87. package/tsconfig.json +3 -3
@@ -1,55 +1,53 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const types_1 = require("@hedia/types");
4
- const enum_1 = require("../types/enum");
5
- const AttentionMessages_1 = require("../utils/AttentionMessages");
6
- const RecommendationError_1 = require("../utils/RecommendationError");
7
- const RecommendationUtils_1 = require("../utils/RecommendationUtils");
8
- const utils_1 = require("./utils");
9
- const ActivityIntensity = types_1.Activity.Enums.ActivityIntensity;
1
+ import { Activity, Milliseconds } from "@hedia/types";
2
+ import { BgLevel, RecommendationReminders } from "../types/enum";
3
+ import { addPostponeActivityMessageUnder5MMOL, AttentionMessage, Messages } from "../utils/AttentionMessages";
4
+ import { CurrentBGLError } from "../utils/RecommendationError";
5
+ import { getAttentionMessage, getBGLevel, getLimitationMessage, getReminder, isActivityWithin15Minutes, isSevereHyperglycemia, } from "../utils/RecommendationUtils";
6
+ import { generateDefaultActivitySettings, generateDefaultLogbook } from "./utils";
7
+ const ActivityIntensity = Activity.Enums.ActivityIntensity;
10
8
  const { moderate } = ActivityIntensity;
11
9
  describe(`Actions based on the blood glucose level:: InsulinSettingsUtils `, () => {
12
10
  const logbookUnder15MMOL = {
13
- ...utils_1.generateDefaultLogbook(),
11
+ ...generateDefaultLogbook(),
14
12
  blood_glucose_millimolar: 14.9,
15
13
  };
16
14
  const logbookOver15MMOL = {
17
- ...utils_1.generateDefaultLogbook(),
15
+ ...generateDefaultLogbook(),
18
16
  blood_glucose_millimolar: 15.1,
19
17
  };
20
18
  const logbookWithNullBloodGlucose = {
21
- ...utils_1.generateDefaultLogbook(),
19
+ ...generateDefaultLogbook(),
22
20
  blood_glucose_millimolar: null,
23
21
  };
24
- const inactiveDate = new Date(Date.now() + types_1.Milliseconds.Minute * 15.1);
22
+ const inactiveDate = new Date(Date.now() + Milliseconds.Minute * 15.1);
25
23
  const activeDate = new Date();
26
24
  const activeActivity = {
27
25
  activityDate: activeDate,
28
26
  activityDuration: 10,
29
27
  activityIntensity: moderate,
30
- activitySettings: utils_1.generateDefaultActivitySettings(),
28
+ activitySettings: generateDefaultActivitySettings(),
31
29
  };
32
30
  const inactiveActivity = { ...activeActivity, activityDate: inactiveDate };
33
31
  it.each `
34
32
  bloodGlucoseValue | latestLogbookFrom6Hours | bgLevel
35
- ${1} | ${null} | ${enum_1.BgLevel.UnsupportedBGLevel}
36
- ${33.4} | ${logbookOver15MMOL} | ${enum_1.BgLevel.UnsupportedBGLevel}
37
- ${1.1} | ${null} | ${enum_1.BgLevel.SevereHypoglycemia}
38
- ${2} | ${logbookOver15MMOL} | ${enum_1.BgLevel.SevereHypoglycemia}
39
- ${3.5} | ${logbookOver15MMOL} | ${enum_1.BgLevel.Hypoglycemia}
40
- ${3.6} | ${null} | ${enum_1.BgLevel.MildHypoglycemia}
41
- ${4} | ${logbookOver15MMOL} | ${enum_1.BgLevel.MildHypoglycemia}
42
- ${4.1} | ${null} | ${enum_1.BgLevel.NormoglycemiaUnder5MMOL}
43
- ${5} | ${logbookUnder15MMOL} | ${enum_1.BgLevel.Normoglycemia}
44
- ${9} | ${null} | ${enum_1.BgLevel.MildHyperglycemia}
45
- ${15} | ${logbookOver15MMOL} | ${enum_1.BgLevel.Hyperglycemia}
46
- ${15.1} | ${null} | ${enum_1.BgLevel.Hyperglycemia}
47
- ${15.1} | ${logbookUnder15MMOL} | ${enum_1.BgLevel.Hyperglycemia}
48
- ${27.2} | ${null} | ${enum_1.BgLevel.Hyperglycemia}
49
- ${15.1} | ${logbookOver15MMOL} | ${enum_1.BgLevel.SevereHyperglycemia}
50
- ${20} | ${logbookOver15MMOL} | ${enum_1.BgLevel.SevereHyperglycemia}
33
+ ${1} | ${null} | ${BgLevel.UnsupportedBGLevel}
34
+ ${33.4} | ${logbookOver15MMOL} | ${BgLevel.UnsupportedBGLevel}
35
+ ${1.1} | ${null} | ${BgLevel.SevereHypoglycemia}
36
+ ${2} | ${logbookOver15MMOL} | ${BgLevel.SevereHypoglycemia}
37
+ ${3.5} | ${logbookOver15MMOL} | ${BgLevel.Hypoglycemia}
38
+ ${3.6} | ${null} | ${BgLevel.MildHypoglycemia}
39
+ ${4} | ${logbookOver15MMOL} | ${BgLevel.MildHypoglycemia}
40
+ ${4.1} | ${null} | ${BgLevel.NormoglycemiaUnder5MMOL}
41
+ ${5} | ${logbookUnder15MMOL} | ${BgLevel.Normoglycemia}
42
+ ${9} | ${null} | ${BgLevel.MildHyperglycemia}
43
+ ${15} | ${logbookOver15MMOL} | ${BgLevel.Hyperglycemia}
44
+ ${15.1} | ${null} | ${BgLevel.Hyperglycemia}
45
+ ${15.1} | ${logbookUnder15MMOL} | ${BgLevel.Hyperglycemia}
46
+ ${27.2} | ${null} | ${BgLevel.Hyperglycemia}
47
+ ${15.1} | ${logbookOver15MMOL} | ${BgLevel.SevereHyperglycemia}
48
+ ${20} | ${logbookOver15MMOL} | ${BgLevel.SevereHyperglycemia}
51
49
  `(`return the correct BG level for $bloodGlucoseValue`, ({ bloodGlucoseValue, bgLevel, latestLogbookFrom6Hours }) => {
52
- expect(RecommendationUtils_1.getBGLevel(bloodGlucoseValue, latestLogbookFrom6Hours)).toBe(bgLevel);
50
+ expect(getBGLevel(bloodGlucoseValue, latestLogbookFrom6Hours)).toBe(bgLevel);
53
51
  });
54
52
  it.each `
55
53
  latestLogbookFrom6Hours | severeHyperglycemia
@@ -60,7 +58,7 @@ describe(`Actions based on the blood glucose level:: InsulinSettingsUtils `, ()
60
58
  ${{}} | ${false}
61
59
  ${logbookWithNullBloodGlucose} | ${false}
62
60
  `(`tests isSevereGlycemia method `, ({ latestLogbookFrom6Hours, severeHyperglycemia }) => {
63
- expect(RecommendationUtils_1.isSevereHyperglycemia(latestLogbookFrom6Hours)).toBe(severeHyperglycemia);
61
+ expect(isSevereHyperglycemia(latestLogbookFrom6Hours)).toBe(severeHyperglycemia);
64
62
  });
65
63
  it.each `
66
64
  activity | within15Minutes
@@ -70,149 +68,149 @@ describe(`Actions based on the blood glucose level:: InsulinSettingsUtils `, ()
70
68
  ${null} | ${false}
71
69
  ${undefined} | ${false}
72
70
  `(`tests isActivityWithin15Minutes `, ({ activity, within15Minutes }) => {
73
- expect(RecommendationUtils_1.isActivityWithin15Minutes(activity)).toBe(within15Minutes);
71
+ expect(isActivityWithin15Minutes(activity)).toBe(within15Minutes);
74
72
  });
75
73
  it.each `
76
74
  bgLevel | activity | attentionMessage
77
- ${enum_1.BgLevel.UnsupportedBGLevel} | ${activeActivity} | ${RecommendationError_1.CurrentBGLError()}
78
- ${enum_1.BgLevel.UnsupportedBGLevel} | ${inactiveActivity} | ${RecommendationError_1.CurrentBGLError()}
75
+ ${BgLevel.UnsupportedBGLevel} | ${activeActivity} | ${CurrentBGLError()}
76
+ ${BgLevel.UnsupportedBGLevel} | ${inactiveActivity} | ${CurrentBGLError()}
79
77
  `(`Unsupported bg level throws error`, ({ bgLevel, activity, attentionMessage }) => {
80
- expect(() => RecommendationUtils_1.getAttentionMessage(bgLevel, activity)).toThrowError(attentionMessage);
78
+ expect(() => getAttentionMessage(bgLevel, activity)).toThrowError(attentionMessage);
81
79
  });
82
80
  it.each `
83
81
  bgLevel | activity | attentionMessage
84
- ${enum_1.BgLevel.BGLevelNotProvided} | ${activeActivity} | ${null}
85
- ${enum_1.BgLevel.SevereHypoglycemia} | ${activeActivity} | ${AttentionMessages_1.addPostponeActivityMessageUnder5MMOL(AttentionMessages_1.AttentionMessage.SevereHypoglycemia())}
86
- ${enum_1.BgLevel.Hypoglycemia} | ${activeActivity} | ${AttentionMessages_1.addPostponeActivityMessageUnder5MMOL(AttentionMessages_1.AttentionMessage.Hypoglycemia())}
87
- ${enum_1.BgLevel.MildHypoglycemia} | ${activeActivity} | ${AttentionMessages_1.addPostponeActivityMessageUnder5MMOL(AttentionMessages_1.AttentionMessage.MildHypoglycemia())}
88
- ${enum_1.BgLevel.NormoglycemiaUnder5MMOL} | ${activeActivity} | ${AttentionMessages_1.AttentionMessage.NormoglycemiaActivityUnder5MMOL()}
89
- ${enum_1.BgLevel.Normoglycemia} | ${activeActivity} | ${null}
90
- ${enum_1.BgLevel.MildHyperglycemia} | ${activeActivity} | ${null}
91
- ${enum_1.BgLevel.Hyperglycemia} | ${activeActivity} | ${AttentionMessages_1.AttentionMessage.HyperglycemiaActivity()}
92
- ${enum_1.BgLevel.SevereHyperglycemia} | ${activeActivity} | ${AttentionMessages_1.AttentionMessage.SevereHyperglycemiaActivity()}
82
+ ${BgLevel.BGLevelNotProvided} | ${activeActivity} | ${null}
83
+ ${BgLevel.SevereHypoglycemia} | ${activeActivity} | ${addPostponeActivityMessageUnder5MMOL(AttentionMessage.SevereHypoglycemia())}
84
+ ${BgLevel.Hypoglycemia} | ${activeActivity} | ${addPostponeActivityMessageUnder5MMOL(AttentionMessage.Hypoglycemia())}
85
+ ${BgLevel.MildHypoglycemia} | ${activeActivity} | ${addPostponeActivityMessageUnder5MMOL(AttentionMessage.MildHypoglycemia())}
86
+ ${BgLevel.NormoglycemiaUnder5MMOL} | ${activeActivity} | ${AttentionMessage.NormoglycemiaActivityUnder5MMOL()}
87
+ ${BgLevel.Normoglycemia} | ${activeActivity} | ${null}
88
+ ${BgLevel.MildHyperglycemia} | ${activeActivity} | ${null}
89
+ ${BgLevel.Hyperglycemia} | ${activeActivity} | ${AttentionMessage.HyperglycemiaActivity()}
90
+ ${BgLevel.SevereHyperglycemia} | ${activeActivity} | ${AttentionMessage.SevereHyperglycemiaActivity()}
93
91
  `(`return the correct attention message with an active activity for $bgLevel`, ({ bgLevel, activity, attentionMessage }) => {
94
- expect(RecommendationUtils_1.getAttentionMessage(bgLevel, activity)).toBe(attentionMessage);
92
+ expect(getAttentionMessage(bgLevel, activity)).toBe(attentionMessage);
95
93
  });
96
94
  it.each `
97
95
  bgLevel | activity | attentionMessage
98
- ${enum_1.BgLevel.BGLevelNotProvided} | ${inactiveActivity} | ${null}
99
- ${enum_1.BgLevel.SevereHypoglycemia} | ${inactiveActivity} | ${AttentionMessages_1.AttentionMessage.SevereHypoglycemia()}
100
- ${enum_1.BgLevel.Hypoglycemia} | ${inactiveActivity} | ${AttentionMessages_1.AttentionMessage.Hypoglycemia()}
101
- ${enum_1.BgLevel.MildHypoglycemia} | ${inactiveActivity} | ${AttentionMessages_1.AttentionMessage.MildHypoglycemia()}
102
- ${enum_1.BgLevel.NormoglycemiaUnder5MMOL} | ${inactiveActivity} | ${null}
103
- ${enum_1.BgLevel.Normoglycemia} | ${inactiveActivity} | ${null}
104
- ${enum_1.BgLevel.MildHyperglycemia} | ${inactiveActivity} | ${null}
105
- ${enum_1.BgLevel.Hyperglycemia} | ${inactiveActivity} | ${null}
106
- ${enum_1.BgLevel.SevereHyperglycemia} | ${inactiveActivity} | ${AttentionMessages_1.AttentionMessage.SevereHyperglycemia()}
96
+ ${BgLevel.BGLevelNotProvided} | ${inactiveActivity} | ${null}
97
+ ${BgLevel.SevereHypoglycemia} | ${inactiveActivity} | ${AttentionMessage.SevereHypoglycemia()}
98
+ ${BgLevel.Hypoglycemia} | ${inactiveActivity} | ${AttentionMessage.Hypoglycemia()}
99
+ ${BgLevel.MildHypoglycemia} | ${inactiveActivity} | ${AttentionMessage.MildHypoglycemia()}
100
+ ${BgLevel.NormoglycemiaUnder5MMOL} | ${inactiveActivity} | ${null}
101
+ ${BgLevel.Normoglycemia} | ${inactiveActivity} | ${null}
102
+ ${BgLevel.MildHyperglycemia} | ${inactiveActivity} | ${null}
103
+ ${BgLevel.Hyperglycemia} | ${inactiveActivity} | ${null}
104
+ ${BgLevel.SevereHyperglycemia} | ${inactiveActivity} | ${AttentionMessage.SevereHyperglycemia()}
107
105
  `(`return the correct attention message with an inactive activity for $bgLevel`, ({ bgLevel, activity, attentionMessage }) => {
108
- expect(RecommendationUtils_1.getAttentionMessage(bgLevel, activity)).toBe(attentionMessage);
106
+ expect(getAttentionMessage(bgLevel, activity)).toBe(attentionMessage);
109
107
  });
110
108
  it.each `
111
109
  bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
112
- ${enum_1.BgLevel.UnsupportedBGLevel} | ${activeActivity} | ${0} | ${1} | ${RecommendationError_1.CurrentBGLError()}
113
- ${enum_1.BgLevel.UnsupportedBGLevel} | ${inactiveActivity} | ${1} | ${2} | ${RecommendationError_1.CurrentBGLError()}
114
- ${enum_1.BgLevel.UnsupportedBGLevel} | ${null} | ${0} | ${undefined} | ${RecommendationError_1.CurrentBGLError()}
115
- ${enum_1.BgLevel.UnsupportedBGLevel} | ${null} | ${1} | ${0} | ${RecommendationError_1.CurrentBGLError()}
110
+ ${BgLevel.UnsupportedBGLevel} | ${activeActivity} | ${0} | ${1} | ${CurrentBGLError()}
111
+ ${BgLevel.UnsupportedBGLevel} | ${inactiveActivity} | ${1} | ${2} | ${CurrentBGLError()}
112
+ ${BgLevel.UnsupportedBGLevel} | ${null} | ${0} | ${undefined} | ${CurrentBGLError()}
113
+ ${BgLevel.UnsupportedBGLevel} | ${null} | ${1} | ${0} | ${CurrentBGLError()}
116
114
  `(`Unsupported bg level throws error`, ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }) => {
117
- expect(() => RecommendationUtils_1.getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toThrowError(expectedReminder);
115
+ expect(() => getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toThrowError(expectedReminder);
118
116
  });
119
117
  it.each `
120
118
  bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
121
- ${enum_1.BgLevel.BGLevelNotProvided} | ${activeActivity} | ${0} | ${1} | ${1}
122
- ${enum_1.BgLevel.BGLevelNotProvided} | ${inactiveActivity} | ${0} | ${2.5} | ${2.5}
123
- ${enum_1.BgLevel.BGLevelNotProvided} | ${null} | ${0} | ${2} | ${enum_1.RecommendationReminders.ReminderOff}
119
+ ${BgLevel.BGLevelNotProvided} | ${activeActivity} | ${0} | ${1} | ${1}
120
+ ${BgLevel.BGLevelNotProvided} | ${inactiveActivity} | ${0} | ${2.5} | ${2.5}
121
+ ${BgLevel.BGLevelNotProvided} | ${null} | ${0} | ${2} | ${RecommendationReminders.ReminderOff}
124
122
  `(`return the correct BG reminder value for when the bgl is not provided`, ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }) => {
125
- expect(RecommendationUtils_1.getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
123
+ expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
126
124
  });
127
125
  it.each `
128
126
  bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
129
- ${enum_1.BgLevel.SevereHypoglycemia} | ${activeActivity} | ${0} | ${1} | ${enum_1.RecommendationReminders.Reminder15Minutes}
130
- ${enum_1.BgLevel.SevereHypoglycemia} | ${inactiveActivity} | ${0} | ${2} | ${enum_1.RecommendationReminders.Reminder15Minutes}
131
- ${enum_1.BgLevel.SevereHypoglycemia} | ${null} | ${0} | ${undefined} | ${enum_1.RecommendationReminders.Reminder15Minutes}
132
- ${enum_1.BgLevel.SevereHypoglycemia} | ${null} | ${1} | ${0} | ${enum_1.RecommendationReminders.Reminder15Minutes}
127
+ ${BgLevel.SevereHypoglycemia} | ${activeActivity} | ${0} | ${1} | ${RecommendationReminders.Reminder15Minutes}
128
+ ${BgLevel.SevereHypoglycemia} | ${inactiveActivity} | ${0} | ${2} | ${RecommendationReminders.Reminder15Minutes}
129
+ ${BgLevel.SevereHypoglycemia} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.Reminder15Minutes}
130
+ ${BgLevel.SevereHypoglycemia} | ${null} | ${1} | ${0} | ${RecommendationReminders.Reminder15Minutes}
133
131
  `(`return the correct BG reminder value for severe glycemia`, ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }) => {
134
- expect(RecommendationUtils_1.getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
132
+ expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
135
133
  });
136
134
  it.each `
137
135
  bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
138
- ${enum_1.BgLevel.Hypoglycemia} | ${activeActivity} | ${0} | ${1} | ${enum_1.RecommendationReminders.Reminder15Minutes}
139
- ${enum_1.BgLevel.Hypoglycemia} | ${inactiveActivity} | ${1} | ${2} | ${enum_1.RecommendationReminders.Reminder15Minutes}
140
- ${enum_1.BgLevel.Hypoglycemia} | ${null} | ${0} | ${undefined} | ${enum_1.RecommendationReminders.Reminder15Minutes}
141
- ${enum_1.BgLevel.Hypoglycemia} | ${null} | ${1} | ${0} | ${enum_1.RecommendationReminders.Reminder15Minutes}
136
+ ${BgLevel.Hypoglycemia} | ${activeActivity} | ${0} | ${1} | ${RecommendationReminders.Reminder15Minutes}
137
+ ${BgLevel.Hypoglycemia} | ${inactiveActivity} | ${1} | ${2} | ${RecommendationReminders.Reminder15Minutes}
138
+ ${BgLevel.Hypoglycemia} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.Reminder15Minutes}
139
+ ${BgLevel.Hypoglycemia} | ${null} | ${1} | ${0} | ${RecommendationReminders.Reminder15Minutes}
142
140
  `(`return the correct BG reminder value for hypoglycemia`, ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }) => {
143
- expect(RecommendationUtils_1.getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
141
+ expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
144
142
  });
145
143
  it.each `
146
144
  bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
147
- ${enum_1.BgLevel.MildHypoglycemia} | ${activeActivity} | ${0} | ${1} | ${enum_1.RecommendationReminders.Reminder15Minutes}
148
- ${enum_1.BgLevel.MildHypoglycemia} | ${activeActivity} | ${1} | ${2} | ${enum_1.RecommendationReminders.Reminder15Minutes}
149
- ${enum_1.BgLevel.MildHypoglycemia} | ${null} | ${0} | ${3} | ${enum_1.RecommendationReminders.Reminder15Minutes}
150
- ${enum_1.BgLevel.MildHypoglycemia} | ${null} | ${1} | ${4} | ${enum_1.RecommendationReminders.Reminder15Minutes}
145
+ ${BgLevel.MildHypoglycemia} | ${activeActivity} | ${0} | ${1} | ${RecommendationReminders.Reminder15Minutes}
146
+ ${BgLevel.MildHypoglycemia} | ${activeActivity} | ${1} | ${2} | ${RecommendationReminders.Reminder15Minutes}
147
+ ${BgLevel.MildHypoglycemia} | ${null} | ${0} | ${3} | ${RecommendationReminders.Reminder15Minutes}
148
+ ${BgLevel.MildHypoglycemia} | ${null} | ${1} | ${4} | ${RecommendationReminders.Reminder15Minutes}
151
149
  `(`return the correct BG reminder value for MildHypoglycemia`, ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }) => {
152
- expect(RecommendationUtils_1.getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
150
+ expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
153
151
  });
154
152
  it.each `
155
153
  bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
156
- ${enum_1.BgLevel.NormoglycemiaUnder5MMOL} | ${activeActivity} | ${0} | ${0.5} | ${0.5}
157
- ${enum_1.BgLevel.NormoglycemiaUnder5MMOL} | ${inactiveActivity} | ${1} | ${2} | ${2}
158
- ${enum_1.BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${1} | ${6} | ${6}
159
- ${enum_1.BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${0} | ${undefined} | ${enum_1.RecommendationReminders.ReminderOff}
160
- ${enum_1.BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${1} | ${undefined} | ${enum_1.RecommendationReminders.HediaReminderDefault}
161
- ${enum_1.BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${0} | ${1} | ${enum_1.RecommendationReminders.ReminderOff}
162
- ${enum_1.BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${0} | ${2} | ${enum_1.RecommendationReminders.ReminderOff}
154
+ ${BgLevel.NormoglycemiaUnder5MMOL} | ${activeActivity} | ${0} | ${0.5} | ${0.5}
155
+ ${BgLevel.NormoglycemiaUnder5MMOL} | ${inactiveActivity} | ${1} | ${2} | ${2}
156
+ ${BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${1} | ${6} | ${6}
157
+ ${BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.ReminderOff}
158
+ ${BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${1} | ${undefined} | ${RecommendationReminders.HediaReminderDefault}
159
+ ${BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${0} | ${1} | ${RecommendationReminders.ReminderOff}
160
+ ${BgLevel.NormoglycemiaUnder5MMOL} | ${null} | ${0} | ${2} | ${RecommendationReminders.ReminderOff}
163
161
  `(`return the correct BG reminder value for normoglycemia under 5 mmol/L`, ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }) => {
164
- expect(RecommendationUtils_1.getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
162
+ expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
165
163
  });
166
164
  it.each `
167
165
  bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
168
- ${enum_1.BgLevel.Normoglycemia} | ${activeActivity} | ${0} | ${0.5} | ${0.5}
169
- ${enum_1.BgLevel.Normoglycemia} | ${inactiveActivity} | ${1} | ${2} | ${2}
170
- ${enum_1.BgLevel.Normoglycemia} | ${null} | ${1} | ${6} | ${6}
171
- ${enum_1.BgLevel.Normoglycemia} | ${null} | ${0} | ${undefined} | ${enum_1.RecommendationReminders.ReminderOff}
172
- ${enum_1.BgLevel.Normoglycemia} | ${null} | ${1} | ${undefined} | ${enum_1.RecommendationReminders.HediaReminderDefault}
173
- ${enum_1.BgLevel.Normoglycemia} | ${null} | ${0} | ${1} | ${enum_1.RecommendationReminders.ReminderOff}
174
- ${enum_1.BgLevel.Normoglycemia} | ${null} | ${0} | ${2} | ${enum_1.RecommendationReminders.ReminderOff}
166
+ ${BgLevel.Normoglycemia} | ${activeActivity} | ${0} | ${0.5} | ${0.5}
167
+ ${BgLevel.Normoglycemia} | ${inactiveActivity} | ${1} | ${2} | ${2}
168
+ ${BgLevel.Normoglycemia} | ${null} | ${1} | ${6} | ${6}
169
+ ${BgLevel.Normoglycemia} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.ReminderOff}
170
+ ${BgLevel.Normoglycemia} | ${null} | ${1} | ${undefined} | ${RecommendationReminders.HediaReminderDefault}
171
+ ${BgLevel.Normoglycemia} | ${null} | ${0} | ${1} | ${RecommendationReminders.ReminderOff}
172
+ ${BgLevel.Normoglycemia} | ${null} | ${0} | ${2} | ${RecommendationReminders.ReminderOff}
175
173
  `(`return the correct BG reminder value for normoglycemia`, ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }) => {
176
- expect(RecommendationUtils_1.getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
174
+ expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
177
175
  });
178
176
  it.each `
179
177
  bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
180
- ${enum_1.BgLevel.MildHyperglycemia} | ${activeActivity} | ${0} | ${3.5} | ${3.5}
181
- ${enum_1.BgLevel.MildHyperglycemia} | ${inactiveActivity} | ${1} | ${2} | ${2}
182
- ${enum_1.BgLevel.MildHyperglycemia} | ${null} | ${1} | ${2.5} | ${2.5}
183
- ${enum_1.BgLevel.MildHyperglycemia} | ${null} | ${0} | ${undefined} | ${enum_1.RecommendationReminders.ReminderOff}
184
- ${enum_1.BgLevel.MildHyperglycemia} | ${null} | ${1} | ${undefined} | ${enum_1.RecommendationReminders.HediaReminderDefault}
185
- ${enum_1.BgLevel.MildHyperglycemia} | ${null} | ${0} | ${1} | ${enum_1.RecommendationReminders.ReminderOff}
186
- ${enum_1.BgLevel.MildHyperglycemia} | ${null} | ${0} | ${2} | ${enum_1.RecommendationReminders.ReminderOff}
178
+ ${BgLevel.MildHyperglycemia} | ${activeActivity} | ${0} | ${3.5} | ${3.5}
179
+ ${BgLevel.MildHyperglycemia} | ${inactiveActivity} | ${1} | ${2} | ${2}
180
+ ${BgLevel.MildHyperglycemia} | ${null} | ${1} | ${2.5} | ${2.5}
181
+ ${BgLevel.MildHyperglycemia} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.ReminderOff}
182
+ ${BgLevel.MildHyperglycemia} | ${null} | ${1} | ${undefined} | ${RecommendationReminders.HediaReminderDefault}
183
+ ${BgLevel.MildHyperglycemia} | ${null} | ${0} | ${1} | ${RecommendationReminders.ReminderOff}
184
+ ${BgLevel.MildHyperglycemia} | ${null} | ${0} | ${2} | ${RecommendationReminders.ReminderOff}
187
185
  `(`return the correct BG reminder value for mildglycemia`, ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }) => {
188
- expect(RecommendationUtils_1.getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
186
+ expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
189
187
  });
190
188
  it.each `
191
189
  bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
192
- ${enum_1.BgLevel.Hyperglycemia} | ${activeActivity} | ${0} | ${1} | ${enum_1.RecommendationReminders.Reminder15Minutes}
193
- ${enum_1.BgLevel.Hyperglycemia} | ${inactiveActivity} | ${1} | ${2} | ${enum_1.RecommendationReminders.Reminder60Minutes}
194
- ${enum_1.BgLevel.Hyperglycemia} | ${activeActivity} | ${0} | ${undefined} | ${enum_1.RecommendationReminders.Reminder15Minutes}
195
- ${enum_1.BgLevel.Hyperglycemia} | ${null} | ${0} | ${undefined} | ${enum_1.RecommendationReminders.Reminder60Minutes}
196
- ${enum_1.BgLevel.Hyperglycemia} | ${activeActivity} | ${1} | ${1} | ${enum_1.RecommendationReminders.Reminder15Minutes}
197
- ${enum_1.BgLevel.Hyperglycemia} | ${null} | ${1} | ${2} | ${enum_1.RecommendationReminders.Reminder60Minutes}
190
+ ${BgLevel.Hyperglycemia} | ${activeActivity} | ${0} | ${1} | ${RecommendationReminders.Reminder15Minutes}
191
+ ${BgLevel.Hyperglycemia} | ${inactiveActivity} | ${1} | ${2} | ${RecommendationReminders.Reminder60Minutes}
192
+ ${BgLevel.Hyperglycemia} | ${activeActivity} | ${0} | ${undefined} | ${RecommendationReminders.Reminder15Minutes}
193
+ ${BgLevel.Hyperglycemia} | ${null} | ${0} | ${undefined} | ${RecommendationReminders.Reminder60Minutes}
194
+ ${BgLevel.Hyperglycemia} | ${activeActivity} | ${1} | ${1} | ${RecommendationReminders.Reminder15Minutes}
195
+ ${BgLevel.Hyperglycemia} | ${null} | ${1} | ${2} | ${RecommendationReminders.Reminder60Minutes}
198
196
  `(`return the correct BG reminder value for hyperglycemia`, ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }) => {
199
- expect(RecommendationUtils_1.getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
197
+ expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
200
198
  });
201
199
  it.each `
202
200
  bgLevel | activity | carbohydrates | remeasureTime | expectedReminder
203
- ${enum_1.BgLevel.SevereHyperglycemia} | ${activeActivity} | ${0} | ${2} | ${enum_1.RecommendationReminders.Reminder15Minutes}
204
- ${enum_1.BgLevel.SevereHyperglycemia} | ${inactiveActivity} | ${1} | ${2} | ${enum_1.RecommendationReminders.Reminder60Minutes}
205
- ${enum_1.BgLevel.SevereHyperglycemia} | ${null} | ${1} | ${undefined} | ${enum_1.RecommendationReminders.Reminder60Minutes}
206
- ${enum_1.BgLevel.SevereHyperglycemia} | ${inactiveActivity} | ${1} | ${2} | ${enum_1.RecommendationReminders.Reminder60Minutes}
201
+ ${BgLevel.SevereHyperglycemia} | ${activeActivity} | ${0} | ${2} | ${RecommendationReminders.Reminder15Minutes}
202
+ ${BgLevel.SevereHyperglycemia} | ${inactiveActivity} | ${1} | ${2} | ${RecommendationReminders.Reminder60Minutes}
203
+ ${BgLevel.SevereHyperglycemia} | ${null} | ${1} | ${undefined} | ${RecommendationReminders.Reminder60Minutes}
204
+ ${BgLevel.SevereHyperglycemia} | ${inactiveActivity} | ${1} | ${2} | ${RecommendationReminders.Reminder60Minutes}
207
205
  `(`return the correct BG reminder value for severeglycemia `, ({ bgLevel, activity, carbohydrates, remeasureTime, expectedReminder }) => {
208
- expect(RecommendationUtils_1.getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
206
+ expect(getReminder(bgLevel, carbohydrates, remeasureTime, activity)).toBe(expectedReminder);
209
207
  });
210
208
  it.each `
211
209
  wasLimited | activityReduction | attentionMessage
212
- ${true} | ${0.25} | ${AttentionMessages_1.Messages.RecommendationWasLimitedActivity(0.25)}
213
- ${true} | ${0} | ${AttentionMessages_1.Messages.RecommendationWasLimited()}
210
+ ${true} | ${0.25} | ${Messages.RecommendationWasLimitedActivity(0.25)}
211
+ ${true} | ${0} | ${Messages.RecommendationWasLimited()}
214
212
  ${false} | ${0} | ${null}
215
213
  `(`return the correct attention message for $bgLevel`, ({ wasLimited, activityReduction, attentionMessage }) => {
216
- expect(RecommendationUtils_1.getLimitationMessage(wasLimited, activityReduction)).toBe(attentionMessage);
214
+ expect(getLimitationMessage(wasLimited, activityReduction)).toBe(attentionMessage);
217
215
  });
218
216
  });
@@ -1,29 +1,27 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  // @ts-nocheck
4
- const types_1 = require("@hedia/types");
5
- const i18nUtils_1 = require("../locale/i18nUtils");
2
+ import { Languages } from "@hedia/types";
3
+ import { changeLanguage, i18n } from "../locale/i18nUtils";
6
4
  describe(`Translation Utils`, () => {
7
5
  test(`Same instance`, () => {
8
- expect(i18nUtils_1.i18n).toBe(i18nUtils_1.i18n);
6
+ expect(i18n).toBe(i18n);
9
7
  });
10
8
  test.each `
11
9
  locale | text
12
- ${types_1.Languages.da} | ${`Dansk`}
13
- ${types_1.Languages.en} | ${`English`}
14
- ${types_1.Languages.de} | ${`Deutsch`}
15
- ${types_1.Languages.es} | ${`Español`}
16
- ${types_1.Languages.it} | ${`Italiano`}
17
- ${types_1.Languages.fr} | ${`Français`}
10
+ ${Languages.da} | ${`Dansk`}
11
+ ${Languages.en} | ${`English`}
12
+ ${Languages.de} | ${`Deutsch`}
13
+ ${Languages.es} | ${`Español`}
14
+ ${Languages.it} | ${`Italiano`}
15
+ ${Languages.fr} | ${`Français`}
18
16
  `(`Change to the right language; $locale`, ({ locale, text }) => {
19
- expect(i18nUtils_1.changeLanguage(locale).language).toBe(text);
17
+ expect(changeLanguage(locale).language).toBe(text);
20
18
  });
21
19
  test.each `
22
20
  locale | text
23
- ${types_1.Languages.nl} | ${types_1.Languages.en}
24
- ${types_1.Languages.jp} | ${types_1.Languages.en}
25
- ${types_1.Languages.ro} | ${types_1.Languages.en}
21
+ ${Languages.nl} | ${Languages.en}
22
+ ${Languages.jp} | ${Languages.en}
23
+ ${Languages.ro} | ${Languages.en}
26
24
  `(`Unsupported language defaults to english; $locale`, ({ locale, text }) => {
27
- expect(i18nUtils_1.changeLanguage(locale).language).toBe(text);
25
+ expect(changeLanguage(locale).language).toBe(text);
28
26
  });
29
27
  });
@@ -1,9 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const types_1 = require("@hedia/types");
4
- const Constants_1 = require("../utils/Constants");
5
- const Utils_1 = require("../utils/Utils");
6
- const InjectionMethod = types_1.UserSettings.Enums.InjectionMethod;
1
+ import { UserSettings } from "@hedia/types";
2
+ import { ACTIVITY_DURATION_MINUTES_LIMITS } from "../utils/Constants";
3
+ import { Utils } from "../utils/Utils";
4
+ const InjectionMethod = UserSettings.Enums.InjectionMethod;
7
5
  const { PenHalf, PenWhole, Pump } = InjectionMethod;
8
6
  describe(`Utils helper functions`, () => {
9
7
  test.each `
@@ -12,7 +10,7 @@ describe(`Utils helper functions`, () => {
12
10
  ${PenHalf} | ${2}
13
11
  ${Pump} | ${10}
14
12
  `(`Get correct rounding for $method`, ({ expected, method }) => {
15
- expect(Utils_1.Utils.getRounding(method)).toBe(expected);
13
+ expect(Utils.getRounding(method)).toBe(expected);
16
14
  });
17
15
  test.each `
18
16
  value | method | expected
@@ -29,23 +27,23 @@ describe(`Utils helper functions`, () => {
29
27
  ${-1.45} | ${PenHalf} | ${-1.5}
30
28
  ${-1.45} | ${Pump} | ${-1.4}
31
29
  `(`Rounding $value using $method to $expected`, ({ expected, method, value, }) => {
32
- expect(Utils_1.Utils.roundValue(value, method)).toBe(expected);
30
+ expect(Utils.roundValue(value, method)).toBe(expected);
33
31
  });
34
32
  const customInterval = { min: 0, max: 75.5 };
35
33
  test.each `
36
34
  value | interval | expected
37
- ${null} | ${Constants_1.ACTIVITY_DURATION_MINUTES_LIMITS} | ${false}
38
- ${undefined} | ${Constants_1.ACTIVITY_DURATION_MINUTES_LIMITS} | ${false}
39
- ${Constants_1.ACTIVITY_DURATION_MINUTES_LIMITS.max} | ${Constants_1.ACTIVITY_DURATION_MINUTES_LIMITS} | ${true}
40
- ${34} | ${Constants_1.ACTIVITY_DURATION_MINUTES_LIMITS} | ${true}
41
- ${Constants_1.ACTIVITY_DURATION_MINUTES_LIMITS.min} | ${Constants_1.ACTIVITY_DURATION_MINUTES_LIMITS} | ${true}
35
+ ${null} | ${ACTIVITY_DURATION_MINUTES_LIMITS} | ${false}
36
+ ${undefined} | ${ACTIVITY_DURATION_MINUTES_LIMITS} | ${false}
37
+ ${ACTIVITY_DURATION_MINUTES_LIMITS.max} | ${ACTIVITY_DURATION_MINUTES_LIMITS} | ${true}
38
+ ${34} | ${ACTIVITY_DURATION_MINUTES_LIMITS} | ${true}
39
+ ${ACTIVITY_DURATION_MINUTES_LIMITS.min} | ${ACTIVITY_DURATION_MINUTES_LIMITS} | ${true}
42
40
  ${0} | ${customInterval} | ${true}
43
41
  ${25.1} | ${customInterval} | ${true}
44
42
  ${75.6} | ${customInterval} | ${false}
45
- ${-1} | ${Constants_1.ACTIVITY_DURATION_MINUTES_LIMITS} | ${false}
46
- ${3601} | ${Constants_1.ACTIVITY_DURATION_MINUTES_LIMITS} | ${false}
43
+ ${-1} | ${ACTIVITY_DURATION_MINUTES_LIMITS} | ${false}
44
+ ${3601} | ${ACTIVITY_DURATION_MINUTES_LIMITS} | ${false}
47
45
  `(`Check if a number is in the interval`, ({ value, interval, expected }) => {
48
- expect(Utils_1.Utils.isInRange(value, interval)).toBe(expected);
46
+ expect(Utils.isInRange(value, interval)).toBe(expected);
49
47
  });
50
48
  test.each `
51
49
  value | expected
@@ -54,7 +52,7 @@ describe(`Utils helper functions`, () => {
54
52
  ${1.11} | ${20}
55
53
  ${12.325} | ${222}
56
54
  `(`Convert blood glucose from mmol/L to mg/dl`, ({ value, expected }) => {
57
- expect(Utils_1.Utils.convertBGLToMGDL(value)).toBe(expected);
55
+ expect(Utils.convertBGLToMGDL(value)).toBe(expected);
58
56
  });
59
57
  test.each `
60
58
  value | expected
@@ -63,6 +61,6 @@ describe(`Utils helper functions`, () => {
63
61
  ${1.11} | ${12}
64
62
  ${12.325} | ${128}
65
63
  `(`Convert from mmol/L to mg/dl`, ({ value, expected }) => {
66
- expect(Utils_1.Utils.convertBKLToMGDL(value)).toBe(expected);
64
+ expect(Utils.convertBKLToMGDL(value)).toBe(expected);
67
65
  });
68
66
  });
@@ -1,32 +1,11 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- const types_1 = require("@hedia/types");
23
- const Constants_1 = require("../utils/Constants");
24
- const Errors = __importStar(require("../utils/RecommendationError"));
25
- const Validations = __importStar(require("../utils/Validations"));
26
- const utils_1 = require("./utils");
27
- const ActivityEnum = types_1.Activity.Enums.ActivityEnum;
28
- const ActivityIntensity = types_1.Activity.Enums.ActivityIntensity;
29
- const InjectionMethod = types_1.UserSettings.Enums.InjectionMethod;
1
+ import { Activity, BloodGlucoseUnit, BloodKetonesUnit, Languages, Milliseconds, UserSettings } from "@hedia/types";
2
+ import { FOUR_HOURS_SECONDS } from "../utils/Constants";
3
+ import * as Errors from "../utils/RecommendationError";
4
+ import * as Validations from "../utils/Validations";
5
+ import { generateDefaultActivitySettings, generateDefaultLogbook } from "./utils";
6
+ const ActivityEnum = Activity.Enums.ActivityEnum;
7
+ const ActivityIntensity = Activity.Enums.ActivityIntensity;
8
+ const InjectionMethod = UserSettings.Enums.InjectionMethod;
30
9
  const { light, moderate, hard } = ActivityIntensity;
31
10
  describe(`Test validations functions for the recommendation props`, () => {
32
11
  test.each `
@@ -47,8 +26,8 @@ describe(`Test validations functions for the recommendation props`, () => {
47
26
  });
48
27
  test.each `
49
28
  validUnit
50
- ${types_1.BloodGlucoseUnit.MG_DL}
51
- ${types_1.BloodGlucoseUnit.MMOL_L}
29
+ ${BloodGlucoseUnit.MG_DL}
30
+ ${BloodGlucoseUnit.MMOL_L}
52
31
  `(`Validation checking on blood glucose unit types $validUnit`, ({ validUnit }) => {
53
32
  expect(() => Validations.checkBGLUnit(validUnit)).not.toThrowError(Errors.BloodGlucoseUnitError());
54
33
  });
@@ -62,8 +41,8 @@ describe(`Test validations functions for the recommendation props`, () => {
62
41
  });
63
42
  test.each `
64
43
  validKetoneProps
65
- ${{ bloodKetoneUnit: types_1.BloodKetonesUnit.MG_DL, currentBKL: 0 }}
66
- ${{ bloodKetoneUnit: types_1.BloodKetonesUnit.MMOL_L, currentBKL: null }}
44
+ ${{ bloodKetoneUnit: BloodKetonesUnit.MG_DL, currentBKL: 0 }}
45
+ ${{ bloodKetoneUnit: BloodKetonesUnit.MMOL_L, currentBKL: null }}
67
46
  ${{ bloodKetoneUnit: null, currentBKL: null }}
68
47
  `(`Validation checking on valid blood ketones props $validKetoneProps`, ({ validKetoneProps }) => {
69
48
  const { bloodKetoneUnit, currentBKL } = validKetoneProps;
@@ -79,8 +58,8 @@ describe(`Test validations functions for the recommendation props`, () => {
79
58
  });
80
59
  test.each `
81
60
  validUnit
82
- ${types_1.BloodKetonesUnit.MG_DL}
83
- ${types_1.BloodKetonesUnit.MMOL_L}
61
+ ${BloodKetonesUnit.MG_DL}
62
+ ${BloodKetonesUnit.MMOL_L}
84
63
  ${null}
85
64
  `(`Validation checking on blood ketones unit types $validUnit`, ({ validUnit }) => {
86
65
  expect(() => Validations.checkBKLUnit(validUnit)).not.toThrowError(Errors.BloodKetoneUnitError());
@@ -95,12 +74,12 @@ describe(`Test validations functions for the recommendation props`, () => {
95
74
  });
96
75
  test.each `
97
76
  validLanguage
98
- ${types_1.Languages.da}
99
- ${types_1.Languages.en}
100
- ${types_1.Languages.de}
101
- ${types_1.Languages.es}
102
- ${types_1.Languages.it}
103
- ${types_1.Languages.fr}
77
+ ${Languages.da}
78
+ ${Languages.en}
79
+ ${Languages.de}
80
+ ${Languages.es}
81
+ ${Languages.it}
82
+ ${Languages.fr}
104
83
  `(`Validation checking on supported languages types $validLanguage`, ({ validLanguage }) => {
105
84
  expect(() => Validations.checkLanguage(validLanguage)).not.toThrowError(Errors.LanguageError());
106
85
  });
@@ -115,7 +94,7 @@ describe(`Test validations functions for the recommendation props`, () => {
115
94
  });
116
95
  it.each `
117
96
  validLatestLogbookFrom6Hours
118
- ${utils_1.generateDefaultLogbook()}
97
+ ${generateDefaultLogbook()}
119
98
  ${null}
120
99
  `(`Validation checking on the latest logbook from the latest 6 hours with a valid logbook`, ({ validLatestLogbookFrom6Hours }) => {
121
100
  expect(() => Validations.checkLatestLogbook6Hours(validLatestLogbookFrom6Hours)).not.toThrowError(Errors.LatestLogbook6HoursBGLError());
@@ -125,8 +104,8 @@ describe(`Test validations functions for the recommendation props`, () => {
125
104
  ${undefined}
126
105
  ${{}}
127
106
  ${[]}
128
- ${{ ...utils_1.generateDefaultLogbook(), blood_glucose_millimolar: 1 }}
129
- ${{ ...utils_1.generateDefaultLogbook(), blood_glucose_millimolar: 33.4 }}
107
+ ${{ ...generateDefaultLogbook(), blood_glucose_millimolar: 1 }}
108
+ ${{ ...generateDefaultLogbook(), blood_glucose_millimolar: 33.4 }}
130
109
  `(`Validation checking on the latest logbook from the latest 6 hours with an invalid logbook `, ({ invalidLatestLogbookFrom6Hours }) => {
131
110
  expect(() => Validations.checkLatestLogbook6Hours(invalidLatestLogbookFrom6Hours)).toThrowError(Errors.LatestLogbook6HoursBGLError());
132
111
  });
@@ -205,7 +184,7 @@ describe(`Test validations for the calculator parameters`, () => {
205
184
  `(`Validation checking on activity $invalidIntensity throws error`, ({ invalidIntensity }) => {
206
185
  expect(() => Validations.checkActivityIntensity(invalidIntensity)).toThrowError(Errors.ActivityIntensityError());
207
186
  });
208
- const validActivitySettings1 = utils_1.generateDefaultActivitySettings();
187
+ const validActivitySettings1 = generateDefaultActivitySettings();
209
188
  const validActivitySettings2 = {
210
189
  ...validActivitySettings1,
211
190
  hard: { fromZero: 1, fromThirty: 0.99, fromFortysix: null },
@@ -229,24 +208,24 @@ describe(`Test validations for the calculator parameters`, () => {
229
208
  hard: { fromZero: 1, fromThirty: 0.99, fromFortysix: 1.1 },
230
209
  };
231
210
  const validActivity1 = {
232
- activityDate: new Date(Date.now() - types_1.Milliseconds.Hour * 5 - types_1.Milliseconds.Minute * 9.9),
211
+ activityDate: new Date(Date.now() - Milliseconds.Hour * 5 - Milliseconds.Minute * 9.9),
233
212
  activityDuration: 60,
234
213
  activityIntensity: moderate,
235
214
  activitySettings: validActivitySettings1,
236
215
  };
237
216
  const validActivity2 = {
238
217
  ...validActivity1,
239
- activityDate: new Date(Date.now() - types_1.Milliseconds.Hour * 4.5 - types_1.Milliseconds.Minute * 9.9),
218
+ activityDate: new Date(Date.now() - Milliseconds.Hour * 4.5 - Milliseconds.Minute * 9.9),
240
219
  activityDuration: 30,
241
220
  };
242
221
  const invalidActivity1 = {
243
222
  ...validActivity1,
244
- activityDate: new Date(Date.now() - types_1.Milliseconds.Hour * 4.5 - types_1.Milliseconds.Minute * 10),
223
+ activityDate: new Date(Date.now() - Milliseconds.Hour * 4.5 - Milliseconds.Minute * 10),
245
224
  activityDuration: 30,
246
225
  };
247
226
  const invalidActivity2 = {
248
227
  ...validActivity1,
249
- activityDate: new Date(Date.now() - types_1.Milliseconds.Hour * 4.25 - types_1.Milliseconds.Minute * 10),
228
+ activityDate: new Date(Date.now() - Milliseconds.Hour * 4.25 - Milliseconds.Minute * 10),
250
229
  activityDuration: 15,
251
230
  };
252
231
  test(`Can call checkActivity with a valid activity`, () => {
@@ -399,7 +378,7 @@ describe(`Test validations for the calculator parameters`, () => {
399
378
  };
400
379
  const validBolus2 = {
401
380
  insulinDose: 50,
402
- secondsPassed: Constants_1.FOUR_HOURS_SECONDS,
381
+ secondsPassed: FOUR_HOURS_SECONDS,
403
382
  };
404
383
  const invalidBolus1 = {
405
384
  // @ts-ignore Forcefully incorrect.
@@ -410,7 +389,7 @@ describe(`Test validations for the calculator parameters`, () => {
410
389
  const invalidBolus2 = {
411
390
  // @ts-ignore Forcefully incorrect.
412
391
  insulinDose: undefined,
413
- secondsPassed: Constants_1.FOUR_HOURS_SECONDS + 1,
392
+ secondsPassed: FOUR_HOURS_SECONDS + 1,
414
393
  };
415
394
  const invalidBolus3 = {
416
395
  insulinDose: 51,