From 83efc9afc4d77a5b1f336f9ab7ca625823cb3d88 Mon Sep 17 00:00:00 2001 From: Paris Kasidiaris Date: Sun, 9 Jul 2017 10:29:32 +0300 Subject: [PATCH] Fix SelectionManager tests --- src/SelectionManager.test.ts | 43 ++++++++++++------------------------ 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/src/SelectionManager.test.ts b/src/SelectionManager.test.ts index 12784e0..e9981fc 100644 --- a/src/SelectionManager.test.ts +++ b/src/SelectionManager.test.ts @@ -37,11 +37,10 @@ describe('SelectionManager', () => { let document: Document; let terminal: ITerminal; - let buffer: CircularList; + let bufferLines: CircularList; 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(100); - terminal = { 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'); }); }); -- 2.39.5