outline-list.test.js 1.2 KB

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