-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Update and remove unused packages (#990)
Co-authored-by: Michael Marszalek <[email protected]> Co-authored-by: Øyvind Thune <[email protected]>
- Loading branch information
1 parent
dcc846f
commit 4d94921
Showing
13 changed files
with
1,632 additions
and
2,442 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
1 change: 0 additions & 1 deletion
1
apps/storefront/components/Tokens/TokenFontSize/TokenFontSize.module.css
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,6 +1,5 @@ | ||
.font { | ||
min-height: 81px; | ||
min-height: 72px; | ||
width: 120px; | ||
border-radius: 4px; | ||
display: flex; | ||
|
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
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 |
---|---|---|
@@ -1,96 +1,99 @@ | ||
import React from 'react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { act, render as renderRtl, screen } from '@testing-library/react'; | ||
|
||
import type { TooltipProps } from './Tooltip'; | ||
import { Tooltip } from './Tooltip'; | ||
|
||
const render = async (props: Partial<TooltipProps> = {}) => { | ||
const allProps: TooltipProps = { | ||
children: <button>My button</button>, | ||
content: 'Tooltip text', | ||
...props, | ||
}; | ||
/* Flush microtasks */ | ||
await act(async () => {}); | ||
const user = userEvent.setup(); | ||
|
||
return { | ||
user, | ||
...renderRtl(<Tooltip {...allProps} />), | ||
}; | ||
}; | ||
|
||
describe('Tooltip', () => { | ||
describe('should render children', () => { | ||
it('should render child', async () => { | ||
await render(); | ||
const tooltipTrigger = screen.getByRole('button', { name: 'My button' }); | ||
|
||
expect(tooltipTrigger).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
describe('should render tooltip', () => { | ||
it('should render tooltip on hover', async () => { | ||
const { user } = await render(); | ||
const tooltipTrigger = screen.getByRole('button', { name: 'My button' }); | ||
|
||
expect(screen.queryByRole('tooltip')).not.toBeInTheDocument(); | ||
await act(async () => await user.hover(tooltipTrigger)); | ||
const tooltip = await screen.findByText('Tooltip text'); | ||
expect(tooltip).toBeInTheDocument(); | ||
expect(screen.queryByRole('tooltip')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render tooltip on focus', async () => { | ||
await render(); | ||
const tooltipTrigger = screen.getByRole('button', { name: 'My button' }); | ||
|
||
expect(screen.queryByText('Tooltip text')).not.toBeInTheDocument(); | ||
act(() => tooltipTrigger.focus()); | ||
const tooltip = await screen.findByText('Tooltip text'); | ||
expect(tooltip).toBeInTheDocument(); | ||
expect(screen.queryByRole('tooltip')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should close tooltip on escape', async () => { | ||
const { user } = await render(); | ||
const tooltipTrigger = screen.getByRole('button', { name: 'My button' }); | ||
|
||
expect(screen.queryByText('Tooltip text')).not.toBeInTheDocument(); | ||
await act(async () => { | ||
await user.hover(tooltipTrigger); | ||
}); | ||
const tooltip = await screen.findByText('Tooltip text'); | ||
expect(tooltip).toBeInTheDocument(); | ||
await act(async () => { | ||
await user.keyboard('[Escape]'); | ||
}); | ||
expect(screen.queryByText('Tooltip text')).not.toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it('should render open when we pass open prop', async () => { | ||
await render({ open: true }); | ||
const tooltipTrigger = screen.getByRole('button', { name: 'My button' }); | ||
|
||
expect(screen.getByRole('tooltip')).toBeInTheDocument(); | ||
expect(tooltipTrigger).toHaveAttribute('aria-describedby'); | ||
}); | ||
|
||
it('delay', async () => { | ||
const user = userEvent.setup(); | ||
|
||
await render({ delay: 300 }); | ||
|
||
await act(async () => { | ||
await user.hover(screen.getByRole('button')); | ||
await new Promise((r) => setTimeout(r, 250)); | ||
expect(screen.queryByRole('tooltip')).toBeNull(); | ||
await new Promise((r) => setTimeout(r, 600)); | ||
}); | ||
|
||
expect(screen.getByRole('tooltip')).toBeVisible(); | ||
}); | ||
}); | ||
import React from 'react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { | ||
act, | ||
render as renderRtl, | ||
screen, | ||
waitFor, | ||
} from '@testing-library/react'; | ||
|
||
import type { TooltipProps } from './Tooltip'; | ||
import { Tooltip } from './Tooltip'; | ||
|
||
const render = async (props: Partial<TooltipProps> = {}) => { | ||
const allProps: TooltipProps = { | ||
children: <button>My button</button>, | ||
content: 'Tooltip text', | ||
...props, | ||
}; | ||
/* Flush microtasks */ | ||
await act(async () => {}); | ||
const user = userEvent.setup(); | ||
|
||
return { | ||
user, | ||
...renderRtl(<Tooltip {...allProps} />), | ||
}; | ||
}; | ||
|
||
describe('Tooltip', () => { | ||
describe('should render children', () => { | ||
it('should render child', async () => { | ||
await render(); | ||
const tooltipTrigger = screen.getByRole('button', { name: 'My button' }); | ||
|
||
expect(tooltipTrigger).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
describe('should render tooltip', () => { | ||
it('should render tooltip on hover', async () => { | ||
const { user } = await render(); | ||
const tooltipTrigger = screen.getByRole('button', { name: 'My button' }); | ||
|
||
expect(screen.queryByRole('tooltip')).not.toBeInTheDocument(); | ||
await act(async () => await user.hover(tooltipTrigger)); | ||
const tooltip = await screen.findByText('Tooltip text'); | ||
expect(tooltip).toBeInTheDocument(); | ||
expect(screen.queryByRole('tooltip')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render tooltip on focus', async () => { | ||
await render(); | ||
const tooltipTrigger = screen.getByRole('button', { name: 'My button' }); | ||
|
||
expect(screen.queryByText('Tooltip text')).not.toBeInTheDocument(); | ||
act(() => tooltipTrigger.focus()); | ||
const tooltip = await screen.findByText('Tooltip text'); | ||
expect(tooltip).toBeInTheDocument(); | ||
expect(screen.queryByRole('tooltip')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should close tooltip on escape', async () => { | ||
const { user } = await render(); | ||
const tooltipTrigger = screen.getByRole('button', { name: 'My button' }); | ||
|
||
expect(screen.queryByText('Tooltip text')).not.toBeInTheDocument(); | ||
await act(async () => { | ||
await user.hover(tooltipTrigger); | ||
}); | ||
const tooltip = await screen.findByText('Tooltip text'); | ||
expect(tooltip).toBeInTheDocument(); | ||
await act(async () => { | ||
await user.keyboard('[Escape]'); | ||
}); | ||
expect(screen.queryByText('Tooltip text')).not.toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it('should render open when we pass open prop', async () => { | ||
await render({ open: true }); | ||
const tooltipTrigger = screen.getByRole('button', { name: 'My button' }); | ||
|
||
expect(screen.getByRole('tooltip')).toBeInTheDocument(); | ||
expect(tooltipTrigger).toHaveAttribute('aria-describedby'); | ||
}); | ||
|
||
it('delay', async () => { | ||
const user = userEvent.setup(); | ||
|
||
await render({ delay: 300 }); | ||
|
||
await user.hover(screen.getByRole('button')); | ||
expect(screen.queryByRole('tooltip')).toBeNull(); | ||
|
||
await waitFor(() => { | ||
expect(screen.queryByRole('tooltip')).toBeVisible(); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.