diff --git a/cypress/components/TableOfContentMarkdown.cy.tsx b/cypress/components/TableOfContentMarkdown.cy.tsx new file mode 100644 index 000000000..5c33ca0ee --- /dev/null +++ b/cypress/components/TableOfContentMarkdown.cy.tsx @@ -0,0 +1,27 @@ +import React from 'react'; +import { TableOfContentMarkdown } from '../../components/TableOfContentMarkdown'; + +describe('TableOfContentMarkdown Component', () => { + it('renders h1 as a link with generated slug', () => { + cy.mount(); + cy.get('a').should('have.attr', 'href', '#hello-world'); + cy.get('a').should('contain', 'Hello World'); + }); + + it('renders h2 with bullet point', () => { + cy.mount(); + cy.get('a').should('have.attr', 'href', '#section-title'); + cy.get('a').should('contain', 'Section Title'); + }); + + it('ignores h3 when depth is 2', () => { + cy.mount(); + cy.get('a').should('not.exist'); + }); + + it('renders h3 when depth is 3', () => { + cy.mount(); + cy.get('a').should('have.attr', 'href', '#sub-section'); + cy.get('a').should('contain', 'Sub Section'); + }); +});