Skip to content

Commit

Permalink
Merge pull request #1396 from yabwe/fix-broken-browser-tests
Browse files Browse the repository at this point in the history
Fix broken browser tests
  • Loading branch information
nmielnik committed Dec 19, 2017
2 parents 7d893ba + 52defad commit 795d14c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ module.exports = function (grunt) {
gruntConfig['saucelabs-jasmine'] = {
all: {
options: {
urls: ['http://127.0.0.1:9999/_SpecRunner.html'],
urls: ['http://localhost:9999/_SpecRunner.html'],
tunnelTimeout: 5,
build: process.env.TRAVIS_JOB_ID,
concurrency: 3,
Expand Down
23 changes: 23 additions & 0 deletions spec/buttons.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@ describe('Buttons TestCase', function () {
expect(button.classList.contains('medium-editor-button-active')).toBe(true);

fireEvent(button, 'click');

this.el.innerHTML = stripAttrIfEmpty(this.el, 'style');

// style="font-weight: bold" prevents IE9+10 from doing anything when 'bold' is triggered
// but it should work in other browsers
expect(!isOldIE() && button.classList.contains('medium-editor-button-active')).toBe(false);
Expand Down Expand Up @@ -507,6 +510,9 @@ describe('Buttons TestCase', function () {
expect(button.classList.contains('medium-editor-button-active')).toBe(true);

fireEvent(button, 'click');

this.el.innerHTML = stripAttrIfEmpty(this.el, 'style');

// style="font-style: italic" prevents IE9+10 from doing anything when 'italic' is triggered
// but it should work in other browsers
expect(!isOldIE() && button.classList.contains('medium-editor-button-active')).toBe(false);
Expand Down Expand Up @@ -566,6 +572,9 @@ describe('Buttons TestCase', function () {
expect(button.classList.contains('medium-editor-button-active')).toBe(true);

fireEvent(button, 'click');

this.el.innerHTML = stripAttrIfEmpty(this.el, 'style');

// style="text-decoration: underline" prevents IE9+10 from doing anything when 'underline' is triggered
// but it should work in other browsers
expect(!isOldIE() && button.classList.contains('medium-editor-button-active')).toBe(false);
Expand Down Expand Up @@ -625,6 +634,9 @@ describe('Buttons TestCase', function () {
expect(button.classList.contains('medium-editor-button-active')).toBe(true);

fireEvent(button, 'click');

this.el.innerHTML = stripAttrIfEmpty(this.el, 'style');

// style="text-decoration: line-through" prevents IE9+10 from doing anything when 'strikethrough' is triggered
// but it should work in other browsers
expect(!isOldIE() && button.classList.contains('medium-editor-button-active')).toBe(false);
Expand Down Expand Up @@ -1056,3 +1068,14 @@ describe('Buttons TestCase', function () {
});
});
});

function stripAttrIfEmpty(element, attribute) {
// we want to strip empty attributes (especially styles,
// because the tests create style tags, inject style content,
// and then remove that style content.
//
// some browsers will remove empty attributes automatically.
//
// others (Chrome, seemingly) will not:
return element.innerHTML.replace(attribute + '=""', '');
}
2 changes: 1 addition & 1 deletion spec/content.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ describe('Content TestCase', function () {
fireEvent(target, 'keydown', {
keyCode: MediumEditor.util.keyCode.BACKSPACE
});
expect(this.el.innerHTML).toBe('<p>lorem ipsum</p><ul><li></li><li>lorem ipsum</li></ul>');
expect(this.el.innerHTML).toMatch(/^<p>lorem ipsum<\/p><ul><li>(<br>)?<\/li><li>lorem ipsum<\/li><\/ul>$/);
});
});

Expand Down

0 comments on commit 795d14c

Please sign in to comment.