Skip to content

Commit c3537d3

Browse files
committed
fix unit test
1 parent 9c148c1 commit c3537d3

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

‎packages/core-data/src/test/resolvers.js‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ describe( 'getEntityRecords', () => {
347347
];
348348
const registry = { batch: ( callback ) => callback() };
349349
const resolveSelect = { getEntitiesConfig: jest.fn( () => ENTITIES ) };
350+
const select = { getPersistedIdMap: jest.fn( () => ( {} ) ) };
350351

351352
beforeEach( async () => {
352353
triggerFetch.mockReset();
@@ -365,7 +366,7 @@ describe( 'getEntityRecords', () => {
365366
await getEntityRecords(
366367
'root',
367368
'postType'
368-
)( { dispatch, registry, resolveSelect } );
369+
)( { dispatch, registry, resolveSelect, select } );
369370

370371
// Fetch request should have been issued.
371372
expect( triggerFetch ).toHaveBeenCalledWith( {
@@ -397,7 +398,7 @@ describe( 'getEntityRecords', () => {
397398
await getEntityRecords(
398399
'root',
399400
'postType'
400-
)( { dispatch, registry, resolveSelect } );
401+
)( { dispatch, registry, resolveSelect, select } );
401402

402403
// Fetch request should have been issued.
403404
expect( triggerFetch ).toHaveBeenCalledWith( {
@@ -431,7 +432,7 @@ describe( 'getEntityRecords', () => {
431432
await getEntityRecords(
432433
'root',
433434
'postType'
434-
)( { dispatch, registry, resolveSelect } );
435+
)( { dispatch, registry, resolveSelect, select } );
435436

436437
// Fetch request should have been issued.
437438
expect( triggerFetch ).toHaveBeenCalledWith( {
@@ -480,6 +481,7 @@ describe( 'getEntityRecords', () => {
480481
dispatch,
481482
registry,
482483
resolveSelect,
484+
select,
483485
} );
484486

485487
// Permissions should have been cached
@@ -521,6 +523,7 @@ describe( 'getEntityRecords', () => {
521523
dispatch,
522524
registry,
523525
resolveSelect,
526+
select,
524527
} );
525528

526529
// Permissions should NOT have been cached
@@ -565,7 +568,7 @@ describe( 'getEntityRecords', () => {
565568
await getEntityRecords( 'postType', 'attachment', {
566569
per_page: -1,
567570
[ RECEIVE_INTERMEDIATE_RESULTS ]: true,
568-
} )( { dispatch, registry, resolveSelect } );
571+
} )( { dispatch, registry, resolveSelect, select } );
569572

570573
// 3 calls for intermediate results (one per page), plus 1 final call with complete records
571574
expect( dispatch.receiveEntityRecords ).toHaveBeenCalledTimes( 4 );
@@ -610,14 +613,15 @@ describe( 'getEntityRecords', () => {
610613

611614
describe( 'taxonomy pagination', () => {
612615
const registry = { batch: ( callback ) => callback() };
613-
let dispatch, loadedTaxonomyEntities;
616+
let dispatch, loadedTaxonomyEntities, select;
614617

615618
beforeEach( async () => {
616619
dispatch = Object.assign( jest.fn(), {
617620
receiveEntityRecords: jest.fn(),
618621
__unstableAcquireStoreLock: jest.fn().mockResolvedValue( 'lock' ),
619622
__unstableReleaseStoreLock: jest.fn(),
620623
} );
624+
select = { getPersistedIdMap: jest.fn( () => ( {} ) ) };
621625
triggerFetch.mockReset();
622626

623627
const mockTaxonomyConfig = {
@@ -651,7 +655,7 @@ describe( 'taxonomy pagination', () => {
651655
await getEntityRecords( 'taxonomy', 'category', {
652656
per_page: 2,
653657
page: 1,
654-
} )( { dispatch, registry, resolveSelect } );
658+
} )( { dispatch, registry, resolveSelect, select } );
655659

656660
expect( triggerFetch ).toHaveBeenLastCalledWith( {
657661
path: '/wp/v2/categories?context=edit&per_page=2&page=1',
@@ -690,7 +694,7 @@ describe( 'taxonomy pagination', () => {
690694
await getEntityRecords( 'taxonomy', 'category', {
691695
per_page: 2,
692696
page: 1,
693-
} )( { dispatch, registry, resolveSelect } );
697+
} )( { dispatch, registry, resolveSelect, select } );
694698

695699
expect( dispatch.receiveEntityRecords ).toHaveBeenCalledWith(
696700
'taxonomy',

0 commit comments

Comments
 (0)