Skip to content

Commit

Permalink
test(DefinitionTooltip): fix unit tests and add coverage for Definiti…
Browse files Browse the repository at this point in the history
…onTooltip (#17679)

* fix: definitiontooltip initial click

* fix issue where initial click would open and immediately close tooltip
* fix unit tests around this functionality

* test(definitiontooltip): definitiontooltip tests

* remove duplicate test case

---------

Co-authored-by: Ariella Gilmore <[email protected]>
Co-authored-by: Preeti Bansal <[email protected]>
  • Loading branch information
3 people authored Oct 14, 2024
1 parent 32c8bef commit 85771f2
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ import React from 'react';
import { DefinitionTooltip } from '../DefinitionTooltip';

describe('DefinitionTooltip', () => {
it('should display onClick a definition provided via prop', async () => {
it('should display on click a definition provided via prop', async () => {
const definition = 'Uniform Resource Locator';
render(<DefinitionTooltip definition={definition}>URL</DefinitionTooltip>);
expect(screen.getByRole('button')).toHaveAttribute(
'aria-expanded',
'false'
);
await userEvent.click(screen.getByText('URL'));
expect(screen.getByText(definition)).toBeVisible();
expect(screen.getByRole('button')).toHaveAttribute('aria-expanded', 'true');
});

it('should have a visible tooltip if `defaultOpen` is set to true', () => {
Expand All @@ -25,7 +29,7 @@ describe('DefinitionTooltip', () => {
term
</DefinitionTooltip>
);
expect(screen.getByText(definition)).toBeVisible();
expect(screen.getByRole('button')).toHaveAttribute('aria-expanded', 'true');
});

describe('Component API', () => {
Expand Down

0 comments on commit 85771f2

Please sign in to comment.