@@ -117,21 +117,21 @@ test("re-runs the promise when the value of 'watch' changes", () => {
117117 expect ( promiseFn ) . toHaveBeenCalledTimes ( 3 )
118118} )
119119
120- test ( "runs deferFn only when explicitly invoked, passing arguments" , ( ) => {
120+ test ( "runs deferFn only when explicitly invoked, passing arguments and props " , ( ) => {
121121 let counter = 1
122122 const deferFn = jest . fn ( ) . mockReturnValue ( resolveTo ( ) )
123123 const { getByText } = render (
124- < Async deferFn = { deferFn } >
124+ < Async deferFn = { deferFn } foo = "bar" >
125125 { ( { run } ) => {
126126 return < button onClick = { ( ) => run ( "go" , counter ++ ) } > run</ button >
127127 } }
128128 </ Async >
129129 )
130130 expect ( deferFn ) . not . toHaveBeenCalled ( )
131131 fireEvent . click ( getByText ( "run" ) )
132- expect ( deferFn ) . toHaveBeenCalledWith ( "go" , 1 )
132+ expect ( deferFn ) . toHaveBeenCalledWith ( "go" , 1 , expect . objectContaining ( { deferFn , foo : "bar" } ) )
133133 fireEvent . click ( getByText ( "run" ) )
134- expect ( deferFn ) . toHaveBeenCalledWith ( "go" , 2 )
134+ expect ( deferFn ) . toHaveBeenCalledWith ( "go" , 2 , expect . objectContaining ( { deferFn , foo : "bar" } ) )
135135} )
136136
137137test ( "reload uses the arguments of the previous run" , ( ) => {
@@ -151,11 +151,11 @@ test("reload uses the arguments of the previous run", () => {
151151 )
152152 expect ( deferFn ) . not . toHaveBeenCalled ( )
153153 fireEvent . click ( getByText ( "run" ) )
154- expect ( deferFn ) . toHaveBeenCalledWith ( "go" , 1 )
154+ expect ( deferFn ) . toHaveBeenCalledWith ( "go" , 1 , expect . objectContaining ( { deferFn } ) )
155155 fireEvent . click ( getByText ( "run" ) )
156- expect ( deferFn ) . toHaveBeenCalledWith ( "go" , 2 )
156+ expect ( deferFn ) . toHaveBeenCalledWith ( "go" , 2 , expect . objectContaining ( { deferFn } ) )
157157 fireEvent . click ( getByText ( "reload" ) )
158- expect ( deferFn ) . toHaveBeenCalledWith ( "go" , 2 )
158+ expect ( deferFn ) . toHaveBeenCalledWith ( "go" , 2 , expect . objectContaining ( { deferFn } ) )
159159} )
160160
161161test ( "only accepts the last invocation of the promise" , async ( ) => {
0 commit comments