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
Add test: should render children with additional popover when hovered
  • Loading branch information
t-hamano committed Aug 15, 2022
commit 4e9b4cf904dae6246904b32f1e40bcf21e69e48c
38 changes: 33 additions & 5 deletions packages/components/src/tooltip/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe( 'Tooltip', () => {
).toBeInTheDocument();
} );

it( 'should render children with additional popover when over', () => {
it( 'should render children with additional popover when focused', () => {
render(
<Tooltip text="Help text">
<button>Hover Me!</button>
Expand All @@ -55,6 +55,32 @@ describe( 'Tooltip', () => {
expect( screen.getByText( 'Help text' ) ).toBeInTheDocument();
} );

it( 'should render children with additional popover when hovered', async () => {
const user = userEvent.setup( {
advanceTimers: jest.advanceTimersByTime,
} );
jest.useFakeTimers();

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

const button = screen.getByRole( 'button' );
await user.hover( button );

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

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

it( 'should show popover on focus', () => {
const originalFocus = jest.fn();
render(
Expand Down Expand Up @@ -120,6 +146,7 @@ describe( 'Tooltip', () => {
} );

const originalMouseEnter = jest.fn();
jest.useFakeTimers();
render(
<Tooltip text="Help text">
<button
Expand All @@ -136,10 +163,11 @@ describe( 'Tooltip', () => {
expect( screen.queryByText( 'Help text' ) ).not.toBeInTheDocument();
expect( originalMouseEnter ).toHaveBeenCalledTimes( 1 );

// Wait popover to be shown.
expect(
await screen.findByText( 'Help text' )
).toBeInTheDocument();
setTimeout( () => {
expect( screen.getByText( 'Help text' ) ).toBeInTheDocument();
jest.runOnlyPendingTimers();
jest.useRealTimers();
}, TOOLTIP_DELAY );
} );

it( 'should respect custom delay prop when showing popover', async () => {
Expand Down