Skip to content

Commit

Permalink
Add a test for the parentheses problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Ionaru committed Feb 17, 2025
1 parent f20ff16 commit e7a56e1
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
43 changes: 43 additions & 0 deletions cypress/e2e/4.image-rendering/image-rendering.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/// <reference types="cypress" />

describe('Image rendering', () => {

const imageUrl = 'https://picsum.photos/id/237/150';

beforeEach(() => {
cy.visit(__dirname + '/index.html');
cy.intercept('GET', imageUrl).as('image');
});

it('must render an image inside the editor', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('#textarea').should('not.be.visible');

cy.get('.EasyMDEContainer .CodeMirror').type(imageUrl);
cy.get('.EasyMDEContainer .CodeMirror').type('{home}![Dog!]({end})');

cy.wait('@image');

cy.get(`.EasyMDEContainer [data-img-src="${imageUrl}"]`).should('be.visible');

cy.previewOn();

cy.get('.EasyMDEContainer .editor-preview').should('contain.html', `<p><img src="${imageUrl}" alt="Dog!"></p>`);
});

it('must be able to handle parentheses inside image alt text', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('#textarea').should('not.be.visible');

cy.get('.EasyMDEContainer .CodeMirror').type(imageUrl);
cy.get('.EasyMDEContainer .CodeMirror').type('{home}![Dog! (He\'s a good boy!)]({end})');

cy.wait('@image');

cy.get(`.EasyMDEContainer [data-img-src="${imageUrl}"]`).should('be.visible');

cy.previewOn();

cy.get('.EasyMDEContainer .editor-preview').should('contain.html', `<p><img src="${imageUrl}" alt="Dog! (He's a good boy!)"></p>`);
});
});
20 changes: 20 additions & 0 deletions cypress/e2e/4.image-rendering/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Default</title>
<link rel="stylesheet" href="../../../dist/easymde.min.css">
<script src="../../../dist/easymde.min.js"></script>
</head>

<body>
<textarea id="textarea"></textarea>
<script>
const easyMDE = new EasyMDE({
previewImagesInEditor: true,
});
</script>
</body>

</html>

0 comments on commit e7a56e1

Please sign in to comment.