Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit ceda080

Browse files
author
Narciso Jaramillo
committed
Collapse some test cases of getSelectedText() and check both values of argument for each of them
1 parent d1a936b commit ceda080

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

test/spec/Editor-test.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -605,19 +605,22 @@ define(function (require, exports, module) {
605605
it("should return empty string for a cursor", function () {
606606
myEditor._codeMirror.setCursor(0, 2);
607607
expect(myEditor.getSelectedText()).toEqual("");
608+
expect(myEditor.getSelectedText(true)).toEqual("");
608609
});
609610

610611
it("should return the contents of a single selection", function () {
611612
myEditor._codeMirror.setSelection({line: 0, ch: 8}, {line: 0, ch: 14});
612613
expect(myEditor.getSelectedText()).toEqual("line 0");
614+
expect(myEditor.getSelectedText(true)).toEqual("line 0");
613615
});
614616

615-
it("should return the primary selection by default", function () {
617+
it("should return the primary selection by default, but concatenate contents if allSelections is true", function () {
616618
myEditor._codeMirror.setSelections([{anchor: {line: 0, ch: 8}, head: {line: 0, ch: 14}},
617619
{anchor: {line: 1, ch: 8}, head: {line: 1, ch: 14}},
618620
{anchor: {line: 2, ch: 8}, head: {line: 2, ch: 14}}
619621
]);
620622
expect(myEditor.getSelectedText()).toEqual("line 2");
623+
expect(myEditor.getSelectedText(true)).toEqual("line 0\nline 1\nline 2");
621624
});
622625

623626
it("should return a primary selection other than the last", function () {
@@ -626,13 +629,6 @@ define(function (require, exports, module) {
626629
{anchor: {line: 2, ch: 8}, head: {line: 2, ch: 14}}
627630
], 1);
628631
expect(myEditor.getSelectedText()).toEqual("line 1");
629-
});
630-
631-
it("should return the contents of a multiple selection separated by newlines if allSelections is true", function () {
632-
myEditor._codeMirror.setSelections([{anchor: {line: 0, ch: 8}, head: {line: 0, ch: 14}},
633-
{anchor: {line: 1, ch: 8}, head: {line: 1, ch: 14}},
634-
{anchor: {line: 2, ch: 8}, head: {line: 2, ch: 14}}
635-
]);
636632
expect(myEditor.getSelectedText(true)).toEqual("line 0\nline 1\nline 2");
637633
});
638634

@@ -641,6 +637,7 @@ define(function (require, exports, module) {
641637
{anchor: {line: 1, ch: 8}, head: {line: 1, ch: 14}},
642638
{anchor: {line: 2, ch: 14}, head: {line: 2, ch: 8}}
643639
]);
640+
expect(myEditor.getSelectedText()).toEqual("line 2");
644641
expect(myEditor.getSelectedText(true)).toEqual("line 0\nline 1\nline 2");
645642
});
646643
});

0 commit comments

Comments
 (0)