@@ -115,8 +115,8 @@ function setupMockClipboard(isSecure: boolean): SetupMockClipboardResult {
115
115
} ;
116
116
}
117
117
118
- function renderUseClipboard < TInput extends UseClipboardInput > ( inputs : TInput ) {
119
- return renderHook < UseClipboardResult , TInput > (
118
+ function renderUseClipboard ( inputs ?: UseClipboardInput ) {
119
+ return renderHook < UseClipboardResult , UseClipboardInput > (
120
120
( props ) => useClipboard ( props ) ,
121
121
{
122
122
initialProps :inputs ,
@@ -188,9 +188,9 @@ describe.each(secureContextValues)("useClipboard - secure: %j", (isSecure) => {
188
188
189
189
const assertClipboardUpdateLifecycle = async (
190
190
result :RenderResult ,
191
- textToCheck :string ,
191
+ textToCopy :string ,
192
192
) :Promise < void > => {
193
- await act ( ( ) => result . current . copyToClipboard ( ) ) ;
193
+ await act ( ( ) => result . current . copyToClipboard ( textToCopy ) ) ;
194
194
expect ( result . current . showCopiedSuccess ) . toBe ( true ) ;
195
195
196
196
// Because of timing trickery, any timeouts for flipping the copy status
@@ -203,35 +203,35 @@ describe.each(secureContextValues)("useClipboard - secure: %j", (isSecure) => {
203
203
await act ( ( ) => jest . runAllTimersAsync ( ) ) ;
204
204
205
205
const clipboardText = getClipboardText ( ) ;
206
- expect ( clipboardText ) . toEqual ( textToCheck ) ;
206
+ expect ( clipboardText ) . toEqual ( textToCopy ) ;
207
207
} ;
208
208
209
209
it ( "Copies the current text to the user's clipboard" , async ( ) => {
210
210
const textToCopy = "dogs" ;
211
- const { result} = renderUseClipboard ( { textToCopy } ) ;
211
+ const { result} = renderUseClipboard ( ) ;
212
212
await assertClipboardUpdateLifecycle ( result , textToCopy ) ;
213
213
} ) ;
214
214
215
215
it ( "Should indicate to components not to show successful copy after a set period of time" , async ( ) => {
216
216
const textToCopy = "cats" ;
217
- const { result} = renderUseClipboard ( { textToCopy } ) ;
217
+ const { result} = renderUseClipboard ( ) ;
218
218
await assertClipboardUpdateLifecycle ( result , textToCopy ) ;
219
219
expect ( result . current . showCopiedSuccess ) . toBe ( false ) ;
220
220
} ) ;
221
221
222
222
it ( "Should notify the user of an error using the provided callback" , async ( ) => {
223
223
const textToCopy = "birds" ;
224
224
const onError = jest . fn ( ) ;
225
- const { result} = renderUseClipboard ( { textToCopy , onError} ) ;
225
+ const { result} = renderUseClipboard ( { onError} ) ;
226
226
227
227
setSimulateFailure ( true ) ;
228
- await act ( ( ) => result . current . copyToClipboard ( ) ) ;
228
+ await act ( ( ) => result . current . copyToClipboard ( textToCopy ) ) ;
229
229
expect ( onError ) . toBeCalled ( ) ;
230
230
} ) ;
231
231
232
232
it ( "Should dispatch a new toast message to the global snackbar when errors happen while no error callback is provided to the hook" , async ( ) => {
233
233
const textToCopy = "crow" ;
234
- const { result} = renderUseClipboard ( { textToCopy } ) ;
234
+ const { result} = renderUseClipboard ( ) ;
235
235
236
236
/**
237
237
*@todo Look into why deferring error-based state updates to the global
@@ -241,7 +241,7 @@ describe.each(secureContextValues)("useClipboard - secure: %j", (isSecure) => {
241
241
* flushed through the GlobalSnackbar component afterwards
242
242
*/
243
243
setSimulateFailure ( true ) ;
244
- await act ( ( ) => result . current . copyToClipboard ( ) ) ;
244
+ await act ( ( ) => result . current . copyToClipboard ( textToCopy ) ) ;
245
245
246
246
const errorMessageNode = screen . queryByText ( COPY_FAILED_MESSAGE ) ;
247
247
expect ( errorMessageNode ) . not . toBeNull ( ) ;
@@ -252,10 +252,10 @@ describe.each(secureContextValues)("useClipboard - secure: %j", (isSecure) => {
252
252
// Snackbar state transitions that you might get if the hook uses the
253
253
// default
254
254
const textToCopy = "hamster" ;
255
- const { result} = renderUseClipboard ( { textToCopy , onError :jest . fn ( ) } ) ;
255
+ const { result} = renderUseClipboard ( { onError :jest . fn ( ) } ) ;
256
256
257
257
setSimulateFailure ( true ) ;
258
- await act ( ( ) => result . current . copyToClipboard ( ) ) ;
258
+ await act ( ( ) => result . current . copyToClipboard ( textToCopy ) ) ;
259
259
260
260
expect ( result . current . error ) . toBeInstanceOf ( Error ) ;
261
261
} ) ;