mirror of
https://github.com/Ionaru/easy-markdown-editor
synced 2025-06-27 13:11:01 -06:00
Add a test for the parentheses problem
This commit is contained in:
parent
f20ff16b81
commit
e7a56e11dd
43
cypress/e2e/4.image-rendering/image-rendering.cy.js
Normal file
43
cypress/e2e/4.image-rendering/image-rendering.cy.js
Normal file
@ -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}');
|
||||
|
||||
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}');
|
||||
|
||||
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
cypress/e2e/4.image-rendering/index.html
Normal file
20
cypress/e2e/4.image-rendering/index.html
Normal file
@ -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>
|
Loading…
x
Reference in New Issue
Block a user