@@ -84,7 +84,10 @@ describe("IfFulfilled", () => {
84
84
await findByText ( "outer inner" )
85
85
expect ( queryByText ( "outer inner" ) ) . toBeInTheDocument ( )
86
86
} )
87
-
87
+ test ( "renders nothing if missing state" , ( ) => {
88
+ const { queryByText } = render ( < IfFulfilled > Test</ IfFulfilled > )
89
+ expect ( queryByText ( "Test" ) ) . not . toBeInTheDocument ( )
90
+ } )
88
91
test ( "renders without children" , async ( ) => {
89
92
const promiseFn = ( ) => resolveTo ( "ok" )
90
93
render ( < Async promiseFn = { promiseFn } > { state => < IfFulfilled state = { state } /> } </ Async > )
@@ -109,6 +112,10 @@ describe("IfPending", () => {
109
112
await findByText ( "done" )
110
113
expect ( queryByText ( "pending" ) ) . toBeNull ( )
111
114
} )
115
+ test ( "renders nothing if missing state" , ( ) => {
116
+ const { queryByText } = render ( < IfPending > Test</ IfPending > )
117
+ expect ( queryByText ( "Test" ) ) . not . toBeInTheDocument ( )
118
+ } )
112
119
} )
113
120
114
121
describe ( "IfInitial" , ( ) => {
@@ -134,6 +141,10 @@ describe("IfInitial", () => {
134
141
await findByText ( "done" )
135
142
expect ( queryByText ( "pending" ) ) . toBeNull ( )
136
143
} )
144
+ test ( "renders nothing if missing state" , ( ) => {
145
+ const { queryByText } = render ( < IfInitial > Test</ IfInitial > )
146
+ expect ( queryByText ( "Test" ) ) . not . toBeInTheDocument ( )
147
+ } )
137
148
} )
138
149
139
150
describe ( "IfRejected" , ( ) => {
@@ -148,6 +159,10 @@ describe("IfRejected", () => {
148
159
await findByText ( "err" )
149
160
expect ( queryByText ( "err" ) ) . toBeInTheDocument ( )
150
161
} )
162
+ test ( "renders nothing if missing state" , ( ) => {
163
+ const { queryByText } = render ( < IfRejected > Test</ IfRejected > )
164
+ expect ( queryByText ( "Test" ) ) . not . toBeInTheDocument ( )
165
+ } )
151
166
} )
152
167
153
168
describe ( "IfSettled" , ( ) => {
@@ -197,4 +212,8 @@ describe("IfSettled", () => {
197
212
fireEvent . click ( getByText ( "reload" ) )
198
213
await findByText ( "loading" )
199
214
} )
215
+ test ( "renders nothing if missing state" , ( ) => {
216
+ const { queryByText } = render ( < IfSettled > Test</ IfSettled > )
217
+ expect ( queryByText ( "Test" ) ) . not . toBeInTheDocument ( )
218
+ } )
200
219
} )
0 commit comments