test(examples): add tests for more example pages

This commit is contained in:
Dominik Biedebach
2022-05-11 17:46:30 +02:00
committed by Dominik
parent 0532770170
commit b7f95d638d
15 changed files with 701 additions and 10 deletions

View File

@@ -0,0 +1,38 @@
context('/src/Examples/Formatting/React/', () => {
before(() => {
cy.visit('/src/Examples/Formatting/React/')
})
beforeEach(() => {
cy.get('.ProseMirror').type('{selectall}{backspace}')
})
const marks = [
{ label: 'highlight', mark: 'mark' },
]
marks.forEach(m => {
it(`sets ${m.label}`, () => {
cy.get('.ProseMirror').type('Hello world.{selectall}')
cy.get('button').contains(m.label).click()
cy.get('.ProseMirror mark').should('exist')
})
})
const alignments = [
{ label: 'left', alignment: 'left' },
{ label: 'center', alignment: 'center' },
{ label: 'right', alignment: 'right' },
{ label: 'justify', alignment: 'justify' },
]
alignments.forEach(a => {
it(`sets ${a.label}`, () => {
cy.get('.ProseMirror').type('Hello world.{selectall}')
cy.get('button').contains(a.label).click()
if (a.alignment !== 'left') {
cy.get('.ProseMirror p').should('have.css', 'text-align', a.alignment)
}
})
})
})

View File

@@ -3,5 +3,36 @@ context('/src/Examples/Formatting/Vue/', () => {
cy.visit('/src/Examples/Formatting/Vue/')
})
// TODO: Write tests
beforeEach(() => {
cy.get('.ProseMirror').type('{selectall}{backspace}')
})
const marks = [
{ label: 'highlight', mark: 'mark' },
]
marks.forEach(m => {
it(`sets ${m.label}`, () => {
cy.get('.ProseMirror').type('Hello world.{selectall}')
cy.get('button').contains(m.label).click()
cy.get('.ProseMirror mark').should('exist')
})
})
const alignments = [
{ label: 'left', alignment: 'left' },
{ label: 'center', alignment: 'center' },
{ label: 'right', alignment: 'right' },
{ label: 'justify', alignment: 'justify' },
]
alignments.forEach(a => {
it(`sets ${a.label}`, () => {
cy.get('.ProseMirror').type('Hello world.{selectall}')
cy.get('button').contains(a.label).click()
if (a.alignment !== 'left') {
cy.get('.ProseMirror p').should('have.css', 'text-align', a.alignment)
}
})
})
})