Skip to content

Commit

Permalink
Fix block inserter unit test
Browse files Browse the repository at this point in the history
Now that block impressions are enabled for all users, we must update the
test expectation to include the `isNew` property set by
`useBlockTypeImpression`. An alternative would be to update this test to
not explicitly check the component prop, but the rendered result which
the user can see.
  • Loading branch information
dcalhoun committed Sep 29, 2021
1 parent 8cfa0d7 commit d348ca0
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const selectMock = {
canInsertBlockType: jest.fn(),
getBlockType: jest.fn(),
getClipboard: jest.fn(),
getSettings: jest.fn( () => ( {} ) ),
getSettings: jest.fn( () => ( { impressions: {} } ) ),
};

describe( 'BlockTypesTab component', () => {
Expand All @@ -48,10 +48,14 @@ describe( 'BlockTypesTab component', () => {
it( 'shows block items', () => {
selectMock.getInserterItems.mockReturnValue( items );

const blockItems = items.filter(
( { id, category } ) =>
category !== 'reusable' && id !== 'core-embed/a-paragraph-embed'
);
const blockItems = items
.filter(
( { id, category } ) =>
category !== 'reusable' &&
id !== 'core-embed/a-paragraph-embed'
)
// Set `isNew` property expected from block type impressions
.map( ( filteredItems ) => ( { ...filteredItems, isNew: false } ) );
const component = shallow(
<BlockTypesTab
rootClientId={ 0 }
Expand Down

0 comments on commit d348ca0

Please sign in to comment.