Skip to content

Commit

Permalink
test: update svelte tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nperez0111 committed Jan 21, 2025
1 parent 8136b1c commit f964e4e
Showing 1 changed file with 70 additions and 17 deletions.
87 changes: 70 additions & 17 deletions demos/src/Examples/Default/Svelte/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
context('/src/Examples/Default/React/', () => {
context('/src/Examples/Default/Svelte/', () => {
beforeEach(() => {
cy.visit('/src/Examples/Default/React/')
})
cy.visit('/src/Examples/Default/Svelte/')

beforeEach(() => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.setContent('<h1>Example Text</h1>')
cy.get('.tiptap').type('{selectall}')
Expand All @@ -25,11 +23,46 @@ context('/src/Examples/Default/React/', () => {
{ label: 'Strike', tag: 's' },
]

buttonMarks.forEach(m => {
it(`should apply ${m.label} when the button is pressed`, () => {
it(`should disable bold, italic, strike when the code tag is enabled for cursor`, () => {
buttonMarks.forEach(m => {
cy.get('.tiptap').type('{selectall}Hello world')
cy.get('button').contains('Code').click()
cy.get('button').contains(m.label).should('be.disabled')
})
})

it(`should enable bold, italic, strike when the code tag is disabled for cursor`, () => {
buttonMarks.forEach(m => {
cy.get('.tiptap').type('{selectall}Hello world')
cy.get('button').contains('Code').click()
cy.get('button').contains('Code').click()
cy.get('button').contains(m.label).should('not.be.disabled')
})
})

it(`should disable bold, italic, strike when the code tag is enabled for selection`, () => {
buttonMarks.forEach(m => {
cy.get('.tiptap').type('{selectall}{backspace}')
cy.get('.tiptap').type('{selectall}Hello world{selectall}')
cy.get('button').contains('Code').click()
cy.get('button').contains(m.label).should('be.disabled')
})
})

it(`should enable bold, italic, strike when the code tag is disabled for selection`, () => {
buttonMarks.forEach(m => {
cy.get('.tiptap').type('{selectall}Hello world{selectall}')
cy.get('button').contains('Code').click()
cy.get('button').contains('Code').click()
cy.get('button').contains(m.label).should('not.be.disabled')
})
})

it(`should apply bold, italic, strike when the button is pressed`, () => {
buttonMarks.forEach(m => {
cy.get('.tiptap').type('{selectall}{backspace}')
cy.get('.tiptap').type('{selectall}Hello world{selectall}')
cy.get('button').contains('Paragraph').click()
cy.get('.tiptap').type('{selectall}')
cy.get('button').contains(m.label).click()
cy.get(`.tiptap ${m.tag}`).should('exist').should('have.text', 'Hello world')
})
Expand Down Expand Up @@ -68,8 +101,8 @@ context('/src/Examples/Default/React/', () => {
{ label: 'Blockquote', tag: 'blockquote' },
]

buttonNodes.forEach(n => {
it(`should set ${n.label} when the button is pressed`, () => {
it(`should set the correct type when the button is pressed`, () => {
buttonNodes.forEach(n => {
cy.get('button').contains('Paragraph').click()
cy.get('.tiptap').type('{selectall}Hello world{selectall}')

Expand Down Expand Up @@ -101,16 +134,36 @@ context('/src/Examples/Default/React/', () => {
})

it('should undo', () => {
cy.get('.tiptap').type('{selectall}{backspace}')
cy.get('button').contains('Undo').click()
cy.get('.tiptap').should('contain', 'Example Text')
cy.get('.tiptap')
.then(([{ editor }]) => {
editor.commands.setContent('<h1>Example Text</h1>')

cy.get('.tiptap').type('{selectall}{backspace}')
return new Promise(resolve => {
setTimeout(resolve, 500)
})
})
.then(() => {
cy.get('button').contains('Undo').click()
cy.get('.tiptap').should('contain', 'Example Text')
})
})

it('should redo', () => {
cy.get('.tiptap').type('{selectall}{backspace}')
cy.get('button').contains('Undo').click()
cy.get('.tiptap').should('contain', 'Example Text')
cy.get('button').contains('Redo').click()
cy.get('.tiptap').should('not.contain', 'Example Text')
cy.get('.tiptap')
.then(([{ editor }]) => {
editor.commands.setContent('<h1>Example Text</h1>')

return new Promise(resolve => {
setTimeout(resolve, 500)
})
})
.then(() => {
cy.get('.tiptap').type('{selectall}{backspace}')
cy.get('button').contains('Undo').click()
cy.get('.tiptap').should('contain', 'Example Text')
cy.get('button').contains('Redo').click()
cy.get('.tiptap').should('not.contain', 'Example Text')
})
})
})

0 comments on commit f964e4e

Please sign in to comment.