-
Notifications
You must be signed in to change notification settings - Fork 0
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
3 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/shared/ui/edit-menu/__snapshots__/edit-menu.spec.tsx.snap
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,35 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`shared/ui/menu-item/menu-item > should render button witgh edit icon 1`] = ` | ||
<button | ||
aria-controls=":r0:" | ||
aria-haspopup="true" | ||
aria-label="button" | ||
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-1ccnvf0-MuiButtonBase-root-MuiIconButton-root" | ||
tabindex="0" | ||
type="button" | ||
> | ||
<svg | ||
aria-hidden="true" | ||
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-i4bv87-MuiSvgIcon-root" | ||
data-testid="MoreHorizIcon" | ||
focusable="false" | ||
viewBox="0 0 24 24" | ||
> | ||
<path | ||
d="M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" | ||
/> | ||
</svg> | ||
<span | ||
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root" | ||
/> | ||
</button> | ||
`; | ||
|
||
exports[`shared/ui/menu-item/menu-item > should render menu on button click 1`] = ` | ||
<ul | ||
class="MuiList-root MuiList-padding MuiMenu-list css-6hp17o-MuiList-root-MuiMenu-list" | ||
role="menu" | ||
tabindex="-1" | ||
/> | ||
`; |
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,45 @@ | ||
import { beforeEach, describe, expect, test } from 'vitest'; | ||
|
||
import { EditMenu } from './edit-menu'; | ||
|
||
import { RenderResult, render } from '~/test-utils'; | ||
|
||
describe('shared/ui/menu-item/menu-item', () => { | ||
const label = 'button'; | ||
let wrapper: RenderResult; | ||
|
||
const createComponent = () => { | ||
wrapper = render(<EditMenu label={label} />); | ||
}; | ||
|
||
const findButton = () => wrapper.getByRole('button', { name: label, }); | ||
const findMenu = () => wrapper.getByRole('menu'); | ||
const openMenu = () => wrapper.user.click(findButton()); | ||
|
||
beforeEach(() => { | ||
createComponent(); | ||
}); | ||
|
||
test('should render button witgh edit icon', () => { | ||
expect(findButton()).toMatchSnapshot(); | ||
expect(findMenu).toThrow(); | ||
}); | ||
|
||
test('should render menu on button click', async () => { | ||
await openMenu(); | ||
|
||
expect(findMenu()).toMatchSnapshot(); | ||
expect(findButton).toThrow(); | ||
}); | ||
|
||
test.each(['small', 'medium', 'large'] as const)( | ||
'should configure button size with size prop. Size %s', | ||
async (size) => { | ||
wrapper.rerender(<EditMenu label={label} size={size} />); | ||
|
||
expect(findButton()).toHaveClass( | ||
`MuiIconButton-size${size[0].toUpperCase() + size.slice(1)}` | ||
); | ||
} | ||
); | ||
}); |
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