@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.
@@ -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) setSelectedState(newSelectedState);
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)) countsObj[id] = 0;
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) setTimeout(onStarted, 100); // in 200ms, call 'onCompleted' callback
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) setTimeout(onStarted, 100); // in 200ms, call 'onError'
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
 
@@ -1,4 +1,3 @@
1
- /* eslint-disable react/display-name, react/prop-types */
2
1
  import { AlertsProvider } from '@dhis2/app-service-alerts';
3
2
  import { renderHook, act } from '@testing-library/react-hooks';
4
3
  import React from 'react';
@@ -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) setSelectedState(newSelectedState);
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,7 +3,10 @@ export const RenderCounter = ({
3
3
  id,
4
4
  countsObj
5
5
  }) => {
6
- if (!(id in countsObj)) countsObj[id] = 0;
6
+ if (!(id in countsObj)) {
7
+ countsObj[id] = 0;
8
+ }
9
+
7
10
  return /*#__PURE__*/React.createElement("div", {
8
11
  "data-testid": id
9
12
  }, ++countsObj[id]);
@@ -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) setTimeout(onStarted, 100); // in 200ms, call 'onCompleted' callback
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) setTimeout(onStarted, 100); // in 200ms, call 'onError'
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.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.4.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"