multiple-levels-outline.test.ts 801 B

123456789101112131415161718192021222324252627282930313233343536
  1. describe('outline', () => {
  2. beforeAll(async () => {
  3. await goto('/frontmatter/multiple-levels-outline')
  4. })
  5. test('set outline to deep', async () => {
  6. const outlineLinksLocator = page.locator('.VPDocAsideOutline .outline-link')
  7. const outlineLinksContent = await outlineLinksLocator.allTextContents()
  8. expect(outlineLinksContent).toEqual([
  9. 'h2 - 1',
  10. 'h3 - 1',
  11. 'h4 - 1',
  12. 'h3 - 2',
  13. 'h4 - 2',
  14. 'h2 - 2',
  15. 'h3 - 3',
  16. 'h4 - 3'
  17. ])
  18. const linkHrefs = await outlineLinksLocator.evaluateAll((element) =>
  19. element.map((element) => element.getAttribute('href'))
  20. )
  21. expect(linkHrefs).toEqual([
  22. '#h2-1',
  23. '#h3-1',
  24. '#h4-1',
  25. '#h3-2',
  26. '#h4-2',
  27. '#h2-2',
  28. '#h3-3',
  29. '#h4-3'
  30. ])
  31. })
  32. })