striven-editor

Maintained and contributed to an open source WYSIWYG editor as an internship project that made it to production and was adopted by the company I was working at.
git clone https://unitehenry.com/git/striven-editor.git
Log | Files | Refs | README | LICENSE

commit f54a862c930b109ea555ed293d3302d98a550a2d
parent 76ca0a859c4852046c8fbc5f0935c4eaa02b0725
Author: Henry Unite <unitehenry@gmail.com>
Date:   Fri, 11 Sep 2020 16:26:12 -0400

regression tests

Diffstat:
Mdemo/src/App.vue | 2+-
Mdemo/src/test.js | 75+++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------
2 files changed, 58 insertions(+), 19 deletions(-)

diff --git a/demo/src/App.vue b/demo/src/App.vue @@ -44,7 +44,7 @@ export default { minimal: false, uploadOnPaste: false, toolbarBottom: false, - toolbarHide: true, + toolbarHide: false, // Tests will break toolbar if this is on sanitizePaste: true, onInvalidFile() { alert("invalid file"); diff --git a/demo/src/test.js b/demo/src/test.js @@ -15,24 +15,7 @@ function node(content) { /* Regression Tests */ describe('Regression Tests', () => { - it('should insert a link that will open in a new window', () => { - const se = getEditor(); - const { editor, body } = se; - body.focus(); - - const menu = editor.querySelector('#link-menu'); - - const url = menu.querySelector('input'); - url.value = 'https://striven.com/'; - - menu.querySelector('button').click(); - const link = body.querySelector('a[target="_blank"]'); - - assert.exists(link, 'will open in new window'); - se.clearContent(); - - }); - + it('should not return script elements', () => { const se = getEditor(); @@ -67,6 +50,62 @@ describe('Regression Tests', () => { }); + it('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.toolbar.querySelector('#toolbar-fontName').click(); + se.editor.querySelector('.se-toolbar-popup-option[style="font-family: Verdana;"]').click(); + se.body.onfocus(); + setTimeout(() => { + assert.exists(se.body.querySelector('p font[face="Verdana"]'), 'selected font style was applied'); + se.clearContent(); + done(); + }, 0); + }, 200); + + }); + + it('apply font size to content', (done) => { + const se = getEditor(); + se.setContent('<p>Change me to 36pt size</p>'); + + setTimeout(() => { + 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(); + se.body.onfocus(); + setTimeout(() => { + assert.exists(se.body.querySelector('font[size="7"]'), 'selected font size was applied'); + se.clearContent(); + done(); + }, 0); + }, 200); + + }); + + it('apply font format to content', (done) => { + const se = getEditor(); + se.setContent('<p>Change me to an H1 format</p>'); + + setTimeout(() => { + 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(); + se.body.onfocus(); + setTimeout(() => { + assert.exists(se.body.querySelector('h1'), 'selected font format was applied'); + se.clearContent(); + done(); + }, 0); + }, 200); + + }); + }); /* Internal Tests */