tests: remove white space from getSelection(). This HACK fixes Firefox tests

This is a bit of a hack, because it appears that getSelection() behaviour is
not consistent across browsers.
pull/3885/head
John McLear 2020-03-22 20:32:39 +00:00 committed by muxator
parent d05e02a681
commit 93ee98ea4b
1 changed files with 45 additions and 5 deletions

View File

@ -136,7 +136,15 @@ describe("the test helper", function(){
helper.selectLines($startLine, $endLine, startOffset, endOffset);
var selection = inner$.document.getSelection();
expect(cleanText(selection.toString())).to.be("ort lines to t");
/*
* replace() is required here because Firefox keeps the line breaks.
*
* I'm not sure this is ideal behavior of getSelection() where the text
* is not consistent between browsers but that's the situation so that's
* how I'm covering it in this test.
*/
expect(cleanText(selection.toString().replace(/(\r\n|\n|\r)/gm,""))).to.be("ort lines to t");
done();
});
@ -154,7 +162,15 @@ describe("the test helper", function(){
helper.selectLines($startLine, $endLine, startOffset, endOffset);
var selection = inner$.document.getSelection();
expect(cleanText(selection.toString())).to.be("ort lines to test");
/*
* replace() is required here because Firefox keeps the line breaks.
*
* I'm not sure this is ideal behavior of getSelection() where the text
* is not consistent between browsers but that's the situation so that's
* how I'm covering it in this test.
*/
expect(cleanText(selection.toString().replace(/(\r\n|\n|\r)/gm,""))).to.be("ort lines to test");
done();
});
@ -172,7 +188,15 @@ describe("the test helper", function(){
helper.selectLines($startLine, $endLine, startOffset, endOffset);
var selection = inner$.document.getSelection();
expect(cleanText(selection.toString())).to.be("ort lines ");
/*
* replace() is required here because Firefox keeps the line breaks.
*
* I'm not sure this is ideal behavior of getSelection() where the text
* is not consistent between browsers but that's the situation so that's
* how I'm covering it in this test.
*/
expect(cleanText(selection.toString().replace(/(\r\n|\n|\r)/gm,""))).to.be("ort lines ");
done();
});
@ -190,7 +214,15 @@ describe("the test helper", function(){
helper.selectLines($startLine, $endLine, startOffset, endOffset);
var selection = inner$.document.getSelection();
expect(cleanText(selection.toString())).to.be("ort lines to test");
/*
* replace() is required here because Firefox keeps the line breaks.
*
* I'm not sure this is ideal behavior of getSelection() where the text
* is not consistent between browsers but that's the situation so that's
* how I'm covering it in this test.
*/
expect(cleanText(selection.toString().replace(/(\r\n|\n|\r)/gm,""))).to.be("ort lines to test");
done();
});
@ -205,7 +237,15 @@ describe("the test helper", function(){
helper.selectLines($startLine, $endLine);
var selection = inner$.document.getSelection();
expect(cleanText(selection.toString())).to.be("short lines to test");
/*
* replace() is required here because Firefox keeps the line breaks.
*
* I'm not sure this is ideal behavior of getSelection() where the text
* is not consistent between browsers but that's the situation so that's
* how I'm covering it in this test.
*/
expect(cleanText(selection.toString().replace(/(\r\n|\n|\r)/gm,""))).to.be("short lines to test");
done();
});