@@ -285,41 +285,32 @@ describe("createDocumentProjection", () => {
285285 )
286286 } )
287287
288- h2 . change ( doc => ( doc . key = "document-2" ) )
289- expect ( result . getByTestId ( "key-stable" ) . textContent ) . toBe ( "value" )
290- expect ( result . getByTestId ( "key-changing" ) . textContent ) . toBe ( "value" )
288+ return testEffect ( async done => {
289+ h2 . change ( doc => ( doc . key = "document-2" ) )
290+ expect ( result . getByTestId ( "key-stable" ) . textContent ) . toBe ( "value" )
291+ expect ( result . getByTestId ( "key-changing" ) . textContent ) . toBe ( "value" )
291292
292- await testEffect ( done => {
293293 h1 . change ( doc => ( doc . key = "hello" ) )
294- done ( )
295- } )
296- expect ( result . getByTestId ( "key-stable" ) . textContent ) . toBe ( "hello" )
297- expect ( result . getByTestId ( "key-changing" ) . textContent ) . toBe ( "hello" )
294+ await new Promise < void > ( setImmediate )
295+
296+ expect ( result . getByTestId ( "key-stable" ) . textContent ) . toBe ( "hello" )
297+ expect ( result . getByTestId ( "key-changing" ) . textContent ) . toBe ( "hello" )
298298
299- await testEffect ( done => {
300299 setChangingHandle ( ( ) => h2 )
301- done ( )
302- } )
303- expect ( result . getByTestId ( "key-stable" ) . textContent ) . toBe ( "hello" )
304- expect ( result . getByTestId ( "key-changing" ) . textContent ) . toBe ( "document-2" )
305300
306- await testEffect ( done => {
301+ expect ( result . getByTestId ( "key-stable" ) . textContent ) . toBe ( "hello" )
302+ expect ( result . getByTestId ( "key-changing" ) . textContent ) . toBe ( "document-2" )
303+
307304 setChangingHandle ( ( ) => h1 )
305+
306+ expect ( result . getByTestId ( "key-stable" ) . textContent ) . toBe ( "hello" )
307+ expect ( result . getByTestId ( "key-changing" ) . textContent ) . toBe ( "hello" )
308308 done ( )
309- } )
310- expect ( result . getByTestId ( "key-stable" ) . textContent ) . toBe ( "hello" )
311- expect ( result . getByTestId ( "key-changing" ) . textContent ) . toBe ( "hello" )
312309
313- await testEffect ( async done => {
314310 setChangingHandle ( h2 )
315311 h2 . change ( doc => ( doc . key = "world" ) )
316- done ( )
317- } )
318-
319- // todo why do i need to do this? `world` is `document-2` if i don't
320- await testEffect ( done => done ( ) )
312+ await new Promise < void > ( setImmediate )
321313
322- await testEffect ( done => {
323314 expect ( result . getByTestId ( "key-stable" ) . textContent ) . toBe ( "hello" )
324315 expect ( result . getByTestId ( "key-changing" ) . textContent ) . toBe ( "world" )
325316 done ( )
0 commit comments