Skip to content

Commit

Permalink
test(extension-link): ✅ add test for autolink validation example in vue
Browse files Browse the repository at this point in the history
  • Loading branch information
bdbch committed May 16, 2022
1 parent 358e315 commit ec41540
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion demos/src/Examples/AutolinkValidation/Vue/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,40 @@ context('/src/Examples/AutolinkValidation/Vue/', () => {
cy.visit('/src/Examples/AutolinkValidation/Vue/')
})

// TODO: Write tests
beforeEach(() => {
cy.get('.ProseMirror').type('{selectall}{backspace}')
})

const validLinks = [
'https://tiptap.dev',
'http://tiptap.dev',
'https://www.tiptap.dev/',
'http://www.tiptap.dev/',
]

const invalidLinks = [
'tiptap.dev',
'www.tiptap.dev',
]

validLinks.forEach(link => {
it(`${link} should get autolinked`, () => {
cy.get('.ProseMirror').type(link)
cy.get('.ProseMirror').should('have.text', link)
cy.get('.ProseMirror')
.find('a')
.should('have.length', 1)
.should('have.attr', 'href', link)
})
})

invalidLinks.forEach(link => {
it(`${link} should NOT get autolinked`, () => {
cy.get('.ProseMirror').type(link)
cy.get('.ProseMirror').should('have.text', link)
cy.get('.ProseMirror')
.find('a')
.should('have.length', 0)
})
})
})

0 comments on commit ec41540

Please sign in to comment.