Skip to content

Commit

Permalink
Fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Feb 27, 2024
1 parent 2401c75 commit a44a9bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/core-data/src/test/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,15 @@ describe( 'getKindEntities', () => {
const dispatch = jest.fn();
const select = {
getEntitiesConfig: jest.fn( () => entities ),
getEntityConfig: jest.fn( () => ( {
kind: 'postType',
name: 'post',
} ) ),
};
const entities = [ { kind: 'postType' } ];
await getOrLoadEntitiesConfig(
'postType',
undefined
'post'
)( { dispatch, select } );
expect( dispatch ).not.toHaveBeenCalled();
} );
Expand All @@ -71,6 +75,7 @@ describe( 'getKindEntities', () => {
const dispatch = jest.fn();
const select = {
getEntitiesConfig: jest.fn( () => [] ),
getEntityConfig: jest.fn( () => undefined ),
};
await getOrLoadEntitiesConfig(
'unknownKind',
Expand All @@ -94,6 +99,7 @@ describe( 'getKindEntities', () => {
const dispatch = jest.fn();
const select = {
getEntitiesConfig: jest.fn( () => [] ),
getEntityConfig: jest.fn( () => undefined ),
};
triggerFetch.mockImplementation( () => fetchedEntities );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jest.mock( '@wordpress/data', () => {
getEntityRecordEdits: jest.fn().mockReturnValue( {
title: 'My Site',
} ),
getEntityConfig: jest.fn().mockReturnValue( {
meta: { labels: { title: 'Title' } },
} ),
};
};
return fn( select );
Expand Down

0 comments on commit a44a9bd

Please sign in to comment.