outline-list.test.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { screen, render } from '@testing-library/react'
  2. import OutlineList from '../../../../../frontend/js/features/outline/components/outline-list'
  3. describe('<OutlineList />', function () {
  4. const jumpToLine = () => {}
  5. it('renders items', function () {
  6. const outline = [
  7. {
  8. title: 'Section 1',
  9. line: 1,
  10. level: 10,
  11. },
  12. {
  13. title: 'Section 2',
  14. line: 2,
  15. level: 10,
  16. },
  17. ]
  18. render(<OutlineList outline={outline} isRoot jumpToLine={jumpToLine} />)
  19. screen.getByRole('treeitem', { name: 'Section 1' })
  20. screen.getByRole('treeitem', { name: 'Section 2' })
  21. })
  22. it('renders as root', function () {
  23. const outline = [
  24. {
  25. title: 'Section',
  26. line: 1,
  27. level: 10,
  28. },
  29. ]
  30. render(<OutlineList outline={outline} isRoot jumpToLine={jumpToLine} />)
  31. screen.getByRole('tree')
  32. })
  33. it('renders as non-root', function () {
  34. const outline = [
  35. {
  36. title: 'Section',
  37. line: 1,
  38. level: 10,
  39. },
  40. ]
  41. render(<OutlineList outline={outline} jumpToLine={jumpToLine} />)
  42. screen.getByRole('group')
  43. })
  44. })