From 5c0bf254429744095f409bea44f2797ce826f62f Mon Sep 17 00:00:00 2001 From: Hans Pagel Date: Thu, 8 Oct 2020 14:54:30 +0200 Subject: [PATCH] add more tests --- .../demos/Extensions/Highlight/index.spec.js | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/docs/src/demos/Extensions/Highlight/index.spec.js b/docs/src/demos/Extensions/Highlight/index.spec.js index eb2f7e0c..7321e2d0 100644 --- a/docs/src/demos/Extensions/Highlight/index.spec.js +++ b/docs/src/demos/Extensions/Highlight/index.spec.js @@ -19,6 +19,61 @@ context('/api/extensions/highlight', () => { .should('contain', 'Example Text') }) + it('should highlight the text in a specific color', () => { + cy.get('.demo__preview button:nth-child(2)') + .click() + + cy.get('.ProseMirror') + .find('mark') + .should('contain', 'Example Text') + .should('have.css', 'background-color', 'rgb(255, 0, 0)') + }) + + it('should update the attributes of existing marks', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.setContent('

Example Text

') + editor.selectAll() + + cy.get('.ProseMirror') + .find('mark') + .should('have.css', 'background-color', 'rgb(0, 0, 255)') + + cy.get('.demo__preview button:nth-child(2)') + .click() + + cy.get('.ProseMirror') + .find('mark') + .should('have.css', 'background-color', 'rgb(255, 0, 0)') + }) + }) + + it('should remove existing marks with the same attributes', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.setContent('

Example Text

') + editor.selectAll() + + cy.get('.ProseMirror') + .find('mark') + .should('have.css', 'background-color', 'rgb(255, 0, 0)') + + cy.get('.demo__preview button:nth-child(2)') + .click() + + cy.get('.ProseMirror') + .find('mark') + .should('not.exist') + }) + }) + + it('the button should highlight the selected text', () => { + cy.get('.demo__preview button:first') + .click() + + cy.get('.ProseMirror') + .find('mark') + .should('contain', 'Example Text') + }) + it('the button should toggle the selected text highlighted', () => { cy.get('.demo__preview button:first') .click()