[test] Fix helper tests for IE

This commit is contained in:
Luiza Pagliari 2017-02-20 06:02:31 -03:00
parent 203a48b42d
commit 92be656113

View file

@ -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();
});