From 713f3364131a620d083e8037954322cf0ccbb43c Mon Sep 17 00:00:00 2001 From: Christian Sterzl Date: Tue, 9 Sep 2014 18:20:39 +0200 Subject: [PATCH] Added test for parser rules, adding classes --- test/editor_commands_test.js | 82 +++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/test/editor_commands_test.js b/test/editor_commands_test.js index c26ad93..19a4ec4 100644 --- a/test/editor_commands_test.js +++ b/test/editor_commands_test.js @@ -252,6 +252,86 @@ if (wysihtml5.browser.supported()) { }); }); + asyncTest("Create link with class", function() { + expect(1); + + var that = this, + text = "text", + editor = new wysihtml5.Editor(this.editableArea1, + { + parserRules: { + classes: { 'mytxtlink': 1 }, + tags: { 'a': + { 'set_class': 'mytxtlink' } + } + } + }); + + editor.on("load", function() { + var editableElement = that.editableArea1; + editor.setValue(text, true); + editor.composer.selection.selectNode(editor.editableElement); + // Create + editor.composer.commands.exec('createLink', { + "href": "http://test.com", "title": "test" + }); + that.equal(editableElement.innerHTML.toLowerCase(), '' + text + '', "Link added with class correctly"); + + start(); + }); + }); + + + + // insertImage + asyncTest("Insert image", function() { + expect(1); + + var that = this, + editor = new wysihtml5.Editor(this.editableArea1); + + editor.on("load", function() { + var editableElement = that.editableArea1; + editor.setValue('', true); + editor.composer.selection.selectNode(editor.editableElement); + // Create + editor.composer.commands.exec('insertImage', { + "src": "http://test.com/test.png" + }); + that.equal(editableElement.innerHTML.toLowerCase(), '
', "Image added correctly"); + + start(); + }); + }); + + asyncTest("Insert image with class", function() { + expect(1); + + var that = this, + editor = new wysihtml5.Editor(this.editableArea1, + { + parserRules: { + classes: { 'mytxtimg': 1 }, + tags: { 'img': + { 'set_class': 'mytxtimg' } + } + } + }); + + editor.on("load", function() { + var editableElement = that.editableArea1; + editor.setValue('', true); + editor.composer.selection.selectNode(editor.editableElement); + // Create + editor.composer.commands.exec('insertImage', "http://test.com/test.png"); + that.equal(editableElement.innerHTML.toLowerCase(), '
', "Image added with class correctly"); + + start(); + }); + }); + + + // create table asyncTest("Create table", function() { expect(1); @@ -379,4 +459,4 @@ if (wysihtml5.browser.supported()) { -} \ No newline at end of file +}