test(extension-link): add test for autolink validation example in vue

This commit is contained in:
Dominik Biedebach 2022-05-13 11:42:04 +02:00 committed by Dominik
parent 358e315921
commit ec4154000d

View File

@ -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)
})
})
})