Select beginning of end line when offset is 0 on frontend tests

pull/3009/head
Luiza Pagliari 2016-06-21 11:07:57 -03:00
parent 95dc9d0315
commit 3f15ff91eb
2 changed files with 19 additions and 1 deletions

View File

@ -145,7 +145,7 @@ var helper = {};
helper.selectLines = function($startLine, $endLine, startOffset, endOffset){ helper.selectLines = function($startLine, $endLine, startOffset, endOffset){
// if no offset is provided, use beginning of start line and end of end line // if no offset is provided, use beginning of start line and end of end line
startOffset = startOffset || 0; startOffset = startOffset || 0;
endOffset = endOffset || $endLine.text().length; endOffset = endOffset === undefined ? $endLine.text().length : endOffset;
var inner$ = helper.padInner$; var inner$ = helper.padInner$;
var selection = inner$.document.getSelection(); var selection = inner$.document.getSelection();

View File

@ -158,6 +158,24 @@ describe("the test helper", function(){
done(); 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){ it("selects full line when offset is longer than line content", function(done){
var inner$ = helper.padInner$; var inner$ = helper.padInner$;