Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

context.svelte.test.ts

18 lines645 Bytes

1import { render } from '@testing-library/svelte'
2import { describe, expect, it } from 'vitest'
3import { getIsRestoringContext } from '../../src/index.js'
4import Base from './Base.svelte'
5​
6describe('getQueryClientContext', () => {
7 it('should throw when called without a client in context', () => {
8 expect(() => render(Base)).toThrow(
9 'No QueryClient was found in Svelte context. Did you forget to wrap your component with QueryClientProvider?',
10 )
11 })
12})
13​
14describe('getIsRestoringContext', () => {
15 it('should not throw when called outside of a component', () => {
16 expect(() => getIsRestoringContext()).not.toThrow()
17 })
18})