diff --git a/src/Buffer.test.ts b/src/Buffer.test.ts index db8a460d09..2561ce36df 100644 --- a/src/Buffer.test.ts +++ b/src/Buffer.test.ts @@ -7,7 +7,7 @@ import { assert, expect } from 'chai'; import { ITerminal } from './Types'; import { Buffer, DEFAULT_ATTR, CHAR_DATA_CHAR_INDEX } from './Buffer'; import { CircularList } from './common/CircularList'; -import { MockTerminal, TestTerminal } from './utils/TestUtils.test'; +import { MockTerminal, TestTerminal } from './ui/TestUtils.test'; import { BufferLine } from './BufferLine'; const INIT_COLS = 80; diff --git a/src/BufferSet.test.ts b/src/BufferSet.test.ts index 38f2ddab93..26f9cd42f7 100644 --- a/src/BufferSet.test.ts +++ b/src/BufferSet.test.ts @@ -7,7 +7,7 @@ import { assert } from 'chai'; import { ITerminal } from './Types'; import { BufferSet } from './BufferSet'; import { Buffer } from './Buffer'; -import { MockTerminal } from './utils/TestUtils.test'; +import { MockTerminal } from './ui/TestUtils.test'; describe('BufferSet', () => { let terminal: ITerminal; diff --git a/src/CharWidth.test.ts b/src/CharWidth.test.ts index d4ddd24c5e..0747fdf12c 100644 --- a/src/CharWidth.test.ts +++ b/src/CharWidth.test.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { TestTerminal } from './utils/TestUtils.test'; +import { TestTerminal } from './ui/TestUtils.test'; import { assert } from 'chai'; import { getStringCellWidth, wcwidth } from './CharWidth'; import { IBuffer } from './Types'; diff --git a/src/InputHandler.test.ts b/src/InputHandler.test.ts index b2fea06a3c..acc18ea57a 100644 --- a/src/InputHandler.test.ts +++ b/src/InputHandler.test.ts @@ -5,7 +5,7 @@ import { assert, expect } from 'chai'; import { InputHandler } from './InputHandler'; -import { MockInputHandlingTerminal } from './utils/TestUtils.test'; +import { MockInputHandlingTerminal } from './ui/TestUtils.test'; import { NULL_CELL_CHAR, NULL_CELL_CODE, NULL_CELL_WIDTH, CHAR_DATA_CHAR_INDEX, CHAR_DATA_ATTR_INDEX, DEFAULT_ATTR } from './Buffer'; import { Terminal } from './Terminal'; import { IBufferLine } from './Types'; diff --git a/src/Linkifier.test.ts b/src/Linkifier.test.ts index 22e797aa7d..0ba1294a0e 100644 --- a/src/Linkifier.test.ts +++ b/src/Linkifier.test.ts @@ -7,7 +7,7 @@ import { assert } from 'chai'; import { IMouseZoneManager, IMouseZone } from './ui/Types'; import { ILinkMatcher, ITerminal, IBufferLine } from './Types'; import { Linkifier } from './Linkifier'; -import { MockBuffer, MockTerminal, TestTerminal } from './utils/TestUtils.test'; +import { MockBuffer, MockTerminal, TestTerminal } from './ui/TestUtils.test'; import { CircularList } from './common/CircularList'; import { BufferLine } from './BufferLine'; diff --git a/src/SelectionManager.test.ts b/src/SelectionManager.test.ts index 8735e8945d..2f74ccdab0 100644 --- a/src/SelectionManager.test.ts +++ b/src/SelectionManager.test.ts @@ -9,7 +9,7 @@ import { SelectionManager, SelectionMode } from './SelectionManager'; import { SelectionModel } from './SelectionModel'; import { BufferSet } from './BufferSet'; import { ITerminal, IBuffer, IBufferLine } from './Types'; -import { MockTerminal } from './utils/TestUtils.test'; +import { MockTerminal } from './ui/TestUtils.test'; import { BufferLine } from './BufferLine'; class TestMockTerminal extends MockTerminal { diff --git a/src/SelectionManager.ts b/src/SelectionManager.ts index 3dc50271dc..4bac040055 100644 --- a/src/SelectionManager.ts +++ b/src/SelectionManager.ts @@ -5,7 +5,7 @@ import { ITerminal, ISelectionManager, IBuffer, CharData, IBufferLine } from './Types'; import { XtermListener } from './common/Types'; -import { MouseHelper } from './utils/MouseHelper'; +import { MouseHelper } from './ui/MouseHelper'; import * as Browser from './core/Platform'; import { CharMeasure } from './ui/CharMeasure'; import { EventEmitter } from './common/EventEmitter'; diff --git a/src/SelectionModel.test.ts b/src/SelectionModel.test.ts index 59b2ce75d0..8d4b30bb58 100644 --- a/src/SelectionModel.test.ts +++ b/src/SelectionModel.test.ts @@ -7,7 +7,7 @@ import { assert } from 'chai'; import { ITerminal } from './Types'; import { SelectionModel } from './SelectionModel'; import { BufferSet } from './BufferSet'; -import { MockTerminal } from './utils/TestUtils.test'; +import { MockTerminal } from './ui/TestUtils.test'; class TestSelectionModel extends SelectionModel { constructor( diff --git a/src/Terminal.test.ts b/src/Terminal.test.ts index fd59144c60..733d2b39bb 100644 --- a/src/Terminal.test.ts +++ b/src/Terminal.test.ts @@ -5,7 +5,7 @@ import { assert, expect } from 'chai'; import { Terminal } from './Terminal'; -import { MockViewport, MockCompositionHelper, MockRenderer } from './utils/TestUtils.test'; +import { MockViewport, MockCompositionHelper, MockRenderer } from './ui/TestUtils.test'; import { CHAR_DATA_CHAR_INDEX, CHAR_DATA_WIDTH_INDEX, DEFAULT_ATTR } from './Buffer'; const INIT_COLS = 80; diff --git a/src/Terminal.ts b/src/Terminal.ts index 779d9bf5e3..bc8fb103a2 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -39,8 +39,7 @@ import { CharMeasure } from './ui/CharMeasure'; import * as Browser from './core/Platform'; import { addDisposableDomListener } from './ui/Lifecycle'; import * as Strings from './Strings'; -import { MouseHelper } from './utils/MouseHelper'; -import { clone } from './utils/Clone'; +import { MouseHelper } from './ui/MouseHelper'; import { DEFAULT_BELL_SOUND, SoundManager } from './SoundManager'; import { DEFAULT_ANSI_COLORS } from './renderer/ColorManager'; import { MouseZoneManager } from './ui/MouseZoneManager'; @@ -52,6 +51,7 @@ import { DomRenderer } from './renderer/dom/DomRenderer'; import { IKeyboardEvent } from './common/Types'; import { evaluateKeyboardEvent } from './core/input/Keyboard'; import { KeyboardResultType, ICharset } from './core/Types'; +import { clone } from './common/Clone'; // Let it work inside Node.js for automated testing purposes. const document = (typeof window !== 'undefined') ? window.document : null; diff --git a/src/utils/Clone.test.ts b/src/common/Clone.test.ts similarity index 95% rename from src/utils/Clone.test.ts rename to src/common/Clone.test.ts index b24452c89a..4b815ff36f 100644 --- a/src/utils/Clone.test.ts +++ b/src/common/Clone.test.ts @@ -101,7 +101,7 @@ describe('clone', () => { test.a.b.c.d.e.f = 'bar'; // The values at a greater depth then 5 should not be cloned - assert.equal(cloned.a.b.c.d.e.f, 'bar'); + assert.equal((cloned as any).a.b.c.d.e.f, 'bar'); }); it('should allow an optional maximum depth to be set', () => { @@ -118,7 +118,7 @@ describe('clone', () => { test.a.b.c = 'bar'; // The values at a greater depth then 2 should not be cloned - assert.equal(cloned.a.b.c, 'bar'); + assert.equal((cloned as any).a.b.c, 'bar'); }); it('should not throw when cloning a recursive reference', () => { diff --git a/src/utils/Clone.ts b/src/common/Clone.ts similarity index 90% rename from src/utils/Clone.ts rename to src/common/Clone.ts index b09c02584c..78bacbb521 100644 --- a/src/utils/Clone.ts +++ b/src/common/Clone.ts @@ -6,7 +6,7 @@ /* * A simple utility for cloning values */ -export const clone = (val: T, depth: number = 5): T => { +export function clone(val: T, depth: number = 5): T | null { if (typeof val !== 'object') { return val; } @@ -25,4 +25,4 @@ export const clone = (val: T, depth: number = 5): T => { } return clonedObject as T; -}; +} diff --git a/src/renderer/CharacterJoinerRegistry.test.ts b/src/renderer/CharacterJoinerRegistry.test.ts index 383d2a7f8b..0c29566ac3 100644 --- a/src/renderer/CharacterJoinerRegistry.test.ts +++ b/src/renderer/CharacterJoinerRegistry.test.ts @@ -1,6 +1,6 @@ import { assert } from 'chai'; -import { MockTerminal, MockBuffer } from '../utils/TestUtils.test'; +import { MockTerminal, MockBuffer } from '../ui/TestUtils.test'; import { CircularList } from '../common/CircularList'; import { ICharacterJoinerRegistry } from './Types'; diff --git a/src/utils/MouseHelper.test.ts b/src/ui/MouseHelper.test.ts similarity index 100% rename from src/utils/MouseHelper.test.ts rename to src/ui/MouseHelper.test.ts diff --git a/src/utils/MouseHelper.ts b/src/ui/MouseHelper.ts similarity index 100% rename from src/utils/MouseHelper.ts rename to src/ui/MouseHelper.ts diff --git a/src/utils/TestUtils.test.ts b/src/ui/TestUtils.test.ts similarity index 100% rename from src/utils/TestUtils.test.ts rename to src/ui/TestUtils.test.ts