@hedia/recommendation-screen 2.1.31 → 2.1.32-alpha.0
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.
- package/coverage/clover.xml +722 -0
- package/coverage/coverage-final.json +28 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +79 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +201 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +170 -0
- package/coverage/lcov-report/src/RecommendationScreen.tsx.html +2594 -0
- package/coverage/lcov-report/src/__tests__/index.html +111 -0
- package/coverage/lcov-report/src/__tests__/utils.tsx.html +533 -0
- package/coverage/lcov-report/src/components/Header.tsx.html +356 -0
- package/coverage/lcov-report/src/components/InfoBars.tsx.html +518 -0
- package/coverage/lcov-report/src/components/InvisibleNumberInput.tsx.html +587 -0
- package/coverage/lcov-report/src/components/LimitationMessage.tsx.html +209 -0
- package/coverage/lcov-report/src/components/LineSeparator.tsx.html +161 -0
- package/coverage/lcov-report/src/components/RecentInsulin.tsx.html +410 -0
- package/coverage/lcov-report/src/components/RecommendationModal.tsx.html +923 -0
- package/coverage/lcov-report/src/components/RecommendedCarbs.tsx.html +1061 -0
- package/coverage/lcov-report/src/components/RecommendedInsulin.tsx.html +779 -0
- package/coverage/lcov-report/src/components/Remeasure.tsx.html +551 -0
- package/coverage/lcov-report/src/components/TransferToLogbook.tsx.html +443 -0
- package/coverage/lcov-report/src/components/TwoOptionModal.tsx.html +665 -0
- package/coverage/lcov-report/src/components/activity/Activity.tsx.html +371 -0
- package/coverage/lcov-report/src/components/activity/ActivityIcon.tsx.html +281 -0
- package/coverage/lcov-report/src/components/activity/ActivityIntensity.tsx.html +281 -0
- package/coverage/lcov-report/src/components/activity/index.html +141 -0
- package/coverage/lcov-report/src/components/index.html +276 -0
- package/coverage/lcov-report/src/components/mood/Emotion.tsx.html +353 -0
- package/coverage/lcov-report/src/components/mood/MoodIcon.tsx.html +335 -0
- package/coverage/lcov-report/src/components/mood/index.html +126 -0
- package/coverage/lcov-report/src/index.html +111 -0
- package/coverage/lcov-report/src/locale/i18nUtils.ts.html +206 -0
- package/coverage/lcov-report/src/locale/index.html +111 -0
- package/coverage/lcov-report/src/utils/AttentionMessages.tsx.html +554 -0
- package/coverage/lcov-report/src/utils/Constants.ts.html +248 -0
- package/coverage/lcov-report/src/utils/RecommendationError.tsx.html +620 -0
- package/coverage/lcov-report/src/utils/RecommendationUtils.ts.html +764 -0
- package/coverage/lcov-report/src/utils/Translations.ts.html +131 -0
- package/coverage/lcov-report/src/utils/Utils.ts.html +545 -0
- package/coverage/lcov-report/src/utils/Validations.ts.html +1544 -0
- package/coverage/lcov-report/src/utils/index.html +201 -0
- package/coverage/lcov.info +1621 -0
- package/package.json +1 -1
- package/src/RecommendationScreen.d.ts +14 -1
- package/src/RecommendationScreen.js +14 -1
- package/src/__tests__/RecommendationScreen.test.js +20 -0
package/package.json
CHANGED
|
@@ -143,10 +143,15 @@ export default class RecommendationScreen extends React.Component<IRecommendatio
|
|
|
143
143
|
*/
|
|
144
144
|
private scrollView?;
|
|
145
145
|
/**
|
|
146
|
-
* A reference to the eventSubscription that'll be returned by addEventListener().
|
|
146
|
+
* A reference to the eventSubscription that'll be returned by AppState.addEventListener().
|
|
147
147
|
* It'll allow us to later remove the subscription.
|
|
148
148
|
*/
|
|
149
149
|
private appStateSubscription?;
|
|
150
|
+
/**
|
|
151
|
+
* A reference to the eventSubscription that'll be returned by BackHandler.addEventListener().
|
|
152
|
+
* It'll allow us to later remove the subscription.
|
|
153
|
+
*/
|
|
154
|
+
private backHandlerSubscription?;
|
|
150
155
|
/**
|
|
151
156
|
* Steps:
|
|
152
157
|
* 1. Call the super() method with the props.
|
|
@@ -226,6 +231,14 @@ export default class RecommendationScreen extends React.Component<IRecommendatio
|
|
|
226
231
|
* - Call the exitCallback prop callback function.
|
|
227
232
|
*/
|
|
228
233
|
onExit: () => void;
|
|
234
|
+
/**
|
|
235
|
+
* Callback to be executed by the back handler listener.
|
|
236
|
+
*
|
|
237
|
+
* Steps:
|
|
238
|
+
* 1. Call the onExist method
|
|
239
|
+
* 2. Return true so that the default behaviour is overwritten.
|
|
240
|
+
*/
|
|
241
|
+
onBackHandlerPress: () => boolean;
|
|
229
242
|
/**
|
|
230
243
|
* Hide the modal that shows attention messages.
|
|
231
244
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { AppState, LogBox, ScrollView, StyleSheet, View } from "react-native";
|
|
2
|
+
import { AppState, BackHandler, LogBox, ScrollView, StyleSheet, View, } from "react-native";
|
|
3
3
|
import { BACKGROUND_COLOUR_PURPLE, BORDER_COLOUR_GREY, BORDER_COLOUR_TEAL } from "./utils/Constants";
|
|
4
4
|
import Header from "./components/Header";
|
|
5
5
|
import InfoBars, { infoStyles } from "./components/InfoBars";
|
|
@@ -125,6 +125,17 @@ export default class RecommendationScreen extends React.Component {
|
|
|
125
125
|
this.props.exitCallback();
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
|
+
/**
|
|
129
|
+
* Callback to be executed by the back handler listener.
|
|
130
|
+
*
|
|
131
|
+
* Steps:
|
|
132
|
+
* 1. Call the onExist method
|
|
133
|
+
* 2. Return true so that the default behaviour is overwritten.
|
|
134
|
+
*/
|
|
135
|
+
this.onBackHandlerPress = () => {
|
|
136
|
+
this.onExit();
|
|
137
|
+
return true;
|
|
138
|
+
};
|
|
128
139
|
/**
|
|
129
140
|
* Hide the modal that shows attention messages.
|
|
130
141
|
*
|
|
@@ -391,6 +402,7 @@ export default class RecommendationScreen extends React.Component {
|
|
|
391
402
|
componentDidMount() {
|
|
392
403
|
if (!this.hasError) {
|
|
393
404
|
this.appStateSubscription = AppState.addEventListener(`change`, this.handleAppStateChange);
|
|
405
|
+
this.backHandlerSubscription = BackHandler.addEventListener(`hardwareBackPress`, this.onBackHandlerPress);
|
|
394
406
|
}
|
|
395
407
|
}
|
|
396
408
|
/**
|
|
@@ -408,6 +420,7 @@ export default class RecommendationScreen extends React.Component {
|
|
|
408
420
|
clearTimeout(this.timer);
|
|
409
421
|
}
|
|
410
422
|
this.appStateSubscription?.remove();
|
|
423
|
+
this.backHandlerSubscription?.remove();
|
|
411
424
|
}
|
|
412
425
|
/** Render a JSX element for displaying the insulin recommendation screen. */
|
|
413
426
|
render() {
|
|
@@ -942,4 +942,24 @@ describe(`Recommendation Screen - TwoOptionModal related tests`, () => {
|
|
|
942
942
|
expect(props.showBolusBar).not.toBeCalled();
|
|
943
943
|
expectTextNotExists(rendered, `No, return to dashboard`);
|
|
944
944
|
});
|
|
945
|
+
test(`BackHandler no recommendation visible - triggers exit modal`, () => {
|
|
946
|
+
const props = getRecommendationProps();
|
|
947
|
+
let backHandler;
|
|
948
|
+
const getBackHandlerListener = jest.fn((eventName, handler) => {
|
|
949
|
+
if (eventName === `hardwareBackPress`) {
|
|
950
|
+
backHandler = handler;
|
|
951
|
+
}
|
|
952
|
+
});
|
|
953
|
+
jest.resetModules();
|
|
954
|
+
jest.doMock(`react-native/Libraries/Utilities/BackHandler`, () => ({
|
|
955
|
+
addEventListener: getBackHandlerListener,
|
|
956
|
+
removeEventListener: jest.fn(),
|
|
957
|
+
}));
|
|
958
|
+
const rendered = render(<RecommendationScreen {...props}/>);
|
|
959
|
+
//@ts-ignore
|
|
960
|
+
backHandler?.();
|
|
961
|
+
rendered.rerender(<RecommendationScreen {...props}/>);
|
|
962
|
+
expectTextExists(rendered, `Save data before closing?`);
|
|
963
|
+
expect(props.showBolusBar).toBeCalled();
|
|
964
|
+
});
|
|
945
965
|
});
|