@@ -3,7 +3,12 @@ import { QueryClient, QueryObserver, onlineManager } from '@tanstack/query-core'
33import { fireEvent , render } from '@solidjs/testing-library'
44import { createLocalStorage } from '@solid-primitives/storage'
55import { Devtools } from '../Devtools'
6- import { PiPProvider , QueryDevtoolsContext , ThemeContext } from '../contexts'
6+ import {
7+ PiPProvider ,
8+ QueryDevtoolsContext ,
9+ ThemeContext ,
10+ useTheme ,
11+ } from '../contexts'
712import type { QueryDevtoolsProps } from '../contexts'
813
914// `solid-transition-group` internally imports from
@@ -1518,34 +1523,39 @@ describe('Devtools', () => {
15181523 } )
15191524
15201525 describe ( 'default theme' , ( ) => {
1521- it ( 'should render without throwing when no "ThemeContext.Provider" wraps it' , ( ) => {
1522- expect ( ( ) =>
1523- render ( ( ) => {
1524- const [ localStore , setLocalStore ] = createLocalStorage ( {
1525- prefix : 'TanstackQueryDevtools' ,
1526- } )
1527- return (
1528- < QueryDevtoolsContext . Provider
1529- value = { {
1530- client : queryClient ,
1531- queryFlavor : 'TanStack Query' ,
1532- version : '5' ,
1533- onlineManager,
1534- } }
1535- >
1536- < PiPProvider
1537- localStore = { localStore }
1538- setLocalStore = { setLocalStore }
1539- >
1540- < Devtools
1541- localStore = { localStore }
1542- setLocalStore = { setLocalStore }
1543- />
1544- </ PiPProvider >
1545- </ QueryDevtoolsContext . Provider >
1546- )
1547- } ) ,
1548- ) . not . toThrow ( )
1526+ it ( 'should fall back to the "dark" theme when no "ThemeContext.Provider" wraps it' , ( ) => {
1527+ let resolvedTheme : ReturnType < ReturnType < typeof useTheme > > | undefined
1528+ function ThemeProbe ( ) {
1529+ const theme = useTheme ( )
1530+ resolvedTheme = theme ( )
1531+ return null
1532+ }
1533+
1534+ const rendered = render ( ( ) => {
1535+ const [ localStore , setLocalStore ] = createLocalStorage ( {
1536+ prefix : 'TanstackQueryDevtools' ,
1537+ } )
1538+ return (
1539+ < QueryDevtoolsContext . Provider
1540+ value = { {
1541+ client : queryClient ,
1542+ queryFlavor : 'TanStack Query' ,
1543+ version : '5' ,
1544+ onlineManager,
1545+ } }
1546+ >
1547+ < PiPProvider localStore = { localStore } setLocalStore = { setLocalStore } >
1548+ < Devtools localStore = { localStore } setLocalStore = { setLocalStore } />
1549+ < ThemeProbe />
1550+ </ PiPProvider >
1551+ </ QueryDevtoolsContext . Provider >
1552+ )
1553+ } )
1554+
1555+ expect ( resolvedTheme ) . toBe ( 'dark' )
1556+ expect (
1557+ rendered . getByLabelText ( 'Open Tanstack query devtools' ) ,
1558+ ) . toBeInTheDocument ( )
15491559 } )
15501560 } )
15511561} )
0 commit comments