Skip to content

Commit

Permalink
resolve test failures after package update
Browse files Browse the repository at this point in the history
  • Loading branch information
brookewp committed Jul 26, 2023
1 parent bb59c76 commit 9182f1e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 53 deletions.
1 change: 1 addition & 0 deletions packages/components/src/ui/ariakit-tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ function AriaToolTip( props: ToolTipProps ) {
shortcut={ shortcut }
/>
) }
{ /* workaround needed until floating-ui/core is updated to ^1.0.2 */ }
<TooltipArrow size={ 0.0001 } />
</Tooltip>
) }
Expand Down
107 changes: 54 additions & 53 deletions packages/components/src/ui/ariakit-tooltip/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,40 +70,19 @@ describe( 'ToolTip', () => {

render( <ToolTip { ...props } /> );

await user.tab();

expect(
screen.getByRole( 'button', { name: /Button/i } )
).toHaveFocus();

await waitFor( () =>
expect(
screen.getByRole( 'tooltip', { name: /tooltip text/i } )
).toBeVisible()
);
const button = screen.getByRole( 'button', { name: /Button/i } );

await user.tab();

expect(
screen.queryByRole( 'tooltip', { name: /tooltip text/i } )
).not.toBeInTheDocument();
} );

it( 'should render the tooltip when the tooltip anchor is hovered', async () => {
const user = userEvent.setup();

render( <ToolTip { ...props } /> );

const button = screen.getByRole( 'button', { name: /Button/i } );

await user.hover( button );
expect( button ).toHaveFocus();

await waitFor( () =>
expect(
screen.getByRole( 'tooltip', { name: /tooltip text/i } )
).toBeVisible()
);

await user.tab();
await user.unhover( button );

expect(
Expand Down Expand Up @@ -150,35 +129,6 @@ describe( 'ToolTip', () => {
).not.toBeInTheDocument();
} );

it( 'should show tooltip when an element is disabled', async () => {
const user = userEvent.setup();

render(
<ToolTip { ...props }>
<Button aria-disabled>Button</Button>
</ToolTip>
);

const button = screen.getByRole( 'button', { name: /Button/i } );

expect( button ).toBeVisible();
expect( button ).toHaveAttribute( 'aria-disabled' );

await user.hover( button );

await waitFor( () =>
expect(
screen.getByRole( 'tooltip', { name: /tooltip text/i } )
).toBeVisible()
);

await user.unhover( button );

expect(
screen.queryByRole( 'tooltip', { name: /tooltip text/i } )
).not.toBeInTheDocument();
} );

it( 'should not show tooltip if the mouse leaves the tooltip anchor before set delay', async () => {
const user = userEvent.setup();
const onMouseEnterMock = jest.fn();
Expand Down Expand Up @@ -245,6 +195,57 @@ describe( 'ToolTip', () => {
).not.toBeInTheDocument();
} );

it( 'should render the tooltip when the tooltip anchor is hovered', async () => {
const user = userEvent.setup();

render( <ToolTip { ...props } /> );

const button = screen.getByRole( 'button', { name: /Button/i } );

await user.hover( button );

await waitFor( () =>
expect(
screen.getByRole( 'tooltip', { name: /tooltip text/i } )
).toBeVisible()
);

await user.unhover( button );

expect(
screen.queryByRole( 'tooltip', { name: /tooltip text/i } )
).not.toBeInTheDocument();
} );

it( 'should show tooltip when an element is disabled', async () => {
const user = userEvent.setup();

render(
<ToolTip { ...props }>
<Button aria-disabled>Button</Button>
</ToolTip>
);

const button = screen.getByRole( 'button', { name: /Button/i } );

expect( button ).toBeVisible();
expect( button ).toHaveAttribute( 'aria-disabled' );

await user.hover( button );

await waitFor( () =>
expect(
screen.getByRole( 'tooltip', { name: /tooltip text/i } )
).toBeVisible()
);

await user.unhover( button );

expect(
screen.queryByRole( 'tooltip', { name: /tooltip text/i } )
).not.toBeInTheDocument();
} );

it( 'should render the shortcut display text when a string is passed as the shortcut', async () => {
const user = userEvent.setup();

Expand Down

0 comments on commit 9182f1e

Please sign in to comment.