From a56badd0dc9aba6c4772f5bf6645d264a0619f71 Mon Sep 17 00:00:00 2001 From: Jeroen Akkerman Date: Fri, 14 Jan 2022 23:09:20 +0100 Subject: [PATCH] Add test for markdown rendering --- .../1-default-editor/preview.spec.js | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 cypress/integration/1-default-editor/preview.spec.js diff --git a/cypress/integration/1-default-editor/preview.spec.js b/cypress/integration/1-default-editor/preview.spec.js new file mode 100644 index 0000000..ced582c --- /dev/null +++ b/cypress/integration/1-default-editor/preview.spec.js @@ -0,0 +1,33 @@ +/// + +describe('Preview', () => { + beforeEach(() => { + cy.visit(__dirname + '/default.html'); + }); + + it('can show a preview of markdown text', () => { + cy.get('.EasyMDEContainer').should('be.visible'); + cy.get('.EasyMDEContainer .editor-preview').should('not.be.visible'); + + // Enter markdown text. + cy.get('.EasyMDEContainer .CodeMirror').type('# My Big Title'); + cy.get('.EasyMDEContainer .CodeMirror').type('{enter}'); + cy.get('.EasyMDEContainer .CodeMirror').type('This is some **important** text!'); + + cy.get('.EasyMDEContainer .CodeMirror-line').should('contain', '# My Big Title'); + cy.get('.EasyMDEContainer .cm-header.cm-header-1').should('contain', '#'); + cy.get('.EasyMDEContainer .cm-header.cm-header-1').should('contain', 'My Big Title'); + + cy.get('.EasyMDEContainer .CodeMirror-line').should('contain', 'This is some **important** text!'); + cy.get('.EasyMDEContainer .cm-strong').should('contain', '**'); + cy.get('.EasyMDEContainer .cm-strong').should('contain', 'important'); + + // Toggle preview. + cy.get('.EasyMDEContainer .editor-toolbar button.preview').click(); + cy.get('.EasyMDEContainer .editor-preview').should('be.visible'); + + // Check preview window for rendered markdown. + cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '

My Big Title

'); + cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '

This is some important text!

'); + }); +});