@@ -17,23 +17,28 @@ const { useResult } = RuntimeProvider.makeFromLayer(Layer.succeed(foo, { value:
1717describe ( "useResult" , ( ) => {
1818 it ( "should run effects" , async ( ) => {
1919 const testEffect = Effect . succeed ( 1 )
20- const { result } = await waitFor ( async ( ) => renderHook ( ( ) => useResult ( ( ) => testEffect , [ ] ) ) )
21- expect ( Result . isSuccess ( result . current . result ) ) . toBe ( true )
20+ const { result } = renderHook ( ( ) => useResult ( ( ) => testEffect , [ ] ) )
21+ expect ( Result . isInitial ( result . current . result ) ) . toBe ( true )
22+ await waitFor ( ( ) => expect ( Result . isSuccess ( result . current . result ) ) . toBe ( true ) )
2223 } )
2324
2425 it ( "should provide context" , async ( ) => {
2526 const testEffect = Effect . map ( foo , ( _ ) => _ . value )
26- const { result } = await waitFor ( async ( ) => renderHook ( ( ) => useResult ( ( ) => testEffect , [ ] ) ) )
27- await waitFor ( ( ) => expect ( Result . isSuccess ( result . current . result ) ) . toBe ( true ) )
28- assert ( Result . isSuccess ( result . current . result ) )
29- expect ( result . current . result . value ) . toBe ( 1 )
27+ const { result } = renderHook ( ( ) => useResult ( ( ) => testEffect , [ ] ) )
28+ expect ( Result . isInitial ( result . current . result ) ) . toBe ( true )
29+ await waitFor ( ( ) => {
30+ assert ( Result . isSuccess ( result . current . result ) )
31+ return expect ( result . current . result . value ) . toBe ( 1 )
32+ } )
3033 } )
3134
3235 it ( "should run streams" , async ( ) => {
3336 const testStream = Stream . succeed ( 1 )
34- const { result } = await waitFor ( async ( ) => renderHook ( ( ) => useResult ( ( ) => testStream , [ ] ) ) )
35- await waitFor ( ( ) => expect ( Result . isSuccess ( result . current . result ) ) . toBe ( true ) )
36- assert ( Result . isSuccess ( result . current . result ) )
37- expect ( result . current . result . value ) . toBe ( 1 )
37+ const { result } = renderHook ( ( ) => useResult ( ( ) => testStream , [ ] ) )
38+ expect ( Result . isInitial ( result . current . result ) ) . toBe ( true )
39+ await waitFor ( ( ) => {
40+ assert ( Result . isSuccess ( result . current . result ) )
41+ return expect ( result . current . result . value ) . toBe ( 1 )
42+ } )
3843 } )
3944} )
0 commit comments