Skip to content

Commit

Permalink
Add test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Jul 13, 2023
1 parent 2803307 commit 7f34dc7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/block-editor/src/components/link-control/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,32 @@ describe( 'Basic rendering', () => {

expect( mockOnRemove ).toHaveBeenCalled();
} );

it( 'should revert to "editing" mode when onRemove is triggered', async () => {
const user = userEvent.setup();
const mockOnRemove = jest.fn();

render(
<LinkControl
value={ { url: 'https://example.com' } }
onRemove={ mockOnRemove }
/>
);

const unLinkButton = screen.queryByRole( 'button', {
name: 'Unlink',
} );
expect( unLinkButton ).toBeVisible();

await user.click( unLinkButton );

expect( mockOnRemove ).toHaveBeenCalled();

// Should revert back to editing mode.
expect(
screen.getByRole( 'combobox', { name: 'Link' } )
).toBeVisible();
} );
} );
} );

Expand Down

0 comments on commit 7f34dc7

Please sign in to comment.