-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* build: library 설치 * feat: lint 설정 * feat: config 설정 * feat: custom render 생성 * build: library 추가 설치 * feat: test setup 파일 추가 * chore: alias 추가 * fix: custon render option 속성 optional 하게 받기 * chore: 주석 제거 * build: test library 버전업 * fix: custom render type 수정 * feat: custom render에 memory router 추가 * feat: custom render에 query client provider 추가 * fix: fillStyle을 null로 설정할 수 없는 에러 해결 * fix: test 환경에 modal div 생성 * fix: custom render에 form provider 추가 * fix: window 함수 선언 * docs: README 수정
- Loading branch information
1 parent
0a48579
commit 83f9bf2
Showing
8 changed files
with
906 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import '@testing-library/jest-dom/vitest'; | ||
|
||
/* @ts-ignore */ | ||
HTMLCanvasElement.prototype.getContext = () => { | ||
return { | ||
fillStyle: '', | ||
fillRect: vitest.fn(), | ||
}; | ||
}; | ||
|
||
beforeAll(() => { | ||
const portalEl = document.createElement('div'); | ||
portalEl.id = 'modal'; | ||
document.body.appendChild(portalEl); | ||
}); | ||
|
||
// beforeEach(() => {}); | ||
// afterAll(() => {}); |
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,58 @@ | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { render, type RenderOptions } from '@testing-library/react'; | ||
import DeviceTypeProvider from 'contexts/DeviceTypeProvider'; | ||
import RecruitingInfoProvider from 'contexts/RecruitingInfoProvider'; | ||
import ThemeProvider from 'contexts/ThemeProvider'; | ||
import type { ReactElement, ReactNode } from 'react'; | ||
import { FormProvider, useForm } from 'react-hook-form'; | ||
import { MemoryRouter, type MemoryRouterProps } from 'react-router-dom'; | ||
|
||
interface AllTheProvidersProps extends MemoryRouterProps { | ||
children: ReactNode; | ||
} | ||
|
||
export const AllTheProviders = ({ children, ...memoryRouterProps }: AllTheProvidersProps) => { | ||
window.alert = vi.fn(); | ||
window.scrollTo = vi.fn(); | ||
|
||
const queryClient = new QueryClient({ | ||
defaultOptions: { | ||
queries: { | ||
refetchOnWindowFocus: false, | ||
refetchOnMount: false, | ||
refetchOnReconnect: false, | ||
gcTime: 1000 * 60 * 60, | ||
retry: false, | ||
}, | ||
}, | ||
}); | ||
|
||
const method = useForm({ mode: 'onBlur' }); | ||
|
||
return ( | ||
<QueryClientProvider client={queryClient}> | ||
<FormProvider {...method}> | ||
<MemoryRouter {...memoryRouterProps}> | ||
<ThemeProvider> | ||
<DeviceTypeProvider> | ||
<RecruitingInfoProvider>{children}</RecruitingInfoProvider> | ||
</DeviceTypeProvider> | ||
</ThemeProvider> | ||
</MemoryRouter> | ||
</FormProvider> | ||
</QueryClientProvider> | ||
); | ||
}; | ||
|
||
const customRender = ( | ||
ui: ReactElement, | ||
options?: Omit<RenderOptions, 'wrapper'>, | ||
memoryRouterProps?: MemoryRouterProps, | ||
) => | ||
render(ui, { | ||
wrapper: ({ children }) => <AllTheProviders {...memoryRouterProps}>{children}</AllTheProviders>, | ||
...options, | ||
}); | ||
|
||
export * from '@testing-library/react'; | ||
export { customRender as render }; |
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.