-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
0744e64
commit f63a0db
Showing
6 changed files
with
83 additions
and
11 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
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
24 changes: 22 additions & 2 deletions
24
src/components/SideDrawer/__test__/TestDrawerContents.test.tsx
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,14 +1,34 @@ | ||
import { describe, expect, it } from 'vitest' | ||
import { describe, expect, it, vi } from 'vitest' | ||
import { render } from '@/tests/customRender' | ||
import { screen } from '@testing-library/react' | ||
import DrawerContents from '../DrawerContents' | ||
import userEvent from '@testing-library/user-event' | ||
import useMediaQuery from '@mui/material/useMediaQuery' | ||
|
||
vi.mock('@mui/material/useMediaQuery', () => { | ||
return { | ||
default: vi.fn() | ||
} | ||
}) | ||
|
||
describe('DrawerContents', () => { | ||
it('should display the DrawerContents', async () => { | ||
render(<DrawerContents />) | ||
render(<DrawerContents closeDrawer={() => { }} />) | ||
const japanese = await screen.findByText('日本語') | ||
expect(japanese).toBeVisible() | ||
}) | ||
|
||
it('should call closeDrawer when clicking x on mobile viewport', async () => { | ||
const mock = vi.fn(() => { }) | ||
const user = userEvent.setup() | ||
vi.mocked(useMediaQuery).mockReturnValue(true) | ||
|
||
render(<DrawerContents closeDrawer={mock} />) | ||
const closeButton = await screen.findByLabelText('close-button') | ||
await user.click(closeButton) | ||
|
||
expect(mock).toHaveBeenCalled() | ||
}) | ||
|
||
it.todo('should show the NavLinks on mobile screens') | ||
}) |
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