Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,61 @@ describe('TanstackQueryDevtools', () => {
expect(() => devtools.unmount()).toThrow('Devtools is not mounted')
})
})

describe('setters', () => {
describe('before mount', () => {
it('should not throw when "setButtonPosition" is called', () => {
expect(() => devtools.setButtonPosition('top-left')).not.toThrow()
})

it('should not throw when "setPosition" is called', () => {
expect(() => devtools.setPosition('left')).not.toThrow()
})

it('should not throw when "setInitialIsOpen" is called', () => {
expect(() => devtools.setInitialIsOpen(true)).not.toThrow()
})

it('should not throw when "setErrorTypes" is called', () => {
expect(() =>
devtools.setErrorTypes([
{ name: 'NetworkError', initializer: () => new Error('Network') },
]),
).not.toThrow()
})

it('should not throw when "setClient" is called', () => {
expect(() => devtools.setClient(new QueryClient())).not.toThrow()
})

it('should not throw when "setTheme" is called', () => {
expect(() => devtools.setTheme('dark')).not.toThrow()
expect(() => devtools.setTheme('light')).not.toThrow()
expect(() => devtools.setTheme('system')).not.toThrow()
expect(() => devtools.setTheme(undefined)).not.toThrow()
})
})

describe('after mount', () => {
it('should not throw when setters are called on a mounted instance', () => {
const el = document.createElement('div')
devtools.mount(el)

try {
expect(() => devtools.setButtonPosition('top-left')).not.toThrow()
expect(() => devtools.setPosition('left')).not.toThrow()
expect(() => devtools.setInitialIsOpen(true)).not.toThrow()
expect(() =>
devtools.setErrorTypes([
{ name: 'NetworkError', initializer: () => new Error('Network') },
]),
).not.toThrow()
expect(() => devtools.setClient(new QueryClient())).not.toThrow()
expect(() => devtools.setTheme('dark')).not.toThrow()
} finally {
devtools.unmount()
}
})
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,66 @@ describe('TanstackQueryDevtoolsPanel', () => {
expect(() => devtools.unmount()).toThrow('Devtools is not mounted')
})
})

describe('setters', () => {
describe('before mount', () => {
it('should not throw when "setButtonPosition" is called', () => {
expect(() => devtools.setButtonPosition('top-left')).not.toThrow()
})

it('should not throw when "setPosition" is called', () => {
expect(() => devtools.setPosition('left')).not.toThrow()
})

it('should not throw when "setInitialIsOpen" is called', () => {
expect(() => devtools.setInitialIsOpen(true)).not.toThrow()
})

it('should not throw when "setErrorTypes" is called', () => {
expect(() =>
devtools.setErrorTypes([
{ name: 'NetworkError', initializer: () => new Error('Network') },
]),
).not.toThrow()
})

it('should not throw when "setClient" is called', () => {
expect(() => devtools.setClient(new QueryClient())).not.toThrow()
})

it('should not throw when "setOnClose" is called', () => {
expect(() => devtools.setOnClose(() => {})).not.toThrow()
})

it('should not throw when "setTheme" is called', () => {
expect(() => devtools.setTheme('dark')).not.toThrow()
expect(() => devtools.setTheme('light')).not.toThrow()
expect(() => devtools.setTheme('system')).not.toThrow()
expect(() => devtools.setTheme(undefined)).not.toThrow()
})
})

describe('after mount', () => {
it('should not throw when setters are called on a mounted instance', () => {
const el = document.createElement('div')
devtools.mount(el)

try {
expect(() => devtools.setButtonPosition('top-left')).not.toThrow()
expect(() => devtools.setPosition('left')).not.toThrow()
expect(() => devtools.setInitialIsOpen(true)).not.toThrow()
expect(() =>
devtools.setErrorTypes([
{ name: 'NetworkError', initializer: () => new Error('Network') },
]),
).not.toThrow()
expect(() => devtools.setClient(new QueryClient())).not.toThrow()
expect(() => devtools.setOnClose(() => {})).not.toThrow()
expect(() => devtools.setTheme('dark')).not.toThrow()
} finally {
devtools.unmount()
}
})
})
})
})
Loading