Skip to content

Commit

Permalink
Fix tests failing in IE due to editableInput always being attached
Browse files Browse the repository at this point in the history
  • Loading branch information
nmielnik committed Aug 20, 2015
1 parent 5b88071 commit 9b68346
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion spec/anchor.spec.js
Expand Up @@ -479,11 +479,11 @@ describe('Anchor Button TestCase', function () {
});

it('should unlink when selection is a link', function () {
spyOn(document, 'execCommand').and.callThrough();
this.el.innerHTML = '<a href="#">link</a>';
var button,
editor = this.newMediumEditor('.editor'),
toolbar = editor.getExtensionByName('toolbar');
spyOn(document, 'execCommand').and.callThrough();
selectElementContentsAndFire(editor.elements[0]);
jasmine.clock().tick(11); // checkSelection delay
button = toolbar.getToolbarElement().querySelector('[data-action="createLink"]');
Expand Down
6 changes: 3 additions & 3 deletions spec/buttons.spec.js
Expand Up @@ -325,10 +325,10 @@ describe('Buttons TestCase', function () {

describe('AppendEl', function () {
it('should call the document.execCommand method when button action is append', function () {
spyOn(document, 'execCommand');
var button,
editor = this.newMediumEditor('.editor'),
toolbar = editor.getExtensionByName('toolbar');
spyOn(document, 'execCommand');
selectElementContentsAndFire(editor.elements[0]);
jasmine.clock().tick(1);
button = toolbar.getToolbarElement().querySelector('[data-action="append-h3"]');
Expand Down Expand Up @@ -444,10 +444,10 @@ describe('Buttons TestCase', function () {

describe('Italics', function () {
it('should call the execCommand for native actions', function () {
spyOn(document, 'execCommand').and.callThrough();
var button,
editor = this.newMediumEditor('.editor'),
toolbar = editor.getExtensionByName('toolbar');
spyOn(document, 'execCommand').and.callThrough();
selectElementContentsAndFire(editor.elements[0]);
button = toolbar.getToolbarElement().querySelector('[data-action="italic"]');
fireEvent(button, 'click');
Expand Down Expand Up @@ -727,14 +727,14 @@ describe('Buttons TestCase', function () {

describe('Image', function () {
it('should create an image', function () {
spyOn(document, 'execCommand').and.callThrough();
var editor = this.newMediumEditor('.editor', {
toolbar: {
buttons: ['image']
}
}),
toolbar = editor.getExtensionByName('toolbar'),
button = toolbar.getToolbarElement().querySelector('[data-action="image"]');
spyOn(document, 'execCommand').and.callThrough();

this.el.innerHTML = '<span id="span-image">http://i.imgur.com/twlXfUq.jpg</span>';
selectElementContentsAndFire(document.getElementById('span-image'));
Expand Down
4 changes: 3 additions & 1 deletion spec/events.spec.js
Expand Up @@ -142,7 +142,9 @@ describe('MediumEditor.Events TestCase', function () {
describe('ExecCommand Listener', function () {
it('should only wrap document.execCommand when required', function () {
var origExecCommand = document.execCommand;
this.newMediumEditor('.editor');
this.newMediumEditor('.editor', {
placeholder: false
});
expect(document.execCommand).toBe(origExecCommand);
});

Expand Down
3 changes: 3 additions & 0 deletions spec/extension.spec.js
Expand Up @@ -81,6 +81,9 @@ describe('Extensions TestCase', function () {
},
createElement: function () {
return document.createElement.apply(document, arguments);
},
execCommand: function () {
return document.execCommand.apply(document, arguments);
}
},
fakeWindow = {
Expand Down
4 changes: 2 additions & 2 deletions spec/placeholder.spec.js
Expand Up @@ -78,10 +78,10 @@ describe('MediumEditor.extensions.placeholder TestCase', function () {
fireEvent(document.body, 'click');
expect(editor.elements[0].className).toContain('medium-editor-placeholder');
this.el.innerHTML = '<p>lorem</p><p id="target">ipsum</p><p>dolor</p>';
fireEvent(editor.elements[0], 'input');
editor.trigger('editableInput', {}, editor.elements[0]);
expect(editor.elements[0].className).not.toContain('medium-editor-placeholder');
this.el.innerHTML = '';
fireEvent(editor.elements[0], 'input');
editor.trigger('editableInput', {}, editor.elements[0]);
expect(editor.elements[0].className).toContain('medium-editor-placeholder');
});

Expand Down

0 comments on commit 9b68346

Please sign in to comment.