Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8603386
Migrate frim enzyme to testing-library
t-hamano Aug 8, 2022
5764d4a
update text matcher
t-hamano Aug 8, 2022
5901f73
Fix typo
t-hamano Aug 8, 2022
02520e8
Update matcher
t-hamano Aug 9, 2022
19d029c
Refactor fireEvent to userEvent
t-hamano Aug 12, 2022
28b1abe
Brush up test (tooltip won't be rendered)
t-hamano Aug 12, 2022
10274ad
Refactor setTimeout to findBy in one test
t-hamano Aug 12, 2022
d6f98a7
Don't use getElementsByClassName
t-hamano Aug 12, 2022
cdafb54
Don't use nodeName, childNodes
t-hamano Aug 12, 2022
81b473b
Remove unused event handler
t-hamano Aug 15, 2022
3126a88
Remove tootip position props
t-hamano Aug 15, 2022
4e9b4cf
Add test: should render children with additional popover when hovered
t-hamano Aug 15, 2022
d5e17de
Simplify mouse click test
t-hamano Aug 15, 2022
7aa6669
Standardize test cases name
t-hamano Aug 20, 2022
894e815
Add test to 'should render children'
t-hamano Aug 20, 2022
6dc8dcc
Merge two tests for focus
t-hamano Aug 20, 2022
3cf023f
Refactor 'should render children with additional tooltip when hovered…
t-hamano Aug 20, 2022
2a15013
Rename from `handleClick` to `onClickMock`
t-hamano Aug 20, 2022
c8b1c0a
Remove unnecessary test 'should show tooltip on delayed mouseenter'
t-hamano Aug 20, 2022
dda605a
Reactor: should not show tooltip on focus as result of mouse click
t-hamano Aug 20, 2022
4b143a0
Refactor: should respect custom delay prop when showing tooltip
t-hamano Aug 20, 2022
7f0367a
Refactor: should show tooltip when an element is disabled
t-hamano Aug 20, 2022
38b51af
Refactor: should not show tooltip if the mouse leaves the anchor befo…
t-hamano Aug 20, 2022
f5604cc
Merge branch 'trunk' into refactor/tooltip-test-to-testing-library
t-hamano Aug 20, 2022
e765736
Update changelog
t-hamano Aug 22, 2022
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
Prev Previous commit
Next Next commit
Simplify mouse click test
  • Loading branch information
t-hamano committed Aug 15, 2022
commit d5e17debeed6e05b64b318598f9bcc1cdb934787
40 changes: 11 additions & 29 deletions packages/components/src/tooltip/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,45 +99,27 @@ describe( 'Tooltip', () => {
expect( screen.getByText( 'Help text' ) ).toBeInTheDocument();
} );

it( 'should not show popover on focus as result of mousedown', async () => {
it( 'should not show popover on focus as result of mouse click', async () => {
const user = userEvent.setup( {
advanceTimers: jest.advanceTimersByTime,
} );
jest.useFakeTimers();

const originalOnMouseDown = jest.fn();
const originalOnMouseUp = jest.fn();
render(
<Tooltip text="Help text">
<button
onMouseDown={ originalOnMouseDown }
onMouseUp={ originalOnMouseUp }
>
Hover Me!
</button>
<button>Hover Me!</button>
</Tooltip>
);

const button = screen.getByRole( 'button' );
// Hovers the button and press the left mouse button
await user.pointer( [
{ target: button },
{ keys: '[MouseLeft]', target: button },
] );
expect( originalOnMouseDown ).toHaveBeenCalledWith(
expect.objectContaining( {
type: 'mousedown',
} )
);

expect( screen.queryByText( 'Help text' ) ).not.toBeInTheDocument();

// Release the left mouse button
await user.pointer( [ { keys: '[/MouseLeft]', target: button } ] );
expect( originalOnMouseUp ).toHaveBeenCalledWith(
expect.objectContaining( {
type: 'mouseup',
} )
);
await user.click( button );
setTimeout( () => {
expect(
screen.queryByText( 'Help text' )
).not.toBeInTheDocument();
jest.runOnlyPendingTimers();
jest.useRealTimers();
}, TOOLTIP_DELAY );
} );

it( 'should show popover on delayed mouseenter', async () => {
Expand Down