summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiza Pagliari <lpagliari@gmail.com>2016-06-21 11:07:57 -0300
committerLuiza Pagliari <lpagliari@gmail.com>2016-06-21 11:07:57 -0300
commit3f15ff91eb1ea29b5d39ccebf2daa1e6634e0330 (patch)
treeae14eadbbb9a2d630b2e3116d5896ef9e2b04330
parent95dc9d031599dfa7fcf986f3ce976932049131d5 (diff)
downloadetherpad-lite-3f15ff91eb1ea29b5d39ccebf2daa1e6634e0330.zip
Select beginning of end line when offset is 0 on frontend tests
-rw-r--r--tests/frontend/helper.js2
-rw-r--r--tests/frontend/specs/helper.js18
2 files changed, 19 insertions, 1 deletions
diff --git a/tests/frontend/helper.js b/tests/frontend/helper.js
index d8aa096f..7a8d19b6 100644
--- a/tests/frontend/helper.js
+++ b/tests/frontend/helper.js
@@ -145,7 +145,7 @@ var helper = {};
helper.selectLines = function($startLine, $endLine, startOffset, endOffset){
// if no offset is provided, use beginning of start line and end of end line
startOffset = startOffset || 0;
- endOffset = endOffset || $endLine.text().length;
+ endOffset = endOffset === undefined ? $endLine.text().length : endOffset;
var inner$ = helper.padInner$;
var selection = inner$.document.getSelection();
diff --git a/tests/frontend/specs/helper.js b/tests/frontend/specs/helper.js
index d460a02b..bb47f4dc 100644
--- a/tests/frontend/specs/helper.js
+++ b/tests/frontend/specs/helper.js
@@ -158,6 +158,24 @@ describe("the test helper", function(){
done();
});
+ it("ends selection at beginning of $endLine when its offset is zero", function(done){
+ var inner$ = helper.padInner$;
+
+ var startOffset = 2;
+ var endOffset = 0;
+
+ var $lines = inner$("div");
+ var $startLine = $lines.slice(1,2);
+ var $endLine = $lines.slice(3,4);
+
+ helper.selectLines($startLine, $endLine, startOffset, endOffset);
+
+ var selection = inner$.document.getSelection();
+ expect(cleanText(selection.toString())).to.be("ort \nlines \n");
+
+ done();
+ });
+
it("selects full line when offset is longer than line content", function(done){
var inner$ = helper.padInner$;