@dhis2/app-service-offline 3.4.3 → 3.5.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/build/cjs/lib/__tests__/use-cacheable-section.test.js +0 -1
- package/build/cjs/lib/global-state-service.js +3 -1
- package/build/cjs/utils/render-counter.js +4 -1
- package/build/cjs/utils/test-mocks.js +12 -3
- package/build/es/lib/__tests__/use-cacheable-section.test.js +0 -1
- package/build/es/lib/global-state-service.js +3 -1
- package/build/es/utils/render-counter.js +4 -1
- package/build/es/utils/test-mocks.js +12 -3
- package/package.json +2 -2
|
@@ -14,7 +14,6 @@ var _offlineProvider = require("../offline-provider");
|
|
|
14
14
|
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
16
|
|
|
17
|
-
/* eslint-disable react/display-name, react/prop-types */
|
|
18
17
|
// Suppress 'act' warning for these tests
|
|
19
18
|
const originalError = console.error;
|
|
20
19
|
beforeEach(() => {
|
|
@@ -72,7 +72,9 @@ const useGlobalState = (selector = identity) => {
|
|
|
72
72
|
const newSelectedState = selector(state); // Second condition handles case where a selected object gets
|
|
73
73
|
// deleted, but state does not update
|
|
74
74
|
|
|
75
|
-
if (!(0, _isEqual.default)(selectedState, newSelectedState) || selectedState === undefined)
|
|
75
|
+
if (!(0, _isEqual.default)(selectedState, newSelectedState) || selectedState === undefined) {
|
|
76
|
+
setSelectedState(newSelectedState);
|
|
77
|
+
}
|
|
76
78
|
};
|
|
77
79
|
|
|
78
80
|
store.subscribe(callback); // Make sure to update state when selector changes
|
|
@@ -13,7 +13,10 @@ const RenderCounter = ({
|
|
|
13
13
|
id,
|
|
14
14
|
countsObj
|
|
15
15
|
}) => {
|
|
16
|
-
if (!(id in countsObj))
|
|
16
|
+
if (!(id in countsObj)) {
|
|
17
|
+
countsObj[id] = 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
17
20
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
18
21
|
"data-testid": id
|
|
19
22
|
}, ++countsObj[id]);
|
|
@@ -9,9 +9,15 @@ const successfulRecordingMock = jest.fn().mockImplementation(async ({
|
|
|
9
9
|
onCompleted
|
|
10
10
|
} = {}) => {
|
|
11
11
|
// in 100ms, call 'onStarted' callback (allows 'pending' state)
|
|
12
|
-
if (onStarted)
|
|
12
|
+
if (onStarted) {
|
|
13
|
+
setTimeout(onStarted, 100);
|
|
14
|
+
} // in 200ms, call 'onCompleted' callback
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
if (onCompleted) {
|
|
18
|
+
setTimeout(onCompleted, 200);
|
|
19
|
+
} // resolve
|
|
13
20
|
|
|
14
|
-
if (onCompleted) setTimeout(onCompleted, 200); // resolve
|
|
15
21
|
|
|
16
22
|
return Promise.resolve();
|
|
17
23
|
});
|
|
@@ -21,7 +27,10 @@ const errorRecordingMock = jest.fn().mockImplementation(({
|
|
|
21
27
|
onError
|
|
22
28
|
} = {}) => {
|
|
23
29
|
// in 100ms, call 'onStarted' callback (allows 'pending' state)
|
|
24
|
-
if (onStarted)
|
|
30
|
+
if (onStarted) {
|
|
31
|
+
setTimeout(onStarted, 100);
|
|
32
|
+
} // in 200ms, call 'onError'
|
|
33
|
+
|
|
25
34
|
|
|
26
35
|
setTimeout(() => onError(new Error('test err')), 200); // resolve to signal successful initiation
|
|
27
36
|
|
|
@@ -50,7 +50,9 @@ export const useGlobalState = (selector = identity) => {
|
|
|
50
50
|
const newSelectedState = selector(state); // Second condition handles case where a selected object gets
|
|
51
51
|
// deleted, but state does not update
|
|
52
52
|
|
|
53
|
-
if (!isEqual(selectedState, newSelectedState) || selectedState === undefined)
|
|
53
|
+
if (!isEqual(selectedState, newSelectedState) || selectedState === undefined) {
|
|
54
|
+
setSelectedState(newSelectedState);
|
|
55
|
+
}
|
|
54
56
|
};
|
|
55
57
|
|
|
56
58
|
store.subscribe(callback); // Make sure to update state when selector changes
|
|
@@ -3,9 +3,15 @@ export const successfulRecordingMock = jest.fn().mockImplementation(async ({
|
|
|
3
3
|
onCompleted
|
|
4
4
|
} = {}) => {
|
|
5
5
|
// in 100ms, call 'onStarted' callback (allows 'pending' state)
|
|
6
|
-
if (onStarted)
|
|
6
|
+
if (onStarted) {
|
|
7
|
+
setTimeout(onStarted, 100);
|
|
8
|
+
} // in 200ms, call 'onCompleted' callback
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
if (onCompleted) {
|
|
12
|
+
setTimeout(onCompleted, 200);
|
|
13
|
+
} // resolve
|
|
7
14
|
|
|
8
|
-
if (onCompleted) setTimeout(onCompleted, 200); // resolve
|
|
9
15
|
|
|
10
16
|
return Promise.resolve();
|
|
11
17
|
});
|
|
@@ -14,7 +20,10 @@ export const errorRecordingMock = jest.fn().mockImplementation(({
|
|
|
14
20
|
onError
|
|
15
21
|
} = {}) => {
|
|
16
22
|
// in 100ms, call 'onStarted' callback (allows 'pending' state)
|
|
17
|
-
if (onStarted)
|
|
23
|
+
if (onStarted) {
|
|
24
|
+
setTimeout(onStarted, 100);
|
|
25
|
+
} // in 200ms, call 'onError'
|
|
26
|
+
|
|
18
27
|
|
|
19
28
|
setTimeout(() => onError(new Error('test err')), 200); // resolve to signal successful initiation
|
|
20
29
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2/app-service-offline",
|
|
3
3
|
"description": "A runtime service for online/offline detection and offline caching",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.5.0",
|
|
5
5
|
"main": "./build/cjs/index.js",
|
|
6
6
|
"module": "./build/es/index.js",
|
|
7
7
|
"types": "build/types/index.d.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"coverage": "yarn test --coverage"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@dhis2/app-service-alerts": "3.
|
|
36
|
+
"@dhis2/app-service-alerts": "3.5.0",
|
|
37
37
|
"prop-types": "^15.7.2",
|
|
38
38
|
"react": "^16.8.6",
|
|
39
39
|
"react-dom": "^16.8.6"
|