]> git.proxmox.com Git - mirror_xterm.js.git/blobdiff - src/SelectionModel.test.ts
Merge pull request #926 from ficristo/search-fix
[mirror_xterm.js.git] / src / SelectionModel.test.ts
index 621026ed223ad4e5cd5efb357c007fa63ec147d2..b087944273a54da097fcbc9cc6f01c01245a2687 100644 (file)
@@ -4,6 +4,8 @@
 import { assert } from 'chai';
 import { ITerminal } from './Interfaces';
 import { SelectionModel } from './SelectionModel';
+import {BufferSet} from './BufferSet';
+import { MockTerminal } from './utils/TestUtils';
 
 class TestSelectionModel extends SelectionModel {
   constructor(
@@ -11,8 +13,6 @@ class TestSelectionModel extends SelectionModel {
   ) {
     super(terminal);
   }
-
-  public areSelectionValuesReversed(): boolean { return this._areSelectionValuesReversed(); }
 }
 
 describe('SelectionManager', () => {
@@ -23,7 +23,13 @@ describe('SelectionManager', () => {
   let model: TestSelectionModel;
 
   beforeEach(() => {
-    terminal = <any>{ cols: 80, rows: 2, ybase: 0 };
+    terminal = new MockTerminal();
+    terminal.cols = 80;
+    terminal.rows = 2;
+    terminal.scrollback = 10;
+    terminal.buffers = new BufferSet(terminal);
+    terminal.buffer = terminal.buffers.active;
+
     model = new TestSelectionModel(terminal);
   });
 
@@ -39,7 +45,7 @@ describe('SelectionManager', () => {
     });
   });
 
-  describe('_areSelectionValuesReversed', () => {
+  describe('areSelectionValuesReversed', () => {
     it('should return true when the selection end is before selection start', () => {
       model.selectionStart = [1, 0];
       model.selectionEnd = [0, 0];
@@ -99,17 +105,13 @@ describe('SelectionManager', () => {
   describe('finalSelectionEnd', () => {
     it('should return the end of the buffer if select all is active', () => {
       model.isSelectAllActive = true;
-      assert.deepEqual(model.finalSelectionEnd, [79, 1]);
+      assert.deepEqual(model.finalSelectionEnd, [80, 1]);
     });
     it('should return null if there is no selection start', () => {
       assert.equal(model.finalSelectionEnd, null);
       model.selectionEnd = [1, 2];
       assert.equal(model.finalSelectionEnd, null);
     });
-    it('should return null if there is no selection end or selection start length', () => {
-      model.selectionStart = [1, 2];
-      assert.equal(model.finalSelectionEnd, null);
-    });
     it('should return selection start + length if there is no selection end', () => {
       model.selectionStart = [2, 2];
       model.selectionStartLength = 2;