@wordpress/core-data 4.4.5 → 4.7.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/CHANGELOG.md +11 -1
- package/README.md +175 -85
- package/build/entities.js +3 -0
- package/build/entities.js.map +1 -1
- package/build/hooks/constants.js +0 -2
- package/build/hooks/constants.js.map +1 -1
- package/build/hooks/index.js +38 -0
- package/build/hooks/index.js.map +1 -0
- package/build/hooks/use-entity-record.js +22 -8
- package/build/hooks/use-entity-record.js.map +1 -1
- package/build/hooks/use-entity-records.js +21 -8
- package/build/hooks/use-entity-records.js.map +1 -1
- package/build/index.js +17 -21
- package/build/index.js.map +1 -1
- package/build/selectors.js +163 -163
- package/build/selectors.js.map +1 -1
- package/build-module/entities.js +3 -0
- package/build-module/entities.js.map +1 -1
- package/build-module/hooks/constants.js +0 -1
- package/build-module/hooks/constants.js.map +1 -1
- package/build-module/hooks/index.js +3 -0
- package/build-module/hooks/index.js.map +1 -0
- package/build-module/hooks/use-entity-record.js +18 -7
- package/build-module/hooks/use-entity-record.js.map +1 -1
- package/build-module/hooks/use-entity-records.js +17 -7
- package/build-module/hooks/use-entity-records.js.map +1 -1
- package/build-module/index.js +2 -3
- package/build-module/index.js.map +1 -1
- package/build-module/selectors.js +164 -163
- package/build-module/selectors.js.map +1 -1
- package/package.json +11 -11
- package/src/entities.ts +1 -0
- package/src/hooks/constants.ts +1 -2
- package/src/hooks/index.ts +8 -0
- package/src/hooks/test/use-entity-record.js +1 -0
- package/src/hooks/test/use-entity-records.js +1 -0
- package/src/hooks/test/use-query-select.js +1 -0
- package/src/hooks/use-entity-record.ts +32 -9
- package/src/hooks/use-entity-records.ts +28 -30
- package/src/index.js +2 -3
- package/src/selectors.ts +406 -216
- package/src/test/actions.js +16 -0
- package/src/test/entities.js +5 -0
- package/src/test/resolvers.js +11 -0
package/src/test/actions.js
CHANGED
|
@@ -58,6 +58,11 @@ describe( 'deleteEntityRecord', () => {
|
|
|
58
58
|
jest.useFakeTimers();
|
|
59
59
|
} );
|
|
60
60
|
|
|
61
|
+
afterEach( () => {
|
|
62
|
+
jest.runOnlyPendingTimers();
|
|
63
|
+
jest.useRealTimers();
|
|
64
|
+
} );
|
|
65
|
+
|
|
61
66
|
it( 'triggers a DELETE request for an existing record', async () => {
|
|
62
67
|
const deletedRecord = { title: 'new post', id: 10 };
|
|
63
68
|
const configs = [
|
|
@@ -180,6 +185,11 @@ describe( 'saveEditedEntityRecord', () => {
|
|
|
180
185
|
jest.useFakeTimers();
|
|
181
186
|
} );
|
|
182
187
|
|
|
188
|
+
afterEach( () => {
|
|
189
|
+
jest.runOnlyPendingTimers();
|
|
190
|
+
jest.useRealTimers();
|
|
191
|
+
} );
|
|
192
|
+
|
|
183
193
|
it( 'Uses "id" as a key when no entity key is provided', async () => {
|
|
184
194
|
const item = { id: 1, menu: 0 };
|
|
185
195
|
const configs = [
|
|
@@ -264,6 +274,7 @@ describe( 'saveEditedEntityRecord', () => {
|
|
|
264
274
|
|
|
265
275
|
describe( 'saveEntityRecord', () => {
|
|
266
276
|
let dispatch;
|
|
277
|
+
|
|
267
278
|
beforeEach( async () => {
|
|
268
279
|
apiFetch.mockReset();
|
|
269
280
|
jest.useFakeTimers();
|
|
@@ -274,6 +285,11 @@ describe( 'saveEntityRecord', () => {
|
|
|
274
285
|
} );
|
|
275
286
|
} );
|
|
276
287
|
|
|
288
|
+
afterEach( () => {
|
|
289
|
+
jest.runOnlyPendingTimers();
|
|
290
|
+
jest.useRealTimers();
|
|
291
|
+
} );
|
|
292
|
+
|
|
277
293
|
it( 'triggers a POST request for a new record', async () => {
|
|
278
294
|
const post = { title: 'new post' };
|
|
279
295
|
const configs = [
|
package/src/test/entities.js
CHANGED
|
@@ -55,6 +55,11 @@ describe( 'getKindEntities', () => {
|
|
|
55
55
|
jest.useFakeTimers();
|
|
56
56
|
} );
|
|
57
57
|
|
|
58
|
+
afterEach( () => {
|
|
59
|
+
jest.runOnlyPendingTimers();
|
|
60
|
+
jest.useRealTimers();
|
|
61
|
+
} );
|
|
62
|
+
|
|
58
63
|
it( 'shouldn’t do anything if the entities have already been resolved', async () => {
|
|
59
64
|
const dispatch = jest.fn();
|
|
60
65
|
const select = {
|
package/src/test/resolvers.js
CHANGED
|
@@ -27,11 +27,17 @@ describe( 'getEntityRecord', () => {
|
|
|
27
27
|
baseURLParams: { context: 'edit' },
|
|
28
28
|
},
|
|
29
29
|
];
|
|
30
|
+
|
|
30
31
|
beforeEach( async () => {
|
|
31
32
|
triggerFetch.mockReset();
|
|
32
33
|
jest.useFakeTimers();
|
|
33
34
|
} );
|
|
34
35
|
|
|
36
|
+
afterEach( () => {
|
|
37
|
+
jest.runOnlyPendingTimers();
|
|
38
|
+
jest.useRealTimers();
|
|
39
|
+
} );
|
|
40
|
+
|
|
35
41
|
it( 'yields with requested post type', async () => {
|
|
36
42
|
const dispatch = Object.assign( jest.fn(), {
|
|
37
43
|
receiveEntityRecords: jest.fn(),
|
|
@@ -149,6 +155,11 @@ describe( 'getEntityRecords', () => {
|
|
|
149
155
|
jest.useFakeTimers();
|
|
150
156
|
} );
|
|
151
157
|
|
|
158
|
+
afterEach( () => {
|
|
159
|
+
jest.runOnlyPendingTimers();
|
|
160
|
+
jest.useRealTimers();
|
|
161
|
+
} );
|
|
162
|
+
|
|
152
163
|
it( 'dispatches the requested post type', async () => {
|
|
153
164
|
const dispatch = Object.assign( jest.fn(), {
|
|
154
165
|
receiveEntityRecords: jest.fn(),
|