Skip to content

Commit

Permalink
Merge pull request #4639 from ueberdosis/feature/fixMarksLinkTests
Browse files Browse the repository at this point in the history
fixes tests in marks/link
  • Loading branch information
janthurau authored Nov 17, 2023
2 parents 58c78d7 + 4dfd839 commit a383297
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
30 changes: 15 additions & 15 deletions demos/src/Marks/Link/React/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ context('/src/Marks/Link/React/', () => {

beforeEach(() => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.setContent('<p>Example Text</p>')
editor.commands.setContent('<p>Example TextDEFAULT</p>')
cy.get('.tiptap').type('{selectall}')
})
})
Expand All @@ -26,27 +26,27 @@ context('/src/Marks/Link/React/', () => {

it('should parse a tags correctly', () => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.setContent('<p><a href="#">Example Text</a></p>')
editor.commands.setContent('<p><a href="#">Example Text1</a></p>')
expect(editor.getHTML()).to.eq(
'<p><a target="_blank" rel="noopener noreferrer nofollow" href="#">Example Text</a></p>',
'<p><a target="_blank" rel="noopener noreferrer nofollow" href="#">Example Text1</a></p>',
)
})
})

it('should parse a tags with target attribute correctly', () => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.setContent('<p><a href="#" target="_self">Example Text</a></p>')
editor.commands.setContent('<p><a href="#" target="_self">Example Text2</a></p>')
expect(editor.getHTML()).to.eq(
'<p><a target="_self" rel="noopener noreferrer nofollow" href="#">Example Text</a></p>',
'<p><a target="_self" rel="noopener noreferrer nofollow" href="#">Example Text2</a></p>',
)
})
})

it('should parse a tags with rel attribute correctly', () => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.setContent('<p><a href="#" rel="follow">Example Text</a></p>')
editor.commands.setContent('<p><a href="#" rel="follow">Example Text3</a></p>')
expect(editor.getHTML()).to.eq(
'<p><a target="_blank" rel="follow" href="#">Example Text</a></p>',
'<p><a target="_blank" rel="follow" href="#">Example Text3</a></p>',
)
})
})
Expand All @@ -61,35 +61,35 @@ context('/src/Marks/Link/React/', () => {

cy.get('.tiptap')
.find('a')
.should('contain', 'Example Text')
.should('contain', 'Example TextDEFAULT')
.should('have.attr', 'href', 'https://tiptap.dev')
})
})

it('detects a pasted URL within a text', () => {
cy.get('.tiptap')
.paste({
pastePayload: 'some text https://example.com around an url',
pastePayload: 'some text https://example1.com around an url',
pasteType: 'text/plain',
})
.find('a')
.should('contain', 'https://example.com')
.should('have.attr', 'href', 'https://example.com')
.should('contain', 'https://example1.com')
.should('have.attr', 'href', 'https://example1.com')
})

it('detects a pasted URL', () => {
cy.get('.tiptap')
.paste({ pastePayload: 'https://example.com', pasteType: 'text/plain' })
.paste({ pastePayload: 'https://example2.com', pasteType: 'text/plain' })
.find('a')
.should('contain', 'Example Text')
.should('have.attr', 'href', 'https://example.com')
.should('contain', 'https://example2.com')
.should('have.attr', 'href', 'https://example2.com')
})

it('detects a pasted URL with query params', () => {
cy.get('.tiptap')
.paste({ pastePayload: 'https://example.com?paramA=nice&paramB=cool', pasteType: 'text/plain' })
.find('a')
.should('contain', 'Example Text')
.should('contain', 'https://example.com?paramA=nice&paramB=cool')
.should('have.attr', 'href', 'https://example.com?paramA=nice&paramB=cool')
})

Expand Down
30 changes: 15 additions & 15 deletions demos/src/Marks/Link/Vue/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@ context('/src/Marks/Link/Vue/', () => {

beforeEach(() => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.setContent('<p>Example Text</p>')
editor.commands.setContent('<p>Example TextDEFAULT</p>')
cy.get('.tiptap').type('{selectall}')
})
})

it('should parse a tags correctly', () => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.setContent('<p><a href="#">Example Text</a></p>')
expect(editor.getHTML()).to.eq('<p><a target="_blank" rel="noopener noreferrer nofollow" href="#">Example Text</a></p>')
editor.commands.setContent('<p><a href="#">Example Text1</a></p>')
expect(editor.getHTML()).to.eq('<p><a target="_blank" rel="noopener noreferrer nofollow" href="#">Example Text1</a></p>')
})
})

it('should parse a tags with target attribute correctly', () => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.setContent('<p><a href="#" target="_self">Example Text</a></p>')
expect(editor.getHTML()).to.eq('<p><a target="_self" rel="noopener noreferrer nofollow" href="#">Example Text</a></p>')
editor.commands.setContent('<p><a href="#" target="_self">Example Text2</a></p>')
expect(editor.getHTML()).to.eq('<p><a target="_self" rel="noopener noreferrer nofollow" href="#">Example Text2</a></p>')
})
})

it('should parse a tags with rel attribute correctly', () => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.setContent('<p><a href="#" rel="follow">Example Text</a></p>')
expect(editor.getHTML()).to.eq('<p><a target="_blank" rel="follow" href="#">Example Text</a></p>')
editor.commands.setContent('<p><a href="#" rel="follow">Example Text3</a></p>')
expect(editor.getHTML()).to.eq('<p><a target="_blank" rel="follow" href="#">Example Text3</a></p>')
})
})

Expand All @@ -42,30 +42,30 @@ context('/src/Marks/Link/Vue/', () => {

cy.get('.tiptap')
.find('a')
.should('contain', 'Example Text')
.should('contain', 'Example TextDEFAULT')
.should('have.attr', 'href', 'https://tiptap.dev')
})
})

it('detects a pasted URL within a text', () => {
cy.get('.tiptap').paste({ pastePayload: 'some text https://example.com around an url', pasteType: 'text/plain' })
cy.get('.tiptap').paste({ pastePayload: 'some text https://example1.com around an url', pasteType: 'text/plain' })
.find('a')
.should('contain', 'https://example.com')
.should('have.attr', 'href', 'https://example.com')
.should('contain', 'https://example1.com')
.should('have.attr', 'href', 'https://example1.com')
})

it('detects a pasted URL', () => {
cy.get('.tiptap').paste({ pastePayload: 'https://example.com', pasteType: 'text/plain' })
cy.get('.tiptap').paste({ pastePayload: 'https://example2.com', pasteType: 'text/plain' })
.find('a')
.should('contain', 'Example Text')
.should('have.attr', 'href', 'https://example.com')
.should('contain', 'https://example2.com')
.should('have.attr', 'href', 'https://example2.com')
})

it('detects a pasted URL with query params', () => {
cy.get('.tiptap')
.paste({ pastePayload: 'https://example.com?paramA=nice&paramB=cool', pasteType: 'text/plain' })
.find('a')
.should('contain', 'Example Text')
.should('contain', 'https://example.com?paramA=nice&paramB=cool')
.should('have.attr', 'href', 'https://example.com?paramA=nice&paramB=cool')
})

Expand Down

0 comments on commit a383297

Please sign in to comment.