text-title.client.spec.tsx 1.2 KB

12345678910111213141516171819202122232425262728
  1. // @vitest-environment jsdom
  2. /** The chip title: the file type's sheet, then the name the registry captured. */
  3. import { afterEach, describe, expect, it } from 'vitest'
  4. import { cleanup, render } from '@testing-library/react'
  5. import type { PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
  6. import { TextTitle } from '../src/client/TextTitle.tsx'
  7. afterEach(cleanup)
  8. function props(title: string): PropsRuntime<'sidebar.right.pane.tab.title'> {
  9. return { useTabInfo: () => ({ tab: { title } }) } as unknown as PropsRuntime<'sidebar.right.pane.tab.title'>
  10. }
  11. describe('TextTitle', () => {
  12. it('draws the type sheet before the title text, sized to the chip line', () => {
  13. const { container } = render(<TextTitle {...props('README.md')} />)
  14. const svg = container.querySelector('svg')
  15. expect(svg?.getAttribute('width')).toBe('16')
  16. expect(svg?.getAttribute('aria-hidden')).toBe('true')
  17. expect(container.textContent).toBe('README.md')
  18. })
  19. it('picks the sheet from the title\'s extension', () => {
  20. const markdown = render(<TextTitle {...props('notes.md')} />).container.querySelector('svg')?.innerHTML
  21. const pdf = render(<TextTitle {...props('paper.pdf')} />).container.querySelector('svg')?.innerHTML
  22. expect(markdown).not.toBe(pdf)
  23. })
  24. })