Skip to content

Commit

Permalink
Test code for PR #1364
Browse files Browse the repository at this point in the history
  • Loading branch information
apptaro committed Sep 1, 2017
1 parent d0c3ebe commit 83f8f1f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/anchor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,26 @@ describe('Anchor Button TestCase', function () {
expect(this.el.innerHTML.indexOf('<a href="http://test.com">lorem ipsum</a>')).toBe(0);
});

// https://github.com/yabwe/medium-editor/pull/1364
it('should create a link containing utf-8 characters correctly when user presses enter', function () {
spyOn(MediumEditor.prototype, 'createLink').and.callThrough();
var editor = this.newMediumEditor('.editor'),
toolbar = editor.getExtensionByName('toolbar'),
button, input;

selectElementContents(editor.elements[0]);
button = toolbar.getToolbarElement().querySelector('[data-action="createLink"]');
fireEvent(button, 'click');
input = editor.getExtensionByName('anchor').getInput();
input.value = 'http://www.st\u00E4dtlifest.ch/';
fireEvent(input, 'keyup', {
keyCode: MediumEditor.util.keyCode.ENTER
});
expect(editor.createLink).toHaveBeenCalled();
// A trailing <br> may be added when insertHTML is used to add the link internally.
expect(this.el.innerHTML.indexOf('<a href="http://www.st\u00E4dtlifest.ch/">lorem ipsum</a>')).toBe(0);
});

it('should remove the extra white spaces in the link when user presses enter', function () {
spyOn(MediumEditor.prototype, 'createLink').and.callThrough();
var editor = this.newMediumEditor('.editor'),
Expand Down

0 comments on commit 83f8f1f

Please sign in to comment.