]> git.proxmox.com Git - mirror_xterm.js.git/commitdiff
Fix SelectionManager tests
authorParis Kasidiaris <paris@sourcelair.com>
Sun, 9 Jul 2017 07:29:32 +0000 (10:29 +0300)
committerParis Kasidiaris <pariskasidiaris@gmail.com>
Sun, 16 Jul 2017 00:47:15 +0000 (03:47 +0300)
src/SelectionManager.test.ts

index 12784e02b0782e844fcb9a1b7dd00981bd517e1e..e9981fce748acaa426cb3843874431a81d54e6f6 100644 (file)
@@ -37,11 +37,10 @@ describe('SelectionManager', () => {
   let document: Document;
 
   let terminal: ITerminal;
-  let buffer: CircularList<any>;
+  let bufferLines: CircularList<any>;
   let rowContainer: HTMLElement;
   let selectionManager: TestSelectionManager;
 
-<<<<<<< HEAD
   beforeEach(() => {
     dom = new jsdom.JSDOM('');
     window = dom.window;
@@ -50,22 +49,8 @@ describe('SelectionManager', () => {
     terminal.scrollback = 100;
     terminal.buffers = new BufferSet(terminal);
     terminal.buffer = terminal.buffers.active;
-    selectionManager = new TestSelectionManager(terminal, buffer, rowContainer, null);
-=======
-  beforeEach(done => {
-    jsdom.env('', (err, w) => {
-      window = w;
-      document = window.document;
-      buffer = new CircularList<any>(100);
-      terminal = <any>{ cols: 80, rows: 2 };
-      terminal.scrollback = 10;
-      terminal.buffers = new BufferSet(terminal);
-      terminal.buffer = terminal.buffers.active;
-
-      selectionManager = new TestSelectionManager(terminal, buffer, rowContainer, null);
-      done();
-    });
->>>>>>> Fix some tests and docs, little code fix up.
+    bufferLines = terminal.buffer.lines
+    selectionManager = new TestSelectionManager(terminal, bufferLines, rowContainer, null);
   });
 
   function stringToRow(text: string): [number, string, number][] {
@@ -78,7 +63,7 @@ describe('SelectionManager', () => {
 
   describe('_selectWordAt', () => {
     it('should expand selection for normal width chars', () => {
-      buffer.push(stringToRow('foo bar'));
+      bufferLines.push(stringToRow('foo bar'));
       selectionManager.selectWordAt([0, 0]);
       assert.equal(selectionManager.selectionText, 'foo');
       selectionManager.selectWordAt([1, 0]);
@@ -95,7 +80,7 @@ describe('SelectionManager', () => {
       assert.equal(selectionManager.selectionText, 'bar');
     });
     it('should expand selection for whitespace', () => {
-      buffer.push(stringToRow('a   b'));
+      bufferLines.push(stringToRow('a   b'));
       selectionManager.selectWordAt([0, 0]);
       assert.equal(selectionManager.selectionText, 'a');
       selectionManager.selectWordAt([1, 0]);
@@ -109,7 +94,7 @@ describe('SelectionManager', () => {
     });
     it('should expand selection for wide characters', () => {
       // Wide characters use a special format
-      buffer.push([
+      bufferLines.push([
         [null, '中', 2],
         [null, '', 0],
         [null, '文', 2],
@@ -161,7 +146,7 @@ describe('SelectionManager', () => {
       assert.equal(selectionManager.selectionText, 'foo');
     });
     it('should select up to non-path characters that are commonly adjacent to paths', () => {
-      buffer.push(stringToRow('(cd)[ef]{gh}\'ij"'));
+      bufferLines.push(stringToRow('(cd)[ef]{gh}\'ij"'));
       selectionManager.selectWordAt([0, 0]);
       assert.equal(selectionManager.selectionText, '(cd');
       selectionManager.selectWordAt([1, 0]);
@@ -199,7 +184,7 @@ describe('SelectionManager', () => {
 
   describe('_selectLineAt', () => {
     it('should select the entire line', () => {
-      buffer.push(stringToRow('foo bar'));
+      bufferLines.push(stringToRow('foo bar'));
       selectionManager.selectLineAt(0);
       assert.equal(selectionManager.selectionText, 'foo bar', 'The selected text is correct');
       assert.deepEqual(selectionManager.model.finalSelectionStart, [0, 0]);
@@ -209,13 +194,13 @@ describe('SelectionManager', () => {
 
   describe('selectAll', () => {
     it('should select the entire buffer, beyond the viewport', () => {
-      buffer.push(stringToRow('1'));
-      buffer.push(stringToRow('2'));
-      buffer.push(stringToRow('3'));
-      buffer.push(stringToRow('4'));
-      buffer.push(stringToRow('5'));
+      bufferLines.push(stringToRow('1'));
+      bufferLines.push(stringToRow('2'));
+      bufferLines.push(stringToRow('3'));
+      bufferLines.push(stringToRow('4'));
+      bufferLines.push(stringToRow('5'));
       selectionManager.selectAll();
-      terminal.buffer.ybase = buffer.length - terminal.rows;
+      terminal.buffer.ybase = bufferLines.length - terminal.rows;
       assert.equal(selectionManager.selectionText, '1\n2\n3\n4\n5');
     });
   });