Skip to content

Commit 7c3e028

Browse files
authored
test(solid-query-devtools/devtools): add wiring and default-value cases for 'initialIsOpen', 'errorTypes', 'theme', 'setClient', and 'unmount' (#10823)
* test(solid-query-devtools/devtools): add wiring cases for 'initialIsOpen', 'errorTypes', 'theme', 'setClient', and 'unmount' * test(solid-query-devtools/devtools): add default-value cases for 'initialIsOpen', 'errorTypes', and 'theme' when omitted
1 parent d5630c9 commit 7c3e028

1 file changed

Lines changed: 80 additions & 9 deletions

File tree

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

Lines changed: 80 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,97 @@ describe('SolidQueryDevtools', () => {
3535
).not.toThrow()
3636
})
3737

38-
it('should forward "buttonPosition" to the devtools instance', () => {
39-
const setButtonPosition = vi.spyOn(
38+
it('should forward "initialIsOpen" to the devtools instance', () => {
39+
const setInitialIsOpen = vi.spyOn(
4040
TanstackQueryDevtools.prototype,
41-
'setButtonPosition',
41+
'setInitialIsOpen',
4242
)
4343
const queryClient = new QueryClient()
4444

4545
render(() => (
46-
<SolidQueryDevtools client={queryClient} buttonPosition="top-left" />
46+
<SolidQueryDevtools client={queryClient} initialIsOpen={true} />
4747
))
4848

49-
expect(setButtonPosition).toHaveBeenCalledWith('top-left')
49+
expect(setInitialIsOpen).toHaveBeenCalledWith(true)
5050
})
5151

52-
it('should forward "position" to the devtools instance', () => {
53-
const setPosition = vi.spyOn(TanstackQueryDevtools.prototype, 'setPosition')
52+
it('should default "initialIsOpen" to "false" when the prop is omitted', () => {
53+
const setInitialIsOpen = vi.spyOn(
54+
TanstackQueryDevtools.prototype,
55+
'setInitialIsOpen',
56+
)
57+
const queryClient = new QueryClient()
58+
59+
render(() => <SolidQueryDevtools client={queryClient} />)
60+
61+
expect(setInitialIsOpen).toHaveBeenCalledWith(false)
62+
})
63+
64+
it('should forward "errorTypes" to the devtools instance', () => {
65+
const setErrorTypes = vi.spyOn(
66+
TanstackQueryDevtools.prototype,
67+
'setErrorTypes',
68+
)
69+
const queryClient = new QueryClient()
70+
const errorTypes = [
71+
{ name: 'Network', initializer: () => new Error('Network') },
72+
]
73+
74+
render(() => (
75+
<SolidQueryDevtools client={queryClient} errorTypes={errorTypes} />
76+
))
77+
78+
expect(setErrorTypes).toHaveBeenCalledWith(errorTypes)
79+
})
80+
81+
it('should default "errorTypes" to an empty array when the prop is omitted', () => {
82+
const setErrorTypes = vi.spyOn(
83+
TanstackQueryDevtools.prototype,
84+
'setErrorTypes',
85+
)
5486
const queryClient = new QueryClient()
5587

56-
render(() => <SolidQueryDevtools client={queryClient} position="left" />)
88+
render(() => <SolidQueryDevtools client={queryClient} />)
89+
90+
expect(setErrorTypes).toHaveBeenCalledWith([])
91+
})
92+
93+
it('should forward "theme" to the devtools instance', () => {
94+
const setTheme = vi.spyOn(TanstackQueryDevtools.prototype, 'setTheme')
95+
const queryClient = new QueryClient()
96+
97+
render(() => <SolidQueryDevtools client={queryClient} theme="dark" />)
98+
99+
expect(setTheme).toHaveBeenCalledWith('dark')
100+
})
101+
102+
it('should default "theme" to "system" when the prop is omitted', () => {
103+
const setTheme = vi.spyOn(TanstackQueryDevtools.prototype, 'setTheme')
104+
const queryClient = new QueryClient()
105+
106+
render(() => <SolidQueryDevtools client={queryClient} />)
107+
108+
expect(setTheme).toHaveBeenCalledWith('system')
109+
})
110+
111+
it('should forward the resolved "QueryClient" via "setClient"', () => {
112+
const setClient = vi.spyOn(TanstackQueryDevtools.prototype, 'setClient')
113+
const queryClient = new QueryClient()
114+
115+
render(() => <SolidQueryDevtools client={queryClient} />)
116+
117+
expect(setClient).toHaveBeenCalledWith(queryClient)
118+
})
119+
120+
it('should call "unmount" on the devtools instance when the component unmounts', () => {
121+
const unmount = vi.spyOn(TanstackQueryDevtools.prototype, 'unmount')
122+
const queryClient = new QueryClient()
123+
124+
const { unmount: unmountComponent } = render(() => (
125+
<SolidQueryDevtools client={queryClient} />
126+
))
127+
unmountComponent()
57128

58-
expect(setPosition).toHaveBeenCalledWith('left')
129+
expect(unmount).toHaveBeenCalled()
59130
})
60131
})

0 commit comments

Comments
 (0)