From 92be6561137bb9db1569910faaff25c0607c4212 Mon Sep 17 00:00:00 2001 From: Luiza Pagliari Date: Mon, 20 Feb 2017 06:02:31 -0300 Subject: [PATCH 1/3] [test] Fix helper tests for IE --- tests/frontend/specs/helper.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/frontend/specs/helper.js b/tests/frontend/specs/helper.js index bb47f4dcd..7270d4798 100644 --- a/tests/frontend/specs/helper.js +++ b/tests/frontend/specs/helper.js @@ -101,16 +101,17 @@ describe("the test helper", function(){ // function to support tests, use a single way to represent whitespaces var cleanText = function(text){ return text - .replace(/\n/gi, "\\\\n") // avoid \n to be replaced by \s on next line - .replace(/\s/gi, " ") - .replace(/\\\\n/gi, "\n"); // move back \n to its original state + // IE replaces line breaks with a whitespace, so we need to unify its behavior + // for other browsers, to have all tests running for all browsers + .replace(/\n/gi, " ") + .replace(/\s/gi, " "); } before(function(done){ helper.newPad(function() { // create some lines to be used on the tests var $firstLine = helper.padInner$("div").first(); - $firstLine.sendkeys("{selectall}some{enter}short{enter}lines{enter}to test{enter}"); + $firstLine.sendkeys("{selectall}some{enter}short{enter}lines{enter}to test{enter}{enter}"); // wait for lines to be split helper.waitFor(function(){ @@ -135,7 +136,7 @@ describe("the test helper", function(){ helper.selectLines($startLine, $endLine, startOffset, endOffset); var selection = inner$.document.getSelection(); - expect(cleanText(selection.toString())).to.be("ort \nlines \nto t"); + expect(cleanText(selection.toString())).to.be("ort lines to t"); done(); }); @@ -153,7 +154,7 @@ describe("the test helper", function(){ helper.selectLines($startLine, $endLine, startOffset, endOffset); var selection = inner$.document.getSelection(); - expect(cleanText(selection.toString())).to.be("ort \nlines \nto test\n"); + expect(cleanText(selection.toString())).to.be("ort lines to test"); done(); }); @@ -171,7 +172,7 @@ describe("the test helper", function(){ helper.selectLines($startLine, $endLine, startOffset, endOffset); var selection = inner$.document.getSelection(); - expect(cleanText(selection.toString())).to.be("ort \nlines \n"); + expect(cleanText(selection.toString())).to.be("ort lines "); done(); }); @@ -189,7 +190,7 @@ describe("the test helper", function(){ helper.selectLines($startLine, $endLine, startOffset, endOffset); var selection = inner$.document.getSelection(); - expect(cleanText(selection.toString())).to.be("ort \nlines \nto test"); + expect(cleanText(selection.toString())).to.be("ort lines to test"); done(); }); @@ -204,7 +205,7 @@ describe("the test helper", function(){ helper.selectLines($startLine, $endLine); var selection = inner$.document.getSelection(); - expect(cleanText(selection.toString())).to.be("short \nlines \nto test"); + expect(cleanText(selection.toString())).to.be("short lines to test"); done(); }); From 15cda0fde6b3b5794b26331f36ab04413be0ee0e Mon Sep 17 00:00:00 2001 From: Luiza Pagliari Date: Mon, 20 Feb 2017 06:03:56 -0300 Subject: [PATCH 2/3] [refactor] Use better way to select a single line --- tests/frontend/specs/helper.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/frontend/specs/helper.js b/tests/frontend/specs/helper.js index 7270d4798..863f7a92c 100644 --- a/tests/frontend/specs/helper.js +++ b/tests/frontend/specs/helper.js @@ -115,7 +115,7 @@ describe("the test helper", function(){ // wait for lines to be split helper.waitFor(function(){ - var $fourthLine = helper.padInner$("div").slice(3,4); + var $fourthLine = helper.padInner$("div").eq(3); return $fourthLine.text() === "to test"; }).done(done); }); @@ -130,8 +130,8 @@ describe("the test helper", function(){ var endOffset = 4; var $lines = inner$("div"); - var $startLine = $lines.slice(1,2); - var $endLine = $lines.slice(3,4); + var $startLine = $lines.eq(1); + var $endLine = $lines.eq(3); helper.selectLines($startLine, $endLine, startOffset, endOffset); @@ -148,8 +148,8 @@ describe("the test helper", function(){ var endOffset = 1; var $lines = inner$("div"); - var $startLine = $lines.slice(1,2); - var $endLine = $lines.slice(4,5); + var $startLine = $lines.eq(1); + var $endLine = $lines.eq(4); helper.selectLines($startLine, $endLine, startOffset, endOffset); @@ -166,8 +166,8 @@ describe("the test helper", function(){ var endOffset = 0; var $lines = inner$("div"); - var $startLine = $lines.slice(1,2); - var $endLine = $lines.slice(3,4); + var $startLine = $lines.eq(1); + var $endLine = $lines.eq(3); helper.selectLines($startLine, $endLine, startOffset, endOffset); @@ -184,8 +184,8 @@ describe("the test helper", function(){ var endOffset = 50; var $lines = inner$("div"); - var $startLine = $lines.slice(1,2); - var $endLine = $lines.slice(3,4); + var $startLine = $lines.eq(1); + var $endLine = $lines.eq(3); helper.selectLines($startLine, $endLine, startOffset, endOffset); @@ -199,8 +199,8 @@ describe("the test helper", function(){ var inner$ = helper.padInner$; var $lines = inner$("div"); - var $startLine = $lines.slice(1,2); - var $endLine = $lines.slice(3,4); + var $startLine = $lines.eq(1); + var $endLine = $lines.eq(3); helper.selectLines($startLine, $endLine); From 2b96a961e3bb70cf574c9248eda16f460809e571 Mon Sep 17 00:00:00 2001 From: Luiza Pagliari Date: Mon, 20 Feb 2017 06:14:27 -0300 Subject: [PATCH 3/3] [fix] Remove extra whitespace on helper tests for IE --- tests/frontend/specs/helper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/frontend/specs/helper.js b/tests/frontend/specs/helper.js index 863f7a92c..8520769aa 100644 --- a/tests/frontend/specs/helper.js +++ b/tests/frontend/specs/helper.js @@ -103,7 +103,7 @@ describe("the test helper", function(){ return text // IE replaces line breaks with a whitespace, so we need to unify its behavior // for other browsers, to have all tests running for all browsers - .replace(/\n/gi, " ") + .replace(/\n/gi, "") .replace(/\s/gi, " "); }