-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test for the parentheses problem
- Loading branch information
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}'); | ||
|
||
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>`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |