- Create code-first route tree in src/app/routing/routeTree.tsx - Replace ProtectedRoute with beforeLoad auth guards - Add useSearchParamsCompat for URLSearchParams access - Update App.tsx, layouts, and all page/widget imports - Add frontend tooling: biome, prettier, env config - Update all tests for TanStack Router compatibility - Remove react-router-dom dependency, @tanstack/router-plugin - Consolidate biome config at root level
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
import { renderHook, waitFor } from '@testing-library/react'
|
|
import { HttpResponse, http } from 'msw'
|
|
import type { ReactNode } from 'react'
|
|
import { describe, expect, it } from 'vitest'
|
|
import { server } from '@/shared/lib/test/server'
|
|
import { useBondCandles } from './useBondCandles'
|
|
|
|
const API = '/api/v1'
|
|
|
|
function createWrapper() {
|
|
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
return function Wrapper({ children }: { children: ReactNode }) {
|
|
return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
|
}
|
|
}
|
|
|
|
describe('useBondCandles', () => {
|
|
it('returns candle data', async () => {
|
|
const { result } = renderHook(
|
|
() => useBondCandles('SU26238RMFS5', '24h', '2024-01-01', '2024-01-31'),
|
|
{ wrapper: createWrapper() },
|
|
)
|
|
await waitFor(() => expect(result.current.isSuccess).toBe(true))
|
|
expect(result.current.data).toHaveLength(2)
|
|
})
|
|
|
|
it('returns empty array when no candles', async () => {
|
|
server.use(
|
|
http.get(`${API}/securities/bonds/:secid/candles`, () => {
|
|
return HttpResponse.json({
|
|
data: { data: [], meta: { fromCache: false, cachedAt: null } },
|
|
})
|
|
}),
|
|
)
|
|
const { result } = renderHook(
|
|
() => useBondCandles('SU26238RMFS5', '24h', '2024-01-01', '2024-01-31'),
|
|
{ wrapper: createWrapper() },
|
|
)
|
|
await waitFor(() => expect(result.current.isSuccess).toBe(true))
|
|
expect(result.current.data).toEqual([])
|
|
})
|
|
})
|