Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zhihengGet committed Jul 14, 2024
1 parent 5e9b3bf commit 8200ebf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<script lang="ts">
import { QueryClient } from '@tanstack/query-core'
import { createInfiniteQuery } from '../../src/createInfiniteQuery'
import { sleep } from '../utils'
const queryClient = new QueryClient()
const query = createInfiniteQuery(
{
queryKey: ['test'],
queryFn: ({ pageParam }) => Number(pageParam),
queryFn: ({ pageParam }) => {
return Number(pageParam)
},
getNextPageParam: (lastPage) => lastPage + 1,
initialPageParam: 0,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { describe, test } from 'vitest'
import { render } from '@testing-library/svelte'
import { render, waitFor } from '@testing-library/svelte'

import { sleep } from '../utils'
import BaseExample from './BaseExample.svelte'

describe.only('createQuery', () => {
describe('createQuery', () => {
test('Render and wait for success', async () => {
const rendered = render(BaseExample)

// await rendered.findByText('Data: undefined')
// await rendered.findByText('Status: pending')
waitFor(async () => {
await rendered.findByText('Data: undefined')
await rendered.findByText('Status: pending')
})

await sleep(20)

await rendered.findByText('Data: {"pages":[0],"pageParams":[0]}')
await rendered.findByText('Status: success')
waitFor(async () => {
await rendered.findByText('Data: {"pages":[0],"pageParams":[0]}')
await rendered.findByText('Status: success')
})
})
})

0 comments on commit 8200ebf

Please sign in to comment.