Download next.js/test/unit/link-warnings.test.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 819 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/unit/link-warnings.test.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/unit/link-warnings.test.tsx
-
curl -L -o link-warnings.test.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/unit/link-warnings.test.tsx
819 Bytes
| /** | |
| * @jest-environment jsdom | |
| */ | |
| import { act, render } from '@testing-library/react' | |
| import '@testing-library/jest-dom' | |
| import Link from 'next/link' | |
| import React from 'react' | |
| describe('<Link/>', () => { | |
| let spy | |
| let expectedErrors | |
| beforeAll(async () => { | |
| spy = jest.spyOn(console, 'error').mockImplementation((...args) => { | |
| console.log(...args) | |
| }) | |
| expectedErrors = 0 | |
| }) | |
| it('test link with unmount', () => { | |
| act(() => { | |
| const { unmount } = render(<Link href="/">hello</Link>) | |
| unmount() | |
| }) | |
| expect(spy).toHaveBeenCalledTimes(expectedErrors) | |
| }) | |
| it('test link without unmount', () => { | |
| act(() => { | |
| render(<Link href="/">hello</Link>) | |
| }) | |
| expect(spy).toHaveBeenCalledTimes(expectedErrors) | |
| }) | |
| afterAll(() => { | |
| spy.mockRestore() | |
| }) | |
| }) | |