Skip to content

Commit

Permalink
Add unit test for Reusable blocks selector
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Nov 23, 2021
1 parent 3c257e6 commit 75b3198
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/edit-site/src/store/test/selectors.js
Expand Up @@ -17,16 +17,21 @@ import {
getPreviousEditedPostId,
getPage,
getNavigationPanelActiveMenu,
getReusableBlocks,
isNavigationOpened,
isInserterOpened,
isListViewOpened,
} from '../selectors';

describe( 'selectors', () => {
const canUser = jest.fn( () => true );
const getEntityRecords = jest.fn( () => [] );
getCanUserCreateMedia.registry = {
select: jest.fn( () => ( { canUser } ) ),
};
getReusableBlocks.registry = {
select: jest.fn( () => ( { getEntityRecords } ) ),
};

describe( 'isFeatureActive', () => {
it( 'is tolerant to an undefined features preference', () => {
Expand Down Expand Up @@ -83,6 +88,22 @@ describe( 'selectors', () => {
} );
} );

describe( 'getReusableBlocks', () => {
it( "selects `getEntityRecords( 'postType', 'wp_block' )` from the core store", () => {
expect( getReusableBlocks() ).toEqual( [] );
expect( getReusableBlocks.registry.select ).toHaveBeenCalledWith(
coreDataStore
);
expect( getEntityRecords ).toHaveBeenCalledWith(
'postType',
'wp_block',
{
per_page: -1,
}
);
} );
} );

describe( 'getSettings', () => {
it( "returns the settings when the user can't create media", () => {
canUser.mockReturnValueOnce( false );
Expand Down

0 comments on commit 75b3198

Please sign in to comment.