@@ -117,21 +117,21 @@ test("re-runs the promise when the value of 'watch' changes", () => {
117
117
expect ( promiseFn ) . toHaveBeenCalledTimes ( 3 )
118
118
} )
119
119
120
- test ( "runs deferFn only when explicitly invoked, passing arguments" , ( ) => {
120
+ test ( "runs deferFn only when explicitly invoked, passing arguments and props " , ( ) => {
121
121
let counter = 1
122
122
const deferFn = jest . fn ( ) . mockReturnValue ( resolveTo ( ) )
123
123
const { getByText } = render (
124
- < Async deferFn = { deferFn } >
124
+ < Async deferFn = { deferFn } foo = "bar" >
125
125
{ ( { run } ) => {
126
126
return < button onClick = { ( ) => run ( "go" , counter ++ ) } > run</ button >
127
127
} }
128
128
</ Async >
129
129
)
130
130
expect ( deferFn ) . not . toHaveBeenCalled ( )
131
131
fireEvent . click ( getByText ( "run" ) )
132
- expect ( deferFn ) . toHaveBeenCalledWith ( "go" , 1 )
132
+ expect ( deferFn ) . toHaveBeenCalledWith ( "go" , 1 , expect . objectContaining ( { deferFn , foo : "bar" } ) )
133
133
fireEvent . click ( getByText ( "run" ) )
134
- expect ( deferFn ) . toHaveBeenCalledWith ( "go" , 2 )
134
+ expect ( deferFn ) . toHaveBeenCalledWith ( "go" , 2 , expect . objectContaining ( { deferFn , foo : "bar" } ) )
135
135
} )
136
136
137
137
test ( "reload uses the arguments of the previous run" , ( ) => {
@@ -151,11 +151,11 @@ test("reload uses the arguments of the previous run", () => {
151
151
)
152
152
expect ( deferFn ) . not . toHaveBeenCalled ( )
153
153
fireEvent . click ( getByText ( "run" ) )
154
- expect ( deferFn ) . toHaveBeenCalledWith ( "go" , 1 )
154
+ expect ( deferFn ) . toHaveBeenCalledWith ( "go" , 1 , expect . objectContaining ( { deferFn } ) )
155
155
fireEvent . click ( getByText ( "run" ) )
156
- expect ( deferFn ) . toHaveBeenCalledWith ( "go" , 2 )
156
+ expect ( deferFn ) . toHaveBeenCalledWith ( "go" , 2 , expect . objectContaining ( { deferFn } ) )
157
157
fireEvent . click ( getByText ( "reload" ) )
158
- expect ( deferFn ) . toHaveBeenCalledWith ( "go" , 2 )
158
+ expect ( deferFn ) . toHaveBeenCalledWith ( "go" , 2 , expect . objectContaining ( { deferFn } ) )
159
159
} )
160
160
161
161
test ( "only accepts the last invocation of the promise" , async ( ) => {
0 commit comments