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.
This commit is contained in:
John McLear 2020-03-22 20:32:39 +00:00 committed by muxator
parent d05e02a681
commit 93ee98ea4b

View file

@ -136,7 +136,15 @@ describe("the test helper", function(){
helper.selectLines($startLine, $endLine, startOffset, endOffset); helper.selectLines($startLine, $endLine, startOffset, endOffset);
var selection = inner$.document.getSelection(); 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(); done();
}); });
@ -154,7 +162,15 @@ describe("the test helper", function(){
helper.selectLines($startLine, $endLine, startOffset, endOffset); helper.selectLines($startLine, $endLine, startOffset, endOffset);
var selection = inner$.document.getSelection(); 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(); done();
}); });
@ -172,7 +188,15 @@ describe("the test helper", function(){
helper.selectLines($startLine, $endLine, startOffset, endOffset); helper.selectLines($startLine, $endLine, startOffset, endOffset);
var selection = inner$.document.getSelection(); 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(); done();
}); });
@ -190,7 +214,15 @@ describe("the test helper", function(){
helper.selectLines($startLine, $endLine, startOffset, endOffset); helper.selectLines($startLine, $endLine, startOffset, endOffset);
var selection = inner$.document.getSelection(); 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(); done();
}); });
@ -205,7 +237,15 @@ describe("the test helper", function(){
helper.selectLines($startLine, $endLine); helper.selectLines($startLine, $endLine);
var selection = inner$.document.getSelection(); 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(); done();
}); });