Skip to content

Commit

Permalink
test: add e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorlxy committed Dec 12, 2023
1 parent 0e626b9 commit 65d1645
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions e2e/docs/markdown/anchors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# title

## anchor 1

### anchor 1-1
26 changes: 26 additions & 0 deletions e2e/tests/markdown/anchors.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
describe('markdown > anchors', () => {
it('should render anchors and navigate correctly', () => {
cy.visit('/markdown/anchors.html')

cy.get('.e2e-theme-content h1')
.should('have.attr', 'id', 'title')
.should('have.attr', 'tabindex', '-1')

cy.get('.e2e-theme-content h1 > a')
.should('have.attr', 'class', 'header-anchor')
.should('have.attr', 'href', '#title')
.click()

cy.location().should((location) => {
expect(location.hash).to.eq('#title')
})

cy.get('#anchor-1-1 > a')
.should('have.attr', 'class', 'header-anchor')
.click()

cy.location().should((location) => {
expect(location.hash).to.eq('#anchor-1-1')
})
})
})

0 comments on commit 65d1645

Please sign in to comment.