-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add infiniteQueryOptions, update context
- Loading branch information
1 parent
f99313d
commit c82319e
Showing
8 changed files
with
69 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script lang="ts"> | ||
import { getQueryClientContext } from '../../src/context' | ||
getQueryClientContext() | ||
</script> |
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 |
---|---|---|
@@ -1,8 +1,18 @@ | ||
import { describe, expect, it } from 'vitest' | ||
import { describe, expect, test } from 'vitest' | ||
import { render } from '@testing-library/svelte' | ||
import { getIsRestoringContext } from '../../src/context' | ||
import BaseExample from './BaseExample.svelte' | ||
|
||
describe('getQueryClientContext', () => { | ||
test('Throw when called without a client in context', () => { | ||
expect(() => render(BaseExample)).toThrowError( | ||
'No QueryClient was found in Svelte context. Did you forget to wrap your component with QueryClientProvider?', | ||
) | ||
}) | ||
}) | ||
|
||
describe('getIsRestoringContext', () => { | ||
it('Should not throw when called outside of a component', () => { | ||
expect(() => getIsRestoringContext()).to.not.throw() | ||
test('Do not throw when called outside of a component', () => { | ||
expect(() => getIsRestoringContext()).not.toThrowError() | ||
}) | ||
}) |
4 changes: 2 additions & 2 deletions
4
packages/svelte-query/tests/createMutation/createMutation.test.ts
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
28 changes: 28 additions & 0 deletions
28
packages/svelte-query/tests/infiniteQueryOptions/infiniteQueryOptions.test.ts
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,28 @@ | ||
import { describe, expectTypeOf, test } from 'vitest' | ||
import { type InfiniteData } from '@tanstack/query-core' | ||
import { infiniteQueryOptions } from '../../src/infiniteQueryOptions' | ||
|
||
describe('queryOptions', () => { | ||
test('Should not allow excess properties', () => { | ||
infiniteQueryOptions({ | ||
queryKey: ['key'], | ||
queryFn: () => Promise.resolve('data'), | ||
getNextPageParam: () => 1, | ||
initialPageParam: 1, | ||
// @ts-expect-error this is a good error, because stallTime does not exist! | ||
stallTime: 1000, | ||
}) | ||
}) | ||
test('Should infer types for callbacks', () => { | ||
infiniteQueryOptions({ | ||
queryKey: ['key'], | ||
queryFn: () => Promise.resolve('data'), | ||
staleTime: 1000, | ||
getNextPageParam: () => 1, | ||
initialPageParam: 1, | ||
select: (data) => { | ||
expectTypeOf(data).toEqualTypeOf<InfiniteData<string, number>>() | ||
}, | ||
}) | ||
}) | ||
}) |
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