Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unsupported block title translation test #33340

Merged
merged 4 commits into from
Jul 16, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions packages/block-library/src/missing/test/edit-integration.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* External dependencies
*/
import { initializeEditor } from 'test/helpers';

/**
* WordPress dependencies
*/
import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
import * as i18n from '@wordpress/i18n';
jest.mock( '@wordpress/i18n', () => {
const actual = jest.requireActual( '@wordpress/i18n' );
return {
...actual,
_x: jest.fn( actual._x ),
};
} );
guarani marked this conversation as resolved.
Show resolved Hide resolved

/**
* Internal dependencies
*/
import { registerCoreBlocks } from '../..';

beforeAll( () => {
// Register all core blocks
registerCoreBlocks();
} );

afterAll( () => {
// Clean up registered blocks
getBlockTypes().forEach( ( block ) => {
unregisterBlockType( block.name );
} );
} );

describe( 'Unsupported block', () => {
it( 'requests translated block title', async () => {
const initialHtml = `<!-- wp:table -->
<figure class="wp-block-table"><table><tbody><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></tbody></table></figure>
<!-- /wp:table -->`;
await initializeEditor( {
initialHtml,
} );

// jest spy for the _x translation function
const _xSpy = jest.spyOn( i18n, '_x' );

expect( _xSpy ).toHaveBeenCalled();
guarani marked this conversation as resolved.
Show resolved Hide resolved
} );
} );