Download next.js/test/unit/getDisplayName.test.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 832 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/unit/getDisplayName.test.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/unit/getDisplayName.test.ts
-
curl -L -o getDisplayName.test.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/unit/getDisplayName.test.ts
832 Bytes
| /* eslint-env jest */ | |
| import { Component } from 'react' | |
| import { getDisplayName } from 'next/dist/shared/lib/utils' | |
| describe('getDisplayName', () => { | |
| it('gets the proper display name of a component', () => { | |
| class ComponentOne extends Component { | |
| render() { | |
| return null | |
| } | |
| } | |
| class ComponentTwo extends Component { | |
| static displayName = 'CustomDisplayName' | |
| render() { | |
| return null | |
| } | |
| } | |
| function FunctionalComponent() { | |
| return null | |
| } | |
| expect(getDisplayName(ComponentOne)).toBe('ComponentOne') | |
| expect(getDisplayName(ComponentTwo)).toBe('CustomDisplayName') | |
| expect(getDisplayName(FunctionalComponent)).toBe('FunctionalComponent') | |
| expect(getDisplayName(() => null)).toBe('Unknown') | |
| expect(getDisplayName('div' as any)).toBe('div') | |
| }) | |
| }) | |