From bdb90403ebd02fef13527a3ae51eecfa7bb3580a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Fri, 6 Nov 2020 14:27:43 +0100 Subject: [PATCH] refactoring --- docs/src/demos/Marks/Highlight/index.spec.js | 54 ++++++++++++-------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/docs/src/demos/Marks/Highlight/index.spec.js b/docs/src/demos/Marks/Highlight/index.spec.js index 4690a893..fef5e42d 100644 --- a/docs/src/demos/Marks/Highlight/index.spec.js +++ b/docs/src/demos/Marks/Highlight/index.spec.js @@ -5,8 +5,11 @@ context('/api/marks/highlight', () => { beforeEach(() => { cy.get('.ProseMirror').then(([{ editor }]) => { - editor.setContent('

Example Text

') - editor.selectAll() + editor + .chain() + .setContent('

Example Text

') + .selectAll() + .run() }) }) @@ -47,25 +50,26 @@ context('/api/marks/highlight', () => { it('should remove existing marks with the same attributes', () => { cy.get('.ProseMirror').then(([{ editor }]) => { - editor.setContent('

Example Text

') - editor.selectAll() - - editor.highlight({ color: 'rgb(255, 0, 0)' }) + editor + .chain() + .setContent('

Example Text

') + .selectAll() + .highlight({ color: 'rgb(255, 0, 0)' }) + .run() cy.get('.ProseMirror') .find('mark') .should('not.exist') - - editor.isActive('highlight', { - color: 'rgb(255, 0, 0)', - }) }) }) it('is active for mark with any attributes', () => { cy.get('.ProseMirror').then(([{ editor }]) => { - editor.setContent('

Example Text

') - editor.selectAll() + editor + .chain() + .setContent('

Example Text

') + .selectAll() + .run() expect(editor.isActive('highlight')).to.eq(true) }) @@ -73,23 +77,33 @@ context('/api/marks/highlight', () => { it('is active for mark with same attributes', () => { cy.get('.ProseMirror').then(([{ editor }]) => { - editor.setContent('

Example Text

') - editor.selectAll() + editor + .chain() + .setContent('

Example Text

') + .selectAll() + .run() - expect(editor.isActive('highlight', { + const isActive = editor.isActive('highlight', { color: 'rgb(255, 0, 0)', - })).to.eq(true) + }) + + expect(isActive).to.eq(true) }) }) it('isn’t active for mark with other attributes', () => { cy.get('.ProseMirror').then(([{ editor }]) => { - editor.setContent('

Example Text

') - editor.selectAll() + editor + .chain() + .setContent('

Example Text

') + .selectAll() + .run() - expect(editor.isActive('highlight', { + const isActive = editor.isActive('highlight', { color: 'rgb(0, 0, 0)', - })).to.eq(false) + }) + + expect(isActive).to.eq(false) }) })