Skip to content

Commit a76d1df

Browse files
authored
add test for useQuery in manual mode (#164)
1 parent bca6374 commit a76d1df

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/tests/useQuery.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,23 @@ describe('useQuery', () => {
138138

139139
expect(queryFn).toHaveBeenCalledWith('test', variables)
140140
})
141+
142+
// See https://github.com/tannerlinsley/react-query/issues/161
143+
it('should not fetch query when `manual` is set to `true`', async () => {
144+
const queryFn = jest.fn()
145+
146+
function Page() {
147+
const { data = 'default' } = useQuery('test', queryFn, { manual: true })
148+
149+
return (
150+
<div>
151+
<h1>{data}</h1>
152+
</div>
153+
)
154+
}
155+
156+
const rendered = render(<Page />)
157+
await waitForElement(() => rendered.getByText('default'))
158+
expect(queryFn).not.toHaveBeenCalled()
159+
})
141160
})

0 commit comments

Comments
 (0)