Skip to content

Commit

Permalink
Mobile - Gallery block - Test the block renders the placeholder corre…
Browse files Browse the repository at this point in the history
…ctly if there are no inner blocks
  • Loading branch information
Gerardo committed Jun 16, 2023
1 parent 599196a commit da45db6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ exports[`Gallery block rearranges gallery items 1`] = `
<!-- /wp:gallery -->"
`;

exports[`Gallery block renders gallery block placeholder correctly if the block doesn't have inner blocks 1`] = `
"<!-- wp:gallery {"linkTo":"none"} -->
<figure class="wp-block-gallery has-nested-images columns-default is-cropped"></figure>
<!-- /wp:gallery -->"
`;

exports[`Gallery block sets caption to gallery 1`] = `
"<!-- wp:gallery {"linkTo":"none"} -->
<figure class="wp-block-gallery has-nested-images columns-default is-cropped"><!-- wp:image {"id":2000} -->
Expand Down
20 changes: 20 additions & 0 deletions packages/block-library/src/gallery/test/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import {
requestImageFailedRetryDialog,
requestImageUploadCancelDialog,
} from '@wordpress/react-native-bridge';
import { store as blockEditorStore } from '@wordpress/block-editor';
import { select } from '@wordpress/data';

/**
* Internal dependencies
Expand Down Expand Up @@ -75,6 +77,24 @@ describe( 'Gallery block', () => {
expect( getEditorHtml() ).toMatchSnapshot();
} );

it( "renders gallery block placeholder correctly if the block doesn't have inner blocks", async () => {
const getBlockSpy = jest
.spyOn( select( blockEditorStore ), 'getBlock' )
.mockReturnValue( {
innerBlocks: undefined,
attributes: {
content: '',
},
} );

const screen = await addGalleryBlock();

expect( getBlock( screen, 'Gallery' ) ).toBeVisible();
expect( getEditorHtml() ).toMatchSnapshot();

getBlockSpy.mockReset();
} );

it( 'selects a gallery item', async () => {
const { galleryBlock } = await initializeWithGalleryBlock( {
numberOfItems: 1,
Expand Down

0 comments on commit da45db6

Please sign in to comment.