File tree 3 files changed +15
-31
lines changed
3 files changed +15
-31
lines changed Original file line number Diff line number Diff line change 1
1
import { render , waitFor } from '@testing-library/react'
2
2
import React , { ReactNode } from 'react'
3
- import { setLogger } from 'react-query'
4
3
import { CustomDataProvider , DataQuery } from '../react'
5
4
import { QueryRenderInput } from '../types'
6
5
7
- beforeAll ( ( ) => {
8
- // Prevent the react-query logger from logging to the console
9
- setLogger ( {
10
- log : jest . fn ( ) ,
11
- warn : jest . fn ( ) ,
12
- error : jest . fn ( ) ,
13
- } )
14
- } )
15
-
16
- afterAll ( ( ) => {
17
- // Restore the original react-query logger
18
- setLogger ( console )
19
- } )
20
-
21
6
describe ( 'Testing custom data provider and useQuery hook' , ( ) => {
22
7
it ( 'Should render without failing' , async ( ) => {
23
8
const data = {
Original file line number Diff line number Diff line change 1
1
import { renderHook , act } from '@testing-library/react-hooks'
2
2
import React from 'react'
3
- import { setLogger } from 'react-query'
4
3
import { CustomDataProvider } from '../components/CustomDataProvider'
5
4
import { useDataQuery } from './useDataQuery'
6
5
7
- beforeAll ( ( ) => {
8
- // Prevent the react-query logger from logging to the console
9
- setLogger ( {
10
- log : jest . fn ( ) ,
11
- warn : jest . fn ( ) ,
12
- error : jest . fn ( ) ,
13
- } )
14
- } )
15
-
16
- afterAll ( ( ) => {
17
- // Restore the original react-query logger
18
- setLogger ( console )
19
- } )
20
-
21
6
describe ( 'useDataQuery' , ( ) => {
22
7
describe ( 'parameters: onComplete' , ( ) => {
23
8
it ( 'Should call onComplete with the data after a successful fetch' , async ( ) => {
Original file line number Diff line number Diff line change 1
1
import { useState , useRef } from 'react'
2
- import { useQuery } from 'react-query'
2
+ import { useQuery , setLogger } from 'react-query'
3
3
import { Query , QueryOptions } from '../../engine'
4
4
import { FetchError } from '../../engine/types/FetchError'
5
5
import { QueryRenderInput , QueryRefetchFunction } from '../../types'
6
6
import { useDataEngine } from './useDataEngine'
7
7
import { useStaticInput } from './useStaticInput'
8
8
9
+ const noop = ( ) => {
10
+ /**
11
+ * Used to silence the default react-query logger. Eventually we
12
+ * could expose the setLogger functionality and remove the call
13
+ * to setLogger here.
14
+ */
15
+ }
16
+
17
+ setLogger ( {
18
+ log : noop ,
19
+ warn : noop ,
20
+ error : noop ,
21
+ } )
22
+
9
23
export const useDataQuery = (
10
24
query : Query ,
11
25
{
You can’t perform that action at this time.
0 commit comments