Download desktop/src/components/chat/CodeViewer.test.tsx from chenbhao/codev: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/chenbhao/codev/resolve/e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/components/chat/CodeViewer.test.tsx
- Command line
-
hf download hf://chenbhao/codev@e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/components/chat/CodeViewer.test.tsx
-
curl -L -o CodeViewer.test.tsx https://huggingface.co/chenbhao/codev/resolve/e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/components/chat/CodeViewer.test.tsx
1.13 kB
| import { render, screen } from '@testing-library/react' | |
| import { describe, expect, it } from 'vitest' | |
| import { CodeViewer } from './CodeViewer' | |
| describe('CodeViewer', () => { | |
| it('keeps the same inner padding for highlighted code content', () => { | |
| const { container } = render( | |
| <CodeViewer code={'cd testb\nnpm run dev'} language="bash" showLineNumbers />, | |
| ) | |
| expect(screen.getByText('cd testb')).toBeTruthy() | |
| expect(screen.getByText('npm run dev')).toBeTruthy() | |
| const contentWrapper = container.querySelector('[data-code-viewer-content]') as HTMLElement | null | |
| expect(contentWrapper).toBeTruthy() | |
| expect(contentWrapper?.style.padding).toBe('0.5rem 12px') | |
| expect(contentWrapper?.style.whiteSpace).toBe('pre') | |
| expect(contentWrapper?.style.wordBreak).toBe('normal') | |
| const codeArea = container.querySelector('.code-viewer-area') as HTMLElement | null | |
| expect(codeArea?.getAttribute('data-has-line-numbers')).toBe('true') | |
| expect(container.querySelector('[data-line-number="1"]')).toBeTruthy() | |
| expect(container.querySelector('[data-line-number="2"]')).toBeTruthy() | |
| }) | |
| }) | |