@@ -17,7 +17,11 @@ import type {
17
17
UseSuspenseInfiniteQueryResult ,
18
18
UseSuspenseQueryResult ,
19
19
} from '..'
20
- import { createRenderStream , disableActEnvironment , cleanup } from '@testing-library/react-render-stream'
20
+ import {
21
+ createRenderStream ,
22
+ disableActEnvironment ,
23
+ cleanup ,
24
+ } from '@testing-library/react-render-stream'
21
25
22
26
// should probably end up in some setup file
23
27
afterEach ( cleanup )
@@ -31,7 +35,9 @@ describe('useSuspenseQuery', () => {
31
35
32
36
const key = queryKey ( )
33
37
34
- const renderStream = createRenderStream < UseSuspenseQueryResult < number > | undefined > ( { snapshotDOM : true } )
38
+ const renderStream = createRenderStream <
39
+ UseSuspenseQueryResult < number > | undefined
40
+ > ( { snapshotDOM : true } )
35
41
36
42
let count = 0
37
43
@@ -62,37 +68,43 @@ describe('useSuspenseQuery', () => {
62
68
< Page />
63
69
</ React . Suspense > ,
64
70
{
65
- wrapper : ( { children } ) => < QueryClientProvider client = { queryClient } > { children } </ QueryClientProvider >
66
- }
71
+ wrapper : ( { children } ) => (
72
+ < QueryClientProvider client = { queryClient } >
73
+ { children }
74
+ </ QueryClientProvider >
75
+ ) ,
76
+ } ,
67
77
)
68
78
69
79
{
70
80
const { snapshot, withinDOM } = await renderStream . takeRender ( )
71
81
// Page didn't render yet, so no call to `replaceSnapshot` yet
72
82
expect ( snapshot ) . toBeUndefined ( ) // I'd probably skip this assertion
73
- withinDOM ( ) . getByText ( " loading" )
83
+ withinDOM ( ) . getByText ( ' loading' )
74
84
}
75
85
{
76
86
const { snapshot, withinDOM } = await renderStream . takeRender ( )
77
87
expect ( snapshot ) . toMatchObject ( { data : 1 , status : 'success' } )
78
- withinDOM ( ) . getByText ( " data: 1" ) // I'd probably skip this assertion
88
+ withinDOM ( ) . getByText ( ' data: 1' ) // I'd probably skip this assertion
79
89
}
80
90
fireEvent . click ( rendered . getByLabelText ( 'toggle' ) )
81
91
{
82
92
const { snapshot, withinDOM } = await renderStream . takeRender ( )
83
93
// Page is suspended so it doesn't replace the snapshot yet
84
94
expect ( snapshot ) . toMatchObject ( { data : 1 , status : 'success' } ) // I'd probably skip this assertion
85
- withinDOM ( ) . getByText ( " loading" )
95
+ withinDOM ( ) . getByText ( ' loading' )
86
96
}
87
97
{
88
98
const { snapshot, withinDOM } = await renderStream . takeRender ( )
89
99
expect ( snapshot ) . toMatchObject ( { data : 2 , status : 'success' } )
90
- withinDOM ( ) . getByText ( " data: 2" ) // I'd probably skip this assertion
100
+ withinDOM ( ) . getByText ( ' data: 2' ) // I'd probably skip this assertion
91
101
}
92
-
102
+
93
103
// this would require setup of this matcher, seems that automatically only works with jest
94
104
// expect(renderStream).not.toRerender()
95
- await expect ( renderStream . takeRender ) . rejects . toMatchObject ( { message : expect . stringMatching ( / E x c e e d e d t i m e o u t / ) } )
105
+ await expect ( renderStream . takeRender ) . rejects . toMatchObject ( {
106
+ message : expect . stringMatching ( / E x c e e d e d t i m e o u t / ) ,
107
+ } )
96
108
} )
97
109
98
110
it ( 'should return the correct states for a successful infinite query' , async ( ) => {
@@ -900,7 +912,7 @@ describe('useSuspenseQuery', () => {
900
912
it ( 'should log an error when skipToken is passed as queryFn' , ( ) => {
901
913
const consoleErrorSpy = vi
902
914
. spyOn ( console , 'error' )
903
- . mockImplementation ( ( ) => { } )
915
+ . mockImplementation ( ( ) => { } )
904
916
const key = queryKey ( )
905
917
906
918
function Page ( ) {
0 commit comments