-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: remove NoteVisualization from component barrel * feat: migrate some files to TS * feat: add unit test * feat: type Distribution for Home Page * fix
- Loading branch information
1 parent
c2c195f
commit f6e8aef
Showing
10 changed files
with
68 additions
and
12 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,42 @@ | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { renderHook, waitFor } from '@testing-library/react'; | ||
import { PropsWithChildren } from 'react'; | ||
import { vi } from 'vitest'; | ||
import { useStamps, useStampsOptions } from './stamps'; | ||
|
||
// Mock de l'API | ||
vi.mock('../../sdk', () => ({ | ||
StampsApi: { | ||
getStamps: () => ['stamp1', 'stamp2'], | ||
}, | ||
})); | ||
|
||
const queryClient = new QueryClient(); | ||
const wrapper = ({ children }: PropsWithChildren<unknown>) => ( | ||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider> | ||
); | ||
|
||
describe('useStamps', () => { | ||
it('should fetch stamps', async () => { | ||
const mockStamps = ['stamp1', 'stamp2']; | ||
|
||
const { result } = renderHook(() => useStamps(), { wrapper }); | ||
|
||
await waitFor(() => expect(result.current.isSuccess).toBe(true)); | ||
|
||
expect(result.current.data).toEqual(mockStamps); | ||
}); | ||
}); | ||
|
||
describe('useStampsOptions', () => { | ||
it('should return stamps as options', async () => { | ||
const { result } = renderHook(() => useStampsOptions(), { wrapper }); | ||
|
||
await waitFor(() => expect(result.current).toHaveLength(2)); | ||
|
||
expect(result.current).toEqual([ | ||
{ value: 'stamp1', label: 'stamp1' }, | ||
{ value: 'stamp2', label: 'stamp2' }, | ||
]); | ||
}); | ||
}); |