Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonjd committed Sep 21, 2023
1 parent 34806f9 commit 2e52836
Showing 1 changed file with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,52 @@ describe( 'usePageContentBlocks', () => {
];
it( 'should return empty array if `isPageContentFocused` is `false`', () => {
const { result } = renderHook( () =>
usePageContentBlocks( blocksList, false )
usePageContentBlocks( {
blocks: blocksList,
isPageContentFocused: false,
} )
);
expect( result.current ).toEqual( [] );
} );
it( 'should return empty array if `blocks` is undefined', () => {
const { result } = renderHook( () =>
usePageContentBlocks( undefined, true )
usePageContentBlocks( {
blocks: undefined,
isPageContentFocused: true,
} )
);
expect( result.current ).toEqual( [] );
} );
it( 'should return empty array if `blocks` is an empty array', () => {
const { result } = renderHook( () => usePageContentBlocks( [], true ) );
const { result } = renderHook( () =>
usePageContentBlocks( {
blocks: [],
isPageContentFocused: true,
} )
);
expect( result.current ).toEqual( [] );
} );
it( 'should return new block list', () => {
const { result } = renderHook( () =>
usePageContentBlocks( blocksList, true )
usePageContentBlocks( {
blocks: blocksList,
isPageContentFocused: true,
} )
);
expect( result.current ).toEqual( [
createBlock( 'core/post-title' ),
createBlock( 'core/post-featured-image' ),
createBlock( 'core/post-content' ),
createBlock( 'core/post-content' ),
] );
} );
it( 'should return new block list wrapped in a Group block', () => {
const { result } = renderHook( () =>
usePageContentBlocks( {
blocks: blocksList,
isPageContentFocused: true,
wrapPageContent: true,
} )
);
expect( result.current ).toEqual( [
{
Expand Down

0 comments on commit 2e52836

Please sign in to comment.