Skip to content
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { create } from 'react-test-renderer';
import { render } from '@testing-library/react';

/**
* Internal dependencies
Expand All @@ -10,27 +10,26 @@ import { PostTypeSupportCheck } from '../';

describe( 'PostTypeSupportCheck', () => {
it( 'renders its children when post type is not known', () => {
let postType;
const tree = create(
<PostTypeSupportCheck postType={ postType } supportKeys="title">
const { container } = render(
<PostTypeSupportCheck postType={ undefined } supportKeys="title">
Supported
</PostTypeSupportCheck>
);

expect( tree.toJSON() ).toBe( 'Supported' );
expect( container ).toHaveTextContent( 'Supported' );
} );

it( 'does not render its children when post type is known and not supports', () => {
const postType = {
supports: {},
};
const tree = create(
const { container } = render(
<PostTypeSupportCheck postType={ postType } supportKeys="title">
Supported
</PostTypeSupportCheck>
);

expect( tree.toJSON() ).toBe( null );
expect( container ).not.toHaveTextContent( 'Supported' );
} );

it( 'renders its children when post type is known and supports', () => {
Expand All @@ -39,13 +38,13 @@ describe( 'PostTypeSupportCheck', () => {
title: true,
},
};
const tree = create(
const { container } = render(
<PostTypeSupportCheck postType={ postType } supportKeys="title">
Supported
</PostTypeSupportCheck>
);

expect( tree.toJSON() ).toBe( 'Supported' );
expect( container ).toHaveTextContent( 'Supported' );
} );

it( 'renders its children if some of keys supported', () => {
Expand All @@ -54,7 +53,7 @@ describe( 'PostTypeSupportCheck', () => {
title: true,
},
};
const tree = create(
const { container } = render(
<PostTypeSupportCheck
postType={ postType }
supportKeys={ [ 'title', 'thumbnail' ] }
Expand All @@ -63,14 +62,14 @@ describe( 'PostTypeSupportCheck', () => {
</PostTypeSupportCheck>
);

expect( tree.toJSON() ).toBe( 'Supported' );
expect( container ).toHaveTextContent( 'Supported' );
} );

it( 'does not render its children if none of keys supported', () => {
const postType = {
supports: {},
};
const tree = create(
const { container } = render(
<PostTypeSupportCheck
postType={ postType }
supportKeys={ [ 'title', 'thumbnail' ] }
Expand All @@ -79,6 +78,6 @@ describe( 'PostTypeSupportCheck', () => {
</PostTypeSupportCheck>
);

expect( tree.toJSON() ).toBe( null );
expect( container ).not.toHaveTextContent( 'Supported' );
} );
} );