Skip to content

Commit

Permalink
Review fixes: add tests for fixed issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Samsel committed Jun 14, 2018
1 parent 6fb4c95 commit 25e5355
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 8 deletions.
23 changes: 22 additions & 1 deletion tests/plugins/emoji/basic.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* bender-tags: emoji */
/* bender-ckeditor-plugins: emoji,toolbar,stylescombo,format,clipboard */
/* bender-ckeditor-plugins: emoji,toolbar,stylescombo,format,clipboard,undo */

( function() {
'use strict';
Expand Down Expand Up @@ -27,6 +27,20 @@
}
};

var singleTests = {
'test emoji doesn\'t create additional undo step on creation': function() {
bender.editorBot.create( {
creator: 'replace',
startupData: '<p>foo:grinning_face:bar :not_emoji:</p>'
}, function( bot ) {
var editor = bot.editor;
editor.fire( 'saveSnapshot' );
assert.areSame( '<p>foo😀bar :not_emoji:</p>', editor.getData() );
assert.areSame( editor.undoManager.snapshots.length, 1 );
} );
}
};

var tests = {
setUp: function() {
if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 ) {
Expand Down Expand Up @@ -78,5 +92,12 @@
};

tests = bender.tools.createTestsForEditors( CKEDITOR.tools.objectKeys( bender.editors ), tests );

CKEDITOR.tools.array.forEach( CKEDITOR.tools.objectKeys( singleTests ), function( key ) {
if ( tests[ key ] === undefined ) {
tests[ key ] = singleTests[ key ];
}
} );

bender.test( tests );
} )();
29 changes: 22 additions & 7 deletions tests/plugins/emoji/customemojilist.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@
( function() {
'use strict';

bender.editor = {
name: 'classic',
config: {
emoji_emojiListUrl: '%BASE_PATH%/plugins/emoji/_assets/emoji.json'
bender.editors = {
classic: {
name: 'classic',
config: {
emoji_emojiListUrl: '%BASE_PATH%/plugins/emoji/_assets/emoji.json'
},
startupData: '<p>foo :grinning_face: bar :not_emoji: this is converted emoji :star:</p>'
},
startupData: '<p>foo :grinning_face: bar :not_emoji: this is converted emoji :star:</p>'
classic2: {
name: 'classic2',
config: {
emoji_emojiListUrl: 'fake.url'
},
startupData: '<p>foo :grinning_face: bar :not_emoji: this is converted emoji :star:</p>'
}
};

bender.test( {
Expand All @@ -21,14 +30,20 @@

// #2036
'test custom emoji list': function() {
var editor = this.editor,
bot = this.editorBot;
var editor = this.editors.classic,
bot = this.editorBots.classic;

assert.areSame( '<p>foo :grinning_face: bar :not_emoji: this is converted emoji ⭐</p>', editor.getData(), 'Checking startup data' );

bot.setHtmlWithSelection( '<p>hello^world</p>' );
editor.insertText( ':grinning_face::not_emoji::star:' );
assert.areSame( '<p>hello:grinning_face::not_emoji:⭐world</p>', editor.getData() );
},

'test invalid emoji list': function() {
var editor = this.editors.classic2;
assert.areSame( '<p>foo :grinning_face: bar :not_emoji: this is converted emoji :star:</p>', editor.getData(), 'Checking startup data' );
assert.isUndefined( editor._.emojiList, 'There is no emoji list loaded' );
}
} );

Expand Down
18 changes: 18 additions & 0 deletions tests/plugins/emoji/manual/noextraundo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<h1>Classic editor</h1>

<textarea id="editor1" cols="10" rows="10">
<p>Hello world. :winking_face:</p>
</textarea>

<h1>Divarea editor</h1>

<div id="editor2" cols="10" rows="10">
<p>Hello world. :winking_face:</p>
</div>

<script>
CKEDITOR.replace( 'editor1' );
CKEDITOR.replace( 'editor2', {
extraPlugins: 'divarea'
} );
</script>
14 changes: 14 additions & 0 deletions tests/plugins/emoji/manual/noextraundo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@bender-tags: 4.10.0, bug, emoji, 2036
@bender-ckeditor-plugins: wysiwygarea, toolbar, elementspath, sourcearea, emoji, clipboard, undo, stylescombo, format
@bender-ui: collapsed

1. Put selection in editor

## Expected:
There isn't created any undo step in editor.

## Unexpected:
There appears undo steps, you can use redo and remove emoji from editor.

## Note:
Repeat steps in both editors.

0 comments on commit 25e5355

Please sign in to comment.