|
1 |
| -import { act, renderHook } from "@testing-library/react"; |
| 1 | +import { act, renderHook, screen } from "@testing-library/react"; |
2 | 2 | import { GlobalSnackbar } from "components/GlobalSnackbar/GlobalSnackbar";
|
3 | 3 | import { ThemeProvider } from "contexts/ThemeProvider";
|
4 | 4 | import {
|
@@ -166,8 +166,8 @@ describe.each(secureContextValues)("useClipboard - secure: %j", (isSecure) => {
|
166 | 166 | // Because of timing trickery, any timeouts for flipping the copy status
|
167 | 167 | // back to false will trigger before the test can complete. This will never
|
168 | 168 | // be an issue in the real world, but it will kick up 'act' warnings in the
|
169 |
| - // console, which makes tests more annoying. Just wait for them to finish up |
170 |
| - // to avoid anything from being logged, but note that the value of |
| 169 | + // console, which makes tests more annoying. Just waiting for them to finish |
| 170 | + // up to avoid anything from being logged, but note that the value of |
171 | 171 | // showCopiedSuccess will become false after this
|
172 | 172 | await act(() => jest.runAllTimersAsync());
|
173 | 173 |
|
@@ -198,7 +198,14 @@ describe.each(secureContextValues)("useClipboard - secure: %j", (isSecure) => {
|
198 | 198 | expect(onError).toBeCalled();
|
199 | 199 | });
|
200 | 200 |
|
201 |
| - it.skip("Should dispatch a new toast message to the global snackbar if no callback is provided", async () => { |
202 |
| - expect.hasAssertions(); |
| 201 | + it("Should dispatch a new toast message to the global snackbar if no callback is provided", async () => { |
| 202 | + const textToCopy = "crow"; |
| 203 | + const { result } = renderUseClipboard({ textToCopy }); |
| 204 | + |
| 205 | + setSimulateFailure(true); |
| 206 | + await act(() => result.current.copyToClipboard()); |
| 207 | + |
| 208 | + const errorMessageNode = screen.queryByText(COPY_FAILED_MESSAGE); |
| 209 | + expect(errorMessageNode).not.toBeNull(); |
203 | 210 | });
|
204 | 211 | });
|
0 commit comments