@dhis2-ui/organisation-unit-tree 10.0.0-alpha.7 → 10.0.0-alpha.8
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/organisation-unit-node/use-open-state.test.js +8 -8
- package/build/cjs/organisation-unit-node/use-org-children.test.js +103 -105
- package/build/cjs/organisation-unit-node/use-org-data/use-org-data.test.js +46 -48
- package/build/cjs/organisation-unit-tree/organisation-unit-tree.test.js +6 -6
- package/build/cjs/organisation-unit-tree/use-root-org-data/use-root-org-unit.test.js +36 -41
- package/build/es/organisation-unit-node/use-open-state.test.js +1 -1
- package/build/es/organisation-unit-node/use-org-children.test.js +91 -93
- package/build/es/organisation-unit-node/use-org-data/use-org-data.test.js +40 -42
- package/build/es/organisation-unit-tree/organisation-unit-tree.test.js +6 -6
- package/build/es/organisation-unit-tree/use-root-org-data/use-root-org-unit.test.js +28 -33
- package/package.json +10 -10
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _appRuntime = require("@dhis2/app-runtime");
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var _react = require("@testing-library/react");
|
|
5
|
+
var _react2 = _interopRequireDefault(require("react"));
|
|
6
6
|
var _useRootOrgData = require("./use-root-org-data.js");
|
|
7
7
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
8
|
describe('OrganisationUnitTree - useRootOrgData', () => {
|
|
@@ -47,14 +47,14 @@ describe('OrganisationUnitTree - useRootOrgData', () => {
|
|
|
47
47
|
let {
|
|
48
48
|
children
|
|
49
49
|
} = _ref;
|
|
50
|
-
return /*#__PURE__*/
|
|
50
|
+
return /*#__PURE__*/_react2.default.createElement(_appRuntime.CustomDataProvider, {
|
|
51
51
|
data: dataProviderData
|
|
52
52
|
}, children);
|
|
53
53
|
};
|
|
54
54
|
it('should respond with `loading: false`, `error: null` and `data: null` initially', () => {
|
|
55
55
|
const {
|
|
56
56
|
result
|
|
57
|
-
} = (0,
|
|
57
|
+
} = (0, _react.renderHook)(() => (0, _useRootOrgData.useRootOrgData)(['A0000000000']), {
|
|
58
58
|
wrapper
|
|
59
59
|
});
|
|
60
60
|
expect(result.current).toEqual(expect.objectContaining({
|
|
@@ -66,12 +66,11 @@ describe('OrganisationUnitTree - useRootOrgData', () => {
|
|
|
66
66
|
});
|
|
67
67
|
it('should provide the org unit data', async () => {
|
|
68
68
|
const {
|
|
69
|
-
result
|
|
70
|
-
|
|
71
|
-
} = (0, _reactHooks.renderHook)(() => (0, _useRootOrgData.useRootOrgData)(['A0000000000']), {
|
|
69
|
+
result
|
|
70
|
+
} = (0, _react.renderHook)(() => (0, _useRootOrgData.useRootOrgData)(['A0000000000']), {
|
|
72
71
|
wrapper
|
|
73
72
|
});
|
|
74
|
-
await
|
|
73
|
+
await (0, _react.waitFor)(() => {});
|
|
75
74
|
expect(result.current).toEqual(expect.objectContaining({
|
|
76
75
|
loading: false,
|
|
77
76
|
error: null,
|
|
@@ -89,7 +88,7 @@ describe('OrganisationUnitTree - useRootOrgData', () => {
|
|
|
89
88
|
let {
|
|
90
89
|
children
|
|
91
90
|
} = _ref2;
|
|
92
|
-
return /*#__PURE__*/
|
|
91
|
+
return /*#__PURE__*/_react2.default.createElement(_appRuntime.CustomDataProvider, {
|
|
93
92
|
data: {
|
|
94
93
|
organisationUnits: async () => {
|
|
95
94
|
throw new Error('Error message');
|
|
@@ -98,25 +97,23 @@ describe('OrganisationUnitTree - useRootOrgData', () => {
|
|
|
98
97
|
}, children);
|
|
99
98
|
};
|
|
100
99
|
const {
|
|
101
|
-
result
|
|
102
|
-
|
|
103
|
-
} = (0, _reactHooks.renderHook)(() => (0, _useRootOrgData.useRootOrgData)(['A0000000000']), {
|
|
100
|
+
result
|
|
101
|
+
} = (0, _react.renderHook)(() => (0, _useRootOrgData.useRootOrgData)(['A0000000000']), {
|
|
104
102
|
wrapper: errorWrapper
|
|
105
103
|
});
|
|
106
|
-
await
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
104
|
+
await (0, _react.waitFor)(() => {
|
|
105
|
+
expect(result.current).toEqual(expect.objectContaining({
|
|
106
|
+
loading: false,
|
|
107
|
+
error: new Error('Error message'),
|
|
108
|
+
data: null
|
|
109
|
+
}));
|
|
110
|
+
});
|
|
112
111
|
});
|
|
113
112
|
it('should send the "isUserDataViewFallback" parameter with value "undefined"', async () => {
|
|
114
|
-
|
|
115
|
-
waitForNextUpdate
|
|
116
|
-
} = (0, _reactHooks.renderHook)(() => (0, _useRootOrgData.useRootOrgData)(['A0000000000']), {
|
|
113
|
+
(0, _react.renderHook)(() => (0, _useRootOrgData.useRootOrgData)(['A0000000000']), {
|
|
117
114
|
wrapper
|
|
118
115
|
});
|
|
119
|
-
await
|
|
116
|
+
await (0, _react.waitFor)(() => {});
|
|
120
117
|
expect(dataProviderData.organisationUnits).toHaveBeenCalledWith('read', expect.objectContaining({
|
|
121
118
|
params: expect.objectContaining({
|
|
122
119
|
isUserDataViewFallback: undefined
|
|
@@ -128,12 +125,10 @@ describe('OrganisationUnitTree - useRootOrgData', () => {
|
|
|
128
125
|
const options = {
|
|
129
126
|
isUserDataViewFallback: true
|
|
130
127
|
};
|
|
131
|
-
|
|
132
|
-
waitForNextUpdate
|
|
133
|
-
} = (0, _reactHooks.renderHook)(() => (0, _useRootOrgData.useRootOrgData)(['A0000000000'], options), {
|
|
128
|
+
(0, _react.renderHook)(() => (0, _useRootOrgData.useRootOrgData)(['A0000000000'], options), {
|
|
134
129
|
wrapper
|
|
135
130
|
});
|
|
136
|
-
await
|
|
131
|
+
await (0, _react.waitFor)(() => {});
|
|
137
132
|
expect(dataProviderData.organisationUnits).toHaveBeenCalledWith('read', expect.objectContaining({
|
|
138
133
|
params: expect.objectContaining({
|
|
139
134
|
isUserDataViewFallback: true
|
|
@@ -154,27 +149,27 @@ describe('OrganisationUnitTree - useRootOrgData', () => {
|
|
|
154
149
|
let {
|
|
155
150
|
children
|
|
156
151
|
} = _ref3;
|
|
157
|
-
return /*#__PURE__*/
|
|
152
|
+
return /*#__PURE__*/_react2.default.createElement(_appRuntime.CustomDataProvider, {
|
|
158
153
|
data: dataProviderDataWithoutDisplayName
|
|
159
154
|
}, children);
|
|
160
155
|
};
|
|
161
156
|
const {
|
|
162
|
-
result
|
|
163
|
-
|
|
164
|
-
} = (0, _reactHooks.renderHook)(() => (0, _useRootOrgData.useRootOrgData)(['A0000000000']), {
|
|
157
|
+
result
|
|
158
|
+
} = (0, _react.renderHook)(() => (0, _useRootOrgData.useRootOrgData)(['A0000000000']), {
|
|
165
159
|
wrapper: wrapperWithoutDisplayName
|
|
166
160
|
});
|
|
167
|
-
await
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
161
|
+
await (0, _react.waitFor)(() => {
|
|
162
|
+
expect(result.current).toEqual(expect.objectContaining({
|
|
163
|
+
loading: false,
|
|
164
|
+
error: null,
|
|
165
|
+
data: {
|
|
166
|
+
A0000000000: {
|
|
167
|
+
id: 'A0000000000',
|
|
168
|
+
path: '/A0000000000',
|
|
169
|
+
displayName: ''
|
|
170
|
+
}
|
|
176
171
|
}
|
|
177
|
-
}
|
|
178
|
-
})
|
|
172
|
+
}));
|
|
173
|
+
});
|
|
179
174
|
});
|
|
180
175
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CustomDataProvider } from '@dhis2/app-runtime';
|
|
2
|
-
import { renderHook } from '@testing-library/react
|
|
2
|
+
import { renderHook, waitFor } from '@testing-library/react';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { useOrgChildren } from './use-org-children.js';
|
|
5
5
|
describe('OrganisationUnitTree - useOrgChildren', () => {
|
|
@@ -37,8 +37,7 @@ describe('OrganisationUnitTree - useOrgChildren', () => {
|
|
|
37
37
|
};
|
|
38
38
|
it('should respond with `loading: true`, `error: null` and `data: null` initially', async () => {
|
|
39
39
|
const {
|
|
40
|
-
result
|
|
41
|
-
waitForNextUpdate
|
|
40
|
+
result
|
|
42
41
|
} = renderHook(() => useOrgChildren({
|
|
43
42
|
node
|
|
44
43
|
}), {
|
|
@@ -54,28 +53,28 @@ describe('OrganisationUnitTree - useOrgChildren', () => {
|
|
|
54
53
|
// Prevent the following error log with
|
|
55
54
|
// "Warning: An update to TestComponent inside a test was not wrapped
|
|
56
55
|
// in act(...)."
|
|
57
|
-
await
|
|
56
|
+
await waitFor(() => {});
|
|
58
57
|
});
|
|
59
58
|
it('should provide the org unit data', async () => {
|
|
60
59
|
const {
|
|
61
|
-
result
|
|
62
|
-
waitForNextUpdate
|
|
60
|
+
result
|
|
63
61
|
} = renderHook(() => useOrgChildren({
|
|
64
62
|
node
|
|
65
63
|
}), {
|
|
66
64
|
wrapper
|
|
67
65
|
});
|
|
68
|
-
await
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
66
|
+
await waitFor(() => {
|
|
67
|
+
expect(result.current).toEqual({
|
|
68
|
+
called: true,
|
|
69
|
+
loading: false,
|
|
70
|
+
error: null,
|
|
71
|
+
data: [{
|
|
72
|
+
id: 'A0000000001',
|
|
73
|
+
path: '/A0000000000/A0000000001',
|
|
74
|
+
children: [],
|
|
75
|
+
displayName: 'Org Unit 2'
|
|
76
|
+
}]
|
|
77
|
+
});
|
|
79
78
|
});
|
|
80
79
|
});
|
|
81
80
|
it('should provide the error', async () => {
|
|
@@ -92,19 +91,19 @@ describe('OrganisationUnitTree - useOrgChildren', () => {
|
|
|
92
91
|
}, children);
|
|
93
92
|
};
|
|
94
93
|
const {
|
|
95
|
-
result
|
|
96
|
-
waitForNextUpdate
|
|
94
|
+
result
|
|
97
95
|
} = renderHook(() => useOrgChildren({
|
|
98
96
|
node
|
|
99
97
|
}), {
|
|
100
98
|
wrapper: errorWrapper
|
|
101
99
|
});
|
|
102
|
-
await
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
100
|
+
await waitFor(() => {
|
|
101
|
+
expect(result.current).toEqual({
|
|
102
|
+
called: true,
|
|
103
|
+
loading: false,
|
|
104
|
+
error: new Error('Error message'),
|
|
105
|
+
data: undefined
|
|
106
|
+
});
|
|
108
107
|
});
|
|
109
108
|
});
|
|
110
109
|
it('should call the onComplete callback', async () => {
|
|
@@ -113,22 +112,21 @@ describe('OrganisationUnitTree - useOrgChildren', () => {
|
|
|
113
112
|
onComplete,
|
|
114
113
|
node
|
|
115
114
|
};
|
|
116
|
-
|
|
117
|
-
waitForNextUpdate
|
|
118
|
-
} = renderHook(() => useOrgChildren(options), {
|
|
115
|
+
renderHook(() => useOrgChildren(options), {
|
|
119
116
|
wrapper
|
|
120
117
|
});
|
|
121
|
-
await
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
118
|
+
await waitFor(() => {
|
|
119
|
+
expect(onComplete).toHaveBeenCalledWith({
|
|
120
|
+
id: 'A0000000000',
|
|
121
|
+
path: '/A0000000000',
|
|
122
|
+
displayName: 'Org Unit 1',
|
|
123
|
+
children: [{
|
|
124
|
+
id: 'A0000000001',
|
|
125
|
+
path: '/A0000000000/A0000000001',
|
|
126
|
+
children: [],
|
|
127
|
+
displayName: 'Org Unit 2'
|
|
128
|
+
}]
|
|
129
|
+
});
|
|
132
130
|
});
|
|
133
131
|
});
|
|
134
132
|
it("should sort the node's children alphabetically by default", async () => {
|
|
@@ -164,8 +162,7 @@ describe('OrganisationUnitTree - useOrgChildren', () => {
|
|
|
164
162
|
}, children);
|
|
165
163
|
};
|
|
166
164
|
const {
|
|
167
|
-
result
|
|
168
|
-
waitForNextUpdate
|
|
165
|
+
result
|
|
169
166
|
} = renderHook(() => useOrgChildren({
|
|
170
167
|
node: {
|
|
171
168
|
...node,
|
|
@@ -174,22 +171,23 @@ describe('OrganisationUnitTree - useOrgChildren', () => {
|
|
|
174
171
|
}), {
|
|
175
172
|
wrapper: wrapperWithUnsortedChildren
|
|
176
173
|
});
|
|
177
|
-
await
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
174
|
+
await waitFor(() => {
|
|
175
|
+
expect(result.current).toEqual({
|
|
176
|
+
called: true,
|
|
177
|
+
loading: false,
|
|
178
|
+
error: null,
|
|
179
|
+
data: [{
|
|
180
|
+
id: 'A0000000001',
|
|
181
|
+
path: '/A0000000000/A0000000001',
|
|
182
|
+
children: [],
|
|
183
|
+
displayName: 'Org Unit 2'
|
|
184
|
+
}, {
|
|
185
|
+
id: 'A0000000002',
|
|
186
|
+
path: '/A0000000000/A0000000002',
|
|
187
|
+
children: [],
|
|
188
|
+
displayName: 'Org Unit 3'
|
|
189
|
+
}]
|
|
190
|
+
});
|
|
193
191
|
});
|
|
194
192
|
});
|
|
195
193
|
it(`should not sort the node's children alphabetically when "suppressAlphabeticalSorting" is true`, async () => {
|
|
@@ -232,27 +230,27 @@ describe('OrganisationUnitTree - useOrgChildren', () => {
|
|
|
232
230
|
suppressAlphabeticalSorting: true
|
|
233
231
|
};
|
|
234
232
|
const {
|
|
235
|
-
result
|
|
236
|
-
waitForNextUpdate
|
|
233
|
+
result
|
|
237
234
|
} = renderHook(() => useOrgChildren(options), {
|
|
238
235
|
wrapper: wrapperWithUnsortedChildren
|
|
239
236
|
});
|
|
240
|
-
await
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
237
|
+
await waitFor(() => {
|
|
238
|
+
expect(result.current).toEqual({
|
|
239
|
+
called: true,
|
|
240
|
+
loading: false,
|
|
241
|
+
error: null,
|
|
242
|
+
data: [{
|
|
243
|
+
id: 'A0000000002',
|
|
244
|
+
path: '/A0000000000/A0000000002',
|
|
245
|
+
children: [],
|
|
246
|
+
displayName: 'Org Unit 3'
|
|
247
|
+
}, {
|
|
248
|
+
id: 'A0000000001',
|
|
249
|
+
path: '/A0000000000/A0000000001',
|
|
250
|
+
children: [],
|
|
251
|
+
displayName: 'Org Unit 2'
|
|
252
|
+
}]
|
|
253
|
+
});
|
|
256
254
|
});
|
|
257
255
|
});
|
|
258
256
|
it(`should not sort the node's children alphabetically when "suppressAlphabeticalSorting" is true`, async () => {
|
|
@@ -295,27 +293,27 @@ describe('OrganisationUnitTree - useOrgChildren', () => {
|
|
|
295
293
|
suppressAlphabeticalSorting: true
|
|
296
294
|
};
|
|
297
295
|
const {
|
|
298
|
-
result
|
|
299
|
-
waitForNextUpdate
|
|
296
|
+
result
|
|
300
297
|
} = renderHook(() => useOrgChildren(options), {
|
|
301
298
|
wrapper: wrapperWithUnsortedChildren
|
|
302
299
|
});
|
|
303
|
-
await
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
300
|
+
await waitFor(() => {
|
|
301
|
+
expect(result.current).toEqual({
|
|
302
|
+
called: true,
|
|
303
|
+
loading: false,
|
|
304
|
+
error: null,
|
|
305
|
+
data: [{
|
|
306
|
+
id: 'A0000000002',
|
|
307
|
+
path: '/A0000000000/A0000000002',
|
|
308
|
+
children: [],
|
|
309
|
+
displayName: 'Org Unit 3'
|
|
310
|
+
}, {
|
|
311
|
+
id: 'A0000000001',
|
|
312
|
+
path: '/A0000000000/A0000000001',
|
|
313
|
+
children: [],
|
|
314
|
+
displayName: 'Org Unit 2'
|
|
315
|
+
}]
|
|
316
|
+
});
|
|
319
317
|
});
|
|
320
318
|
});
|
|
321
319
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CustomDataProvider } from '@dhis2/app-runtime';
|
|
2
|
-
import { renderHook } from '@testing-library/react
|
|
2
|
+
import { renderHook, waitFor } from '@testing-library/react';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { useOrgData } from './use-org-data.js';
|
|
5
5
|
describe('OrganisationUnitTree - useOrgData', () => {
|
|
@@ -59,22 +59,22 @@ describe('OrganisationUnitTree - useOrgData', () => {
|
|
|
59
59
|
});
|
|
60
60
|
it('should provide the org unit data', async () => {
|
|
61
61
|
const {
|
|
62
|
-
result
|
|
63
|
-
waitForNextUpdate
|
|
62
|
+
result
|
|
64
63
|
} = renderHook(() => useOrgData('A0000000000', {
|
|
65
64
|
displayName: 'Display name'
|
|
66
65
|
}), {
|
|
67
66
|
wrapper
|
|
68
67
|
});
|
|
69
|
-
await
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
await waitFor(() => {
|
|
69
|
+
expect(result.current).toEqual({
|
|
70
|
+
loading: false,
|
|
71
|
+
error: null,
|
|
72
|
+
data: {
|
|
73
|
+
id: 'A0000000000',
|
|
74
|
+
path: '/A0000000000',
|
|
75
|
+
displayName: 'Org Unit 1'
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
78
|
});
|
|
79
79
|
});
|
|
80
80
|
it('should provide the error', async () => {
|
|
@@ -91,56 +91,54 @@ describe('OrganisationUnitTree - useOrgData', () => {
|
|
|
91
91
|
}, children);
|
|
92
92
|
};
|
|
93
93
|
const {
|
|
94
|
-
result
|
|
95
|
-
waitForNextUpdate
|
|
94
|
+
result
|
|
96
95
|
} = renderHook(() => useOrgData('A0000000000', {
|
|
97
96
|
displayName: 'Display name'
|
|
98
97
|
}), {
|
|
99
98
|
wrapper: errorWrapper
|
|
100
99
|
});
|
|
101
|
-
await
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
await waitFor(() => {
|
|
101
|
+
expect(result.current).toEqual({
|
|
102
|
+
loading: false,
|
|
103
|
+
error: new Error('Error message'),
|
|
104
|
+
data: {
|
|
105
|
+
displayName: 'Display name',
|
|
106
|
+
id: 'A0000000000'
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
109
|
});
|
|
110
110
|
});
|
|
111
111
|
it('should send the "isUserDataViewFallback" parameter with value "undefined"', async () => {
|
|
112
112
|
const options = {
|
|
113
113
|
displayName: 'Display name'
|
|
114
114
|
};
|
|
115
|
-
|
|
116
|
-
waitForNextUpdate
|
|
117
|
-
} = renderHook(() => useOrgData('A0000000000', options), {
|
|
115
|
+
renderHook(() => useOrgData('A0000000000', options), {
|
|
118
116
|
wrapper
|
|
119
117
|
});
|
|
120
|
-
await
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
118
|
+
await waitFor(() => {
|
|
119
|
+
expect(dataProviderData.organisationUnits).toHaveBeenCalledWith('read', expect.objectContaining({
|
|
120
|
+
params: expect.objectContaining({
|
|
121
|
+
isUserDataViewFallback: undefined
|
|
122
|
+
})
|
|
123
|
+
}), expect.objectContaining({}) // contains the `signal`
|
|
124
|
+
);
|
|
125
|
+
});
|
|
127
126
|
});
|
|
128
127
|
it('should send the "isUserDataViewFallback" parameter with value "true"', async () => {
|
|
129
128
|
const options = {
|
|
130
129
|
isUserDataViewFallback: true,
|
|
131
130
|
displayName: 'Display name'
|
|
132
131
|
};
|
|
133
|
-
|
|
134
|
-
waitForNextUpdate
|
|
135
|
-
} = renderHook(() => useOrgData('A0000000000', options), {
|
|
132
|
+
renderHook(() => useOrgData('A0000000000', options), {
|
|
136
133
|
wrapper
|
|
137
134
|
});
|
|
138
|
-
await
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
135
|
+
await waitFor(() => {
|
|
136
|
+
expect(dataProviderData.organisationUnits).toHaveBeenCalledWith('read', expect.objectContaining({
|
|
137
|
+
params: expect.objectContaining({
|
|
138
|
+
isUserDataViewFallback: true
|
|
139
|
+
})
|
|
140
|
+
}), expect.objectContaining({}) // contains the `signal`
|
|
141
|
+
);
|
|
142
|
+
});
|
|
145
143
|
});
|
|
146
144
|
});
|
|
@@ -15,7 +15,7 @@ describe('OrganisationUnitTree', () => {
|
|
|
15
15
|
describe('Controlled expanded props', () => {
|
|
16
16
|
describe('Missing props', () => {
|
|
17
17
|
it('should throw a prop-types error when "handleCollapse" is missing', () => {
|
|
18
|
-
shallow(
|
|
18
|
+
shallow(/*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
19
19
|
data: {}
|
|
20
20
|
}, /*#__PURE__*/React.createElement(OrganisationUnitTree, {
|
|
21
21
|
roots: "/A001",
|
|
@@ -24,10 +24,10 @@ describe('OrganisationUnitTree', () => {
|
|
|
24
24
|
handleExpand: () => {}
|
|
25
25
|
})));
|
|
26
26
|
expect(errorMock).toHaveBeenCalledTimes(1);
|
|
27
|
-
expect(errorMock.mock.calls[0][
|
|
27
|
+
expect(errorMock.mock.calls[0][2]).toMatch(/Invalid prop `handleCollapse` supplied to `OrganisationUnitTree`/, {});
|
|
28
28
|
});
|
|
29
29
|
it('should throw a prop-types error when "handleExpand" is missing', () => {
|
|
30
|
-
shallow(
|
|
30
|
+
shallow(/*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
31
31
|
data: {}
|
|
32
32
|
}, /*#__PURE__*/React.createElement(OrganisationUnitTree, {
|
|
33
33
|
roots: "/A001",
|
|
@@ -36,10 +36,10 @@ describe('OrganisationUnitTree', () => {
|
|
|
36
36
|
handleCollapse: () => {}
|
|
37
37
|
})));
|
|
38
38
|
expect(errorMock).toHaveBeenCalledTimes(1);
|
|
39
|
-
expect(errorMock.mock.calls[0][
|
|
39
|
+
expect(errorMock.mock.calls[0][2]).toMatch(/Invalid prop `handleExpand` supplied to `OrganisationUnitTree`/);
|
|
40
40
|
});
|
|
41
41
|
it('should throw a prop-types error when "expanded" is missing', () => {
|
|
42
|
-
shallow(
|
|
42
|
+
shallow(/*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
43
43
|
data: {}
|
|
44
44
|
}, /*#__PURE__*/React.createElement(OrganisationUnitTree, {
|
|
45
45
|
roots: "/A001",
|
|
@@ -48,7 +48,7 @@ describe('OrganisationUnitTree', () => {
|
|
|
48
48
|
handleExpand: () => {}
|
|
49
49
|
})));
|
|
50
50
|
expect(errorMock).toHaveBeenCalledTimes(1);
|
|
51
|
-
expect(errorMock.mock.calls[0][
|
|
51
|
+
expect(errorMock.mock.calls[0][2]).toMatch('Invalid prop `expanded` supplied to `OrganisationUnitTree`, this prop is conditionally required but has value `undefined`. The condition that made this prop required is: `props => !!props.handleExpand || !!props.handleCollapse`.');
|
|
52
52
|
});
|
|
53
53
|
});
|
|
54
54
|
});
|