Skip to content

Commit

Permalink
fix(tests): fix autolink validation test
Browse files Browse the repository at this point in the history
  • Loading branch information
bdbch committed Nov 25, 2022
1 parent 4d7f05a commit 5150095
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 30 deletions.
23 changes: 8 additions & 15 deletions demos/src/Examples/AutolinkValidation/React/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,17 @@ context('/src/Examples/AutolinkValidation/React/', () => {
'https://tiptap.dev',
]

validLinks.forEach(link => {
it(`${link[0]} should get autolinked`, () => {
cy.get('.ProseMirror').type(link[0])
cy.get('.ProseMirror').should('have.text', link[0])
cy.get('.ProseMirror')
.find('a')
.should('have.length', 1)
.should('have.attr', 'href', link[1])
it('valid links should get autolinked', () => {
validLinks.forEach(([rawTextInput, textThatShouldBeLinked]) => {
cy.get('.ProseMirror').type(`{selectall}{backspace}${rawTextInput}`)
cy.get('.ProseMirror a').contains(textThatShouldBeLinked)
})
})

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)
it('invalid links should not get autolinked', () => {
invalidLinks.forEach(rawTextInput => {
cy.get('.ProseMirror').type(`{selectall}{backspace}${rawTextInput}`)
cy.get('.ProseMirror a').should('not.exist')
})
})

Expand Down
23 changes: 8 additions & 15 deletions demos/src/Examples/AutolinkValidation/Vue/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,17 @@ context('/src/Examples/AutolinkValidation/Vue/', () => {
'https://tiptap.dev',
]

validLinks.forEach(link => {
it(`${link[0]} should get autolinked`, () => {
cy.get('.ProseMirror').type(link[0])
cy.get('.ProseMirror').should('have.text', link[0])
cy.get('.ProseMirror')
.find('a')
.should('have.length', 1)
.should('have.attr', 'href', link[1])
it('valid links should get autolinked', () => {
validLinks.forEach(([rawTextInput, textThatShouldBeLinked]) => {
cy.get('.ProseMirror').type(`{selectall}{backspace}${rawTextInput}`)
cy.get('.ProseMirror a').contains(textThatShouldBeLinked)
})
})

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)
it('invalid links should not get autolinked', () => {
invalidLinks.forEach(rawTextInput => {
cy.get('.ProseMirror').type(`{selectall}{backspace}${rawTextInput}`)
cy.get('.ProseMirror a').should('not.exist')
})
})
})

0 comments on commit 5150095

Please sign in to comment.