-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(drawer): handle clickoutside on slower active boolean (#1621)
* fix(drawer): handle clickoutside on slower active boolean * test: drawer opens on click
- Loading branch information
Showing
4 changed files
with
29 additions
and
14 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
import { generateSnapshots } from '@chanzuckerberg/story-utils'; | ||
import { composeStories } from '@storybook/testing-react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import React from 'react'; | ||
import * as stories from './Drawer.stories'; | ||
const { DefaultInteractive } = composeStories(stories); | ||
|
||
describe('<Drawer />', () => { | ||
generateSnapshots(stories, { | ||
getElement: async () => { | ||
const filters = await screen.findByRole('dialog'); | ||
return filters.parentElement; // eslint-disable-line testing-library/no-node-access | ||
}, | ||
}); | ||
|
||
it('shows the dialog when the open dialog button is clicked', async () => { | ||
const user = userEvent.setup(); | ||
render(<DefaultInteractive />); | ||
const openDrawerButton = await screen.findByRole('button', { | ||
name: 'Open Drawer', | ||
}); | ||
expect(screen.queryByRole('dialog')).not.toBeInTheDocument(); | ||
await user.click(openDrawerButton); | ||
expect(screen.getByRole('dialog')).toBeTruthy(); | ||
}); | ||
}); |
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
File renamed without changes.