-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(ui): Convert clipboard tooltip component to RTL (#28930)
- Loading branch information
Showing
2 changed files
with
17 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,30 @@ | ||
import {mountWithTheme} from 'sentry-test/enzyme'; | ||
import copy from 'copy-text-to-clipboard'; | ||
|
||
import {fireEvent, mountWithTheme} from 'sentry-test/reactTestingLibrary'; | ||
|
||
import ClipboardTooltip from 'app/components/clipboardTooltip'; | ||
import {OPEN_DELAY} from 'app/components/tooltip'; | ||
|
||
jest.mock('copy-text-to-clipboard'); | ||
|
||
describe('ClipboardTooltip', function () { | ||
it('renders', function () { | ||
it('renders', async function () { | ||
const title = 'tooltip content'; | ||
const content = 'This text displays a tooltip when hovering'; | ||
const wrapper = mountWithTheme( | ||
<ClipboardTooltip title={title}> | ||
<span>This text displays a tooltip when hovering</span> | ||
<span>{content}</span> | ||
</ClipboardTooltip> | ||
); | ||
|
||
jest.useFakeTimers(); | ||
|
||
const trigger = wrapper.find('span'); | ||
trigger.simulate('mouseEnter'); | ||
|
||
jest.advanceTimersByTime(OPEN_DELAY); | ||
wrapper.update(); | ||
|
||
const tooltipClipboardWrapper = wrapper.find('TooltipClipboardWrapper'); | ||
expect(tooltipClipboardWrapper.length).toEqual(1); | ||
expect(wrapper.getByText(content)).toBeInTheDocument(); | ||
fireEvent.mouseEnter(wrapper.getByText(content)); | ||
|
||
const tooltipTextContent = tooltipClipboardWrapper.find('TextOverflow'); | ||
expect(tooltipTextContent.length).toEqual(1); | ||
await wrapper.findByText(title); | ||
|
||
const clipboardContent = tooltipClipboardWrapper.find('Clipboard'); | ||
expect(clipboardContent.length).toEqual(1); | ||
expect(clipboardContent.props().value).toEqual(title); | ||
const clipboardContent = wrapper.getByLabelText('Copy to clipboard'); | ||
expect(clipboardContent).toBeInTheDocument(); | ||
fireEvent.click(clipboardContent); | ||
|
||
const iconCopy = clipboardContent.find('IconCopy'); | ||
expect(iconCopy.length).toEqual(1); | ||
expect(copy).toHaveBeenCalledWith(title); | ||
}); | ||
}); |