Skip to content

Commit d5630c9

Browse files
test(solid-query-devtools/devtools): add tests for forwarding 'buttonPosition' and 'position' props to the devtools instance (#10819)
* test(solid-query-devtools/devtools): add tests for forwarding 'buttonPosition' and 'position' props to the devtools instance * ci: apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 9c8d2ea commit d5630c9

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

packages/solid-query-devtools/src/__tests__/devtools.test.tsx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
import { describe, expect, it } from 'vitest'
1+
import { afterEach, describe, expect, it, vi } from 'vitest'
22
import { render } from '@solidjs/testing-library'
33
import { QueryClient, QueryClientProvider } from '@tanstack/solid-query'
4+
import { TanstackQueryDevtools } from '@tanstack/query-devtools'
45
import SolidQueryDevtools from '../devtools'
56

67
describe('SolidQueryDevtools', () => {
8+
afterEach(() => {
9+
vi.restoreAllMocks()
10+
})
11+
712
it('should throw an error if no query client has been set', () => {
813
expect(() => render(() => <SolidQueryDevtools />)).toThrow(
914
'No QueryClient set, use QueryClientProvider to set one',
@@ -29,4 +34,27 @@ describe('SolidQueryDevtools', () => {
2934
render(() => <SolidQueryDevtools client={queryClient} />),
3035
).not.toThrow()
3136
})
37+
38+
it('should forward "buttonPosition" to the devtools instance', () => {
39+
const setButtonPosition = vi.spyOn(
40+
TanstackQueryDevtools.prototype,
41+
'setButtonPosition',
42+
)
43+
const queryClient = new QueryClient()
44+
45+
render(() => (
46+
<SolidQueryDevtools client={queryClient} buttonPosition="top-left" />
47+
))
48+
49+
expect(setButtonPosition).toHaveBeenCalledWith('top-left')
50+
})
51+
52+
it('should forward "position" to the devtools instance', () => {
53+
const setPosition = vi.spyOn(TanstackQueryDevtools.prototype, 'setPosition')
54+
const queryClient = new QueryClient()
55+
56+
render(() => <SolidQueryDevtools client={queryClient} position="left" />)
57+
58+
expect(setPosition).toHaveBeenCalledWith('left')
59+
})
3260
})

0 commit comments

Comments
 (0)