QuickLinks: Prevent jsdom "Error: Not implemented: navigation" test output (https://github.com/woocommerce/woocommerce-admin/pull/4547)

This commit is contained in:
Matt Sherman 2020-06-11 07:58:09 -04:00 committed by GitHub
parent 227a499343
commit bea82c93cd
2 changed files with 29 additions and 9 deletions

View File

@ -56,7 +56,12 @@ describe( 'QuickLinks', () => {
const recordEvent = jest.fn();
render(
<QuickLinks getSetting={ () => {} } recordEvent={ recordEvent } />
<QuickLinks
getSetting={ () => {} }
recordEvent={ recordEvent }
// Prevent jsdom "Error: Not implemented: navigation" in test output
onItemClick={ () => false }
/>
);
userEvent.click(
@ -76,7 +81,12 @@ describe( 'QuickLinks', () => {
const recordEvent = jest.fn();
render(
<QuickLinks getSetting={ () => {} } recordEvent={ recordEvent } />
<QuickLinks
getSetting={ () => {} }
recordEvent={ recordEvent }
// Prevent jsdom "Error: Not implemented: navigation" in test output
onItemClick={ () => false }
/>
);
userEvent.click(
@ -96,7 +106,12 @@ describe( 'QuickLinks', () => {
const recordEvent = jest.fn();
render(
<QuickLinks getSetting={ () => {} } recordEvent={ recordEvent } />
<QuickLinks
getSetting={ () => {} }
recordEvent={ recordEvent }
// Prevent jsdom "Error: Not implemented: navigation" in test output
onItemClick={ () => false }
/>
);
userEvent.click(
@ -118,7 +133,12 @@ describe( 'QuickLinks', () => {
const recordEvent = jest.fn();
render(
<QuickLinks getSetting={ () => {} } recordEvent={ recordEvent } />
<QuickLinks
getSetting={ () => {} }
recordEvent={ recordEvent }
// Prevent jsdom "Error: Not implemented: navigation" in test output
onItemClick={ () => false }
/>
);
userEvent.click(
@ -141,10 +161,6 @@ describe( 'QuickLinks', () => {
<QuickLinks getSetting={ getSetting } recordEvent={ () => {} } />
);
userEvent.click(
screen.getByRole( 'menuitem', { name: 'View my store' } )
);
expect( getSetting ).toHaveBeenCalledWith( 'siteUrl' );
} );
} );

View File

@ -105,7 +105,11 @@ describe( 'Link', () => {
} );
it( 'should support `onClick`', () => {
const clickHandler = jest.fn();
// Prevent jsdom "Error: Not implemented: navigation" in test output
const clickHandler = jest.fn( ( event ) => {
event.preventDefault();
return false;
} );
const { container } = render(
<Link