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
Refactor 'should render children with additional tooltip when hovered…
…' test without and
  • Loading branch information
t-hamano committed Aug 20, 2022
commit 3cf023f148ec663d4d6a324a8b58b01616682af8
21 changes: 10 additions & 11 deletions packages/components/src/tooltip/test/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { render, screen } from '@testing-library/react';
import { render, screen, act } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

/**
Expand Down Expand Up @@ -71,26 +71,25 @@ describe( 'Tooltip', () => {
const user = userEvent.setup( {
advanceTimers: jest.advanceTimersByTime,
} );
jest.useFakeTimers();

render(
<Tooltip text="Help text">
<button>Hover Me!</button>
</Tooltip>
);

const button = screen.getByRole( 'button' );
const button = screen.getByRole( 'button', { name: 'Hover Me!' } );
expect( button ).toBeInTheDocument();

await user.hover( button );

expect(
screen.getByRole( 'button', { name: 'Hover Me!' } )
).toBeInTheDocument();
// Tooltip hasn't appeared yet
expect( screen.queryByText( 'Help text' ) ).not.toBeInTheDocument();

setTimeout( () => {
expect( screen.getByText( 'Help text' ) ).toBeInTheDocument();
jest.runOnlyPendingTimers();
jest.useRealTimers();
}, TOOLTIP_DELAY );
act( () => jest.advanceTimersByTime( TOOLTIP_DELAY ) );

// Tooltip shows after the delay
expect( screen.getByText( 'Help text' ) ).toBeInTheDocument();
} );

it( 'should not show tooltip on focus as result of mouse click', async () => {
Expand Down