From 8436924db09522863a70252766448902e43c2d2b Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Fri, 10 May 2024 16:08:39 +0100 Subject: [PATCH] Fix unit tests --- .../editor/src/components/page-attributes/test/order.js | 6 +++++- .../editor/src/components/post-last-revision/test/check.js | 6 +++++- .../src/components/post-type-support-check/test/index.js | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/editor/src/components/page-attributes/test/order.js b/packages/editor/src/components/page-attributes/test/order.js index 245cbbb8fc71db..fcb836bbfef0d3 100644 --- a/packages/editor/src/components/page-attributes/test/order.js +++ b/packages/editor/src/components/page-attributes/test/order.js @@ -22,7 +22,11 @@ jest.mock( '@wordpress/data/src/components/use-dispatch', () => ( { function setupDataMock( order = 0 ) { useSelect.mockImplementation( ( mapSelect ) => mapSelect( () => ( { - getPostType: () => null, + getPostType: () => ( { + supports: { + 'page-attributes': true, + }, + } ), getEditedPostAttribute: ( attr ) => { switch ( attr ) { case 'menu_order': diff --git a/packages/editor/src/components/post-last-revision/test/check.js b/packages/editor/src/components/post-last-revision/test/check.js index 6e5210e8ed6bfb..0c3e680992a2e1 100644 --- a/packages/editor/src/components/post-last-revision/test/check.js +++ b/packages/editor/src/components/post-last-revision/test/check.js @@ -21,7 +21,11 @@ function setupDataMock( id, count ) { getCurrentPostLastRevisionId: () => id, getCurrentPostRevisionsCount: () => count, getEditedPostAttribute: () => null, - getPostType: () => null, + getPostType: () => ( { + supports: { + revisions: true, + }, + } ), } ) ) ); } diff --git a/packages/editor/src/components/post-type-support-check/test/index.js b/packages/editor/src/components/post-type-support-check/test/index.js index 8acef8abacb6b2..71b9f083a74a23 100644 --- a/packages/editor/src/components/post-type-support-check/test/index.js +++ b/packages/editor/src/components/post-type-support-check/test/index.js @@ -29,7 +29,7 @@ function setupUseSelectMock( postType ) { } describe( 'PostTypeSupportCheck', () => { - it( 'renders its children when post type is not known', () => { + it( 'does not render its children when post type is not known', () => { setupUseSelectMock( undefined ); const { container } = render( @@ -38,7 +38,7 @@ describe( 'PostTypeSupportCheck', () => { ); - expect( container ).toHaveTextContent( 'Supported' ); + expect( container ).not.toHaveTextContent( 'Supported' ); } ); it( 'does not render its children when post type is known and not supports', () => {