Skip to content

Commit 65910c1

Browse files
committed
docs: fix typos
1 parent caf1222 commit 65910c1

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

site/src/hooks/useClipboard.test.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
*
55
* When you call user.setup to make a new user session, it will make a mock
66
* clipboard instance that will always succeed. It also can't be removed after
7-
* it's been added. This actually makes testing useClipboard impossible to test
8-
* properly because any call to user.setup immediately pollutes the tests with
9-
* false negatives. Even if something should fail, it won't.
7+
* it's been added, and it will persist across test cases. This actually makes
8+
* testing useClipboard properly impossible because any call to user.setup
9+
* immediately pollutes the tests with false negatives. Even if something should
10+
* fail, it won't.
1011
*/
1112
import { act, renderHook, screen } from "@testing-library/react";
1213
import { GlobalSnackbar } from "components/GlobalSnackbar/GlobalSnackbar";
@@ -218,8 +219,9 @@ describe.each(secureContextValues)("useClipboard - secure: %j", (isSecure) => {
218219

219220
/**
220221
* @todo Look into why deferring error-based state updates to the global
221-
* snackbar still kicks up act warnings, even after using act for the main
222-
* source of the state transition
222+
* snackbar still kicks up act warnings, even after wrapping copyToClipboard
223+
* in act. copyToClipboard should be the main source of the state
224+
* transitions,
223225
*/
224226
setSimulateFailure(true);
225227
await act(() => result.current.copyToClipboard());
@@ -228,12 +230,12 @@ describe.each(secureContextValues)("useClipboard - secure: %j", (isSecure) => {
228230
expect(errorMessageNode).not.toBeNull();
229231
});
230232

231-
it("Should expose the error value for render logic when a copy fails", async () => {
232-
// Using empty error callback to silence any possible act warnings from
233-
// Snackbar state transitions
234-
const onError = jest.fn();
233+
it("Should expose the error as a value when a copy fails", async () => {
234+
// Using empty onError callback to silence any possible act warnings from
235+
// Snackbar state transitions that you might get if the hook uses the
236+
// default
235237
const textToCopy = "hamster";
236-
const { result } = renderUseClipboard({ textToCopy, onError });
238+
const { result } = renderUseClipboard({ textToCopy, onError: jest.fn() });
237239

238240
setSimulateFailure(true);
239241
await act(() => result.current.copyToClipboard());

0 commit comments

Comments
 (0)