-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
681 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import * as React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { baselineComponent, waitForFloatingPosition } from '../../testing/utils'; | ||
import { Popover, type PopoverProps } from './Popover'; | ||
|
||
describe(Popover, () => { | ||
baselineComponent((props) => ( | ||
<Popover defaultShown {...props}> | ||
<div>Test</div> | ||
</Popover> | ||
)); | ||
|
||
it('should provide zIndex to popover element', async () => { | ||
const result = render( | ||
<Popover | ||
defaultShown | ||
content="Some popover" | ||
aria-describedby="target" | ||
role="tooltip" | ||
data-testid="popover" | ||
zIndex="100500" | ||
> | ||
<div id="target">Target</div> | ||
</Popover>, | ||
); | ||
await waitForFloatingPosition(); | ||
expect(result.getByTestId('popover').parentElement).toHaveStyle('z-index: 100500'); | ||
}); | ||
|
||
it('should injects aria-expanded attr to target element if correct role provided', async () => { | ||
const Fixture = ({ shown }: PopoverProps) => ( | ||
<Popover | ||
shown={shown} | ||
id="menu" | ||
role="menu" | ||
aria-labelledby="target" | ||
content={<div role="menuitem">1</div>} | ||
> | ||
<div id="target" aria-haspopup="true" aria-controls="menu" data-testid="target"> | ||
Target | ||
</div> | ||
</Popover> | ||
); | ||
const result = render(<Fixture shown />); | ||
await waitForFloatingPosition(); | ||
expect(result.getByTestId('target')).toHaveAttribute('aria-expanded', 'true'); | ||
result.rerender(<Fixture shown={false} />); | ||
await waitForFloatingPosition(); | ||
expect(result.getByTestId('target')).toHaveAttribute('aria-expanded', 'false'); | ||
}); | ||
}); |
Oops, something went wrong.