summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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$;