commit b939f9b3af9af9111da28b9f2bc7c2671937f070
parent 1fe47c20e74029f92f28b1443b7d1bb0bcf96268
Author: m1ga <migamiga@web.de>
Date: Thu, 1 Oct 2020 16:10:21 +0200
link button check
Diffstat:
1 file changed, 33 insertions(+), 16 deletions(-)
diff --git a/demo/src/test.js b/demo/src/test.js
@@ -4,7 +4,7 @@ mocha.setup('bdd');
function getEditor() {
const editor = [...document.getElementsByClassName('striven-editor')].pop();
- return editor.StrivenEditor();
+ return editor.StrivenEditor();
}
function node(content) {
@@ -15,10 +15,10 @@ function node(content) {
/* Regression Tests */
describe('Regression Tests', () => {
-
+
it('should not return script elements', () => {
const se = getEditor();
-
+
const content = `
<p>This is some dangerous content!</p>
<script>alert('hello');</script>
@@ -53,9 +53,9 @@ describe('Regression Tests', () => {
it('should apply font style to content', (done) => {
const se = getEditor();
se.setContent('<p>Change me to Verdana</p>');
-
+
setTimeout(() => {
- se.getRange().selectNode(se.body.querySelector('p'));
+ se.getRange().selectNode(se.body.querySelector('p'));
se.toolbar.querySelector('#toolbar-fontName').click();
se.editor.querySelector('.se-toolbar-popup-option[style="font-family: Verdana;"]').click();
se.body.onfocus();
@@ -73,7 +73,7 @@ describe('Regression Tests', () => {
se.setContent('<p>Change me to 36pt size</p>');
setTimeout(() => {
- se.getRange().selectNode(se.body.querySelector('p'));
+ se.getRange().selectNode(se.body.querySelector('p'));
se.toolbar.querySelector('#toolbar-fontSize').click();
const option = [...se.editor.querySelectorAll('.se-toolbar-popup-option')].filter(opt => (opt.textContent === '36pt')).pop();
option.click();
@@ -92,7 +92,7 @@ describe('Regression Tests', () => {
se.setContent('<p>Change me to an H1 format</p>');
setTimeout(() => {
- se.getRange().selectNode(se.body.querySelector('p'));
+ se.getRange().selectNode(se.body.querySelector('p'));
se.toolbar.querySelector('#toolbar-fontFormat').click();
const option = [...se.editor.querySelectorAll('.se-toolbar-popup-option')].filter(opt => (opt.textContent === 'Heading 1')).pop();
option.click();
@@ -109,7 +109,7 @@ describe('Regression Tests', () => {
it('should apply a scroll bar for large content', () => {
const se = getEditor();
se.editor.setAttribute('max-height', '300px');
- se.body.style.maxHeight = '300px';
+ se.body.style.maxHeight = '300px';
let largeContent = '';
for(let i = 0; i < 1000; i++) {
@@ -118,17 +118,17 @@ describe('Regression Tests', () => {
se.setContent(largeContent);
se.body.blur();
-
+
assert.notEqual(se.body.scrollHeight, se.body.offsetHeight, 'scroll bar was set');
se.clearContent();
- se.overflow();
+ se.overflow();
});
it('should apply a scroll bar for large content after collapsing fullscreen', () => {
const se = getEditor();
se.editor.setAttribute('max-height', '300px');
- se.body.style.maxHeight = '300px';
+ se.body.style.maxHeight = '300px';
se.toolbar.querySelector('#toolbar-fullscreen').click();
@@ -139,10 +139,10 @@ describe('Regression Tests', () => {
se.setContent(largeContent);
se.toolbar.querySelector('#toolbar-fullscreen').click();
-
+
assert.notEqual(se.body.scrollHeight, se.body.offsetHeight, 'scroll bar was set');
se.clearContent();
- se.overflow();
+ se.overflow();
});
@@ -153,24 +153,41 @@ describe('Regression Tests', () => {
fetch('https://raw.githubusercontent.com/striven-erp/striven-editor/master/LICENSE.txt')
.then(res => res.body.getReader().read().then(d => {
se.attachFile(new File([new Blob(d.value)], 'LICENSE.txt'));
-
+
const isAttached = se.getFiles().pop() instanceof File;
const elCreated = se.filesSection.querySelector('.se-file .se-file-name').textContent === 'LICENSE.txt';
assert.isTrue(isAttached && elCreated, 'file was attached');
se.clearFiles();
done();
-
+
}));
});
+ it('should open/close link menu', (done) => {
+ const se = getEditor();
+ se.openLinkMenu();
+ assert.exists(document.querySelector('#link-menu'), 'menu is there');
+
+ se.openLinkMenu()
+ setTimeout(function() {
+ if (window.getComputedStyle(document.getElementById("link-menu")).visibility == "visible") {
+ se.closeLinkMenu();
+ setTimeout(function() {
+ if (window.getComputedStyle(document.getElementById("link-menu")).visibility == "hidden") {
+ done();
+ }
+ }, 500);
+ }
+ }, 250);
+ });
});
/* Internal Tests */
describe('Internal Tests', () => {
it('should of been created', () => {
- assert.exists(getEditor().editor, 'Editor is created');
+ assert.exists(getEditor().editor, 'Editor is created');
});
it('should have a body', () => {