Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/preact-query/src/__tests__/ssr.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
QueryClient,
QueryClientProvider,
useInfiniteQuery,
useMutationState,
useQuery,
} from '..'
import { setIsServer } from './utils'
Expand Down Expand Up @@ -136,6 +137,24 @@ describe('Server Side Rendering', () => {
queryCache.clear()
})

it('useMutationState should return empty array', () => {
function Page() {
const mutationState = useMutationState()

return <div>{`mutationState: ${mutationState.length}`}</div>
}

const markup = renderToString(
<QueryClientProvider client={queryClient}>
<Page />
</QueryClientProvider>,
)

expect(markup).toContain('mutationState: 0')

queryCache.clear()
})

it('useInfiniteQuery should return the correct state', async () => {
const key = queryKey()
const queryFn = vi.fn(() => sleep(10).then(() => 'page 1'))
Expand Down
Loading