refactoring
This commit is contained in:
@@ -5,8 +5,11 @@ context('/api/marks/highlight', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.get('.ProseMirror').then(([{ editor }]) => {
|
cy.get('.ProseMirror').then(([{ editor }]) => {
|
||||||
editor.setContent('<p>Example Text</p>')
|
editor
|
||||||
editor.selectAll()
|
.chain()
|
||||||
|
.setContent('<p>Example Text</p>')
|
||||||
|
.selectAll()
|
||||||
|
.run()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -47,25 +50,26 @@ context('/api/marks/highlight', () => {
|
|||||||
|
|
||||||
it('should remove existing marks with the same attributes', () => {
|
it('should remove existing marks with the same attributes', () => {
|
||||||
cy.get('.ProseMirror').then(([{ editor }]) => {
|
cy.get('.ProseMirror').then(([{ editor }]) => {
|
||||||
editor.setContent('<p><mark style="background-color: rgb(255, 0, 0);">Example Text</mark></p>')
|
editor
|
||||||
editor.selectAll()
|
.chain()
|
||||||
|
.setContent('<p><mark style="background-color: rgb(255, 0, 0);">Example Text</mark></p>')
|
||||||
editor.highlight({ color: 'rgb(255, 0, 0)' })
|
.selectAll()
|
||||||
|
.highlight({ color: 'rgb(255, 0, 0)' })
|
||||||
|
.run()
|
||||||
|
|
||||||
cy.get('.ProseMirror')
|
cy.get('.ProseMirror')
|
||||||
.find('mark')
|
.find('mark')
|
||||||
.should('not.exist')
|
.should('not.exist')
|
||||||
|
|
||||||
editor.isActive('highlight', {
|
|
||||||
color: 'rgb(255, 0, 0)',
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('is active for mark with any attributes', () => {
|
it('is active for mark with any attributes', () => {
|
||||||
cy.get('.ProseMirror').then(([{ editor }]) => {
|
cy.get('.ProseMirror').then(([{ editor }]) => {
|
||||||
editor.setContent('<p><mark data-color="red">Example Text</mark></p>')
|
editor
|
||||||
editor.selectAll()
|
.chain()
|
||||||
|
.setContent('<p><mark data-color="red">Example Text</mark></p>')
|
||||||
|
.selectAll()
|
||||||
|
.run()
|
||||||
|
|
||||||
expect(editor.isActive('highlight')).to.eq(true)
|
expect(editor.isActive('highlight')).to.eq(true)
|
||||||
})
|
})
|
||||||
@@ -73,23 +77,33 @@ context('/api/marks/highlight', () => {
|
|||||||
|
|
||||||
it('is active for mark with same attributes', () => {
|
it('is active for mark with same attributes', () => {
|
||||||
cy.get('.ProseMirror').then(([{ editor }]) => {
|
cy.get('.ProseMirror').then(([{ editor }]) => {
|
||||||
editor.setContent('<p><mark style="background-color: rgb(255, 0, 0);">Example Text</mark></p>')
|
editor
|
||||||
editor.selectAll()
|
.chain()
|
||||||
|
.setContent('<p><mark style="background-color: rgb(255, 0, 0);">Example Text</mark></p>')
|
||||||
|
.selectAll()
|
||||||
|
.run()
|
||||||
|
|
||||||
expect(editor.isActive('highlight', {
|
const isActive = editor.isActive('highlight', {
|
||||||
color: 'rgb(255, 0, 0)',
|
color: 'rgb(255, 0, 0)',
|
||||||
})).to.eq(true)
|
})
|
||||||
|
|
||||||
|
expect(isActive).to.eq(true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('isn’t active for mark with other attributes', () => {
|
it('isn’t active for mark with other attributes', () => {
|
||||||
cy.get('.ProseMirror').then(([{ editor }]) => {
|
cy.get('.ProseMirror').then(([{ editor }]) => {
|
||||||
editor.setContent('<p><mark style="background-color: rgb(255, 0, 0);">Example Text</mark></p>')
|
editor
|
||||||
editor.selectAll()
|
.chain()
|
||||||
|
.setContent('<p><mark style="background-color: rgb(255, 0, 0);">Example Text</mark></p>')
|
||||||
|
.selectAll()
|
||||||
|
.run()
|
||||||
|
|
||||||
expect(editor.isActive('highlight', {
|
const isActive = editor.isActive('highlight', {
|
||||||
color: 'rgb(0, 0, 0)',
|
color: 'rgb(0, 0, 0)',
|
||||||
})).to.eq(false)
|
})
|
||||||
|
|
||||||
|
expect(isActive).to.eq(false)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user