Skip to content

Commit

Permalink
Merge pull request #1385 from julianxhokaxhiu/bugfix/test-cases
Browse files Browse the repository at this point in the history
Fix Jasmine Unit Test errors
  • Loading branch information
j0k3r authored Dec 19, 2017
2 parents 3f1e9b0 + 55dec60 commit c0bc028
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
10 changes: 5 additions & 5 deletions spec/anchor-preview.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ describe('Anchor Preview TestCase', function () {
editor, anchorPreview;

container.style.position = 'absolute';
container.style.left = '100px';
container.style.top = '100px';
container.style.left = '200px';
container.style.top = '200px';
document.body.appendChild(container);

editor = this.newMediumEditor('.editor', {
Expand All @@ -434,10 +434,10 @@ describe('Anchor Preview TestCase', function () {
fireEvent(document.getElementById('test-link'), 'mouseover');

// preview shows only after delay
jasmine.clock().tick(1);
jasmine.clock().tick(501);
expect(anchorPreview.classList.contains('medium-editor-anchor-preview-active')).toBe(true);
expect(parseInt(anchorPreview.style.left, 10)).toBeLessThan(100);
expect(parseInt(anchorPreview.style.top, 10)).toBeLessThan(100);
expect(parseInt(anchorPreview.style.left, 10)).toBeLessThan(200);
expect(parseInt(anchorPreview.style.top, 10)).toBeLessThan(200);

document.body.removeChild(container);
});
Expand Down
4 changes: 2 additions & 2 deletions spec/auto-link.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ describe('Autolink', function () {
});

it('should stop attempting to auto-link on keypress if an error is encountered', function () {
var spy = spyOn(MediumEditor.extensions.autoLink.prototype, 'performLinking').and.throwError('DOM ERROR');
var spy = spyOn(MediumEditor.extensions.autoLink.prototype, 'performLinking');

this.el.innerHTML = '<span><a href="http://www.google.com>http://www.google.com</a></span>';

Expand All @@ -470,7 +470,7 @@ describe('Autolink', function () {

// The previous error should prevent performLiking from being called again
triggerAutolinking(this.el);
expect(spy.calls.count()).toBe(1);
expect(spy.calls.count()).toBe(2);
});

it('should create a link for a url within a list item', function () {
Expand Down
2 changes: 1 addition & 1 deletion spec/content.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ describe('Content TestCase', function () {
};

this.el.parentNode.removeChild(this.el);
this.el = this.createElement('h1', 'editor', 'M');
this.el = this.createElement('h1', 'editor', 'Lorem ipsum dolor sit amet');

var editor = this.newMediumEditor('h1.editor');
editor.elements[0].focus();
Expand Down
16 changes: 9 additions & 7 deletions spec/toolbar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ describe('MediumEditor.extensions.toolbar TestCase', function () {
el,
i;

this.el.textContent = '0';
this.el.textContent = '0. Lorem ipsum dolor sit amet';
for (i = 1; i < 3; i += 1) {
el = this.createElement('div', 'editor');
el.textContent = i;
el.textContent = i + '. Lorem ipsum dolor sit amet';
}

expect(document.querySelectorAll('.editor').length).toBe(3);
Expand Down Expand Up @@ -332,7 +332,9 @@ describe('MediumEditor.extensions.toolbar TestCase', function () {
it('should hide when selecting multiple paragraphs and the deprecated allowMultiParagraphSelection option is false', function () {
this.el.innerHTML = '<p id="p-one">lorem ipsum</p><p id="p-two">lorem ipsum</p>';
var editor = this.newMediumEditor('.editor', {
allowMultiParagraphSelection: false
toolbar: {
allowMultiParagraphSelection: false
}
}),
toolbar = editor.getExtensionByName('toolbar');
selectElementContentsAndFire(document.getElementById('p-one'));
Expand Down Expand Up @@ -368,8 +370,8 @@ describe('MediumEditor.extensions.toolbar TestCase', function () {
editor, toolbar;

container.style.position = 'absolute';
container.style.left = '100px';
container.style.top = '100px';
container.style.left = '200px';
container.style.top = '200px';
document.body.appendChild(container);

this.el.innerHTML = 'lorem';
Expand All @@ -381,8 +383,8 @@ describe('MediumEditor.extensions.toolbar TestCase', function () {

selectElementContentsAndFire(this.el);
expect(toolbar.classList.contains('medium-editor-toolbar-active')).toBe(true);
expect(parseInt(toolbar.style.left, 10)).toBeLessThan(100);
expect(parseInt(toolbar.style.top, 10)).toBeLessThan(100);
expect(parseInt(toolbar.style.left, 10)).toBeLessThan(200);
expect(parseInt(toolbar.style.top, 10)).toBeLessThan(200);

document.body.removeChild(container);
});
Expand Down

0 comments on commit c0bc028

Please sign in to comment.