From 15d79143e265dbcd6c2505a9ca86823c4e508bef Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 27 Feb 2017 12:56:54 -0800 Subject: [PATCH] Get rid of exposed test method (phantom is gone) --- src/Linkifier.test.ts | 7 ++++++- src/Linkifier.ts | 23 ++++++++--------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/Linkifier.test.ts b/src/Linkifier.test.ts index bdab5cb..b1c1541 100644 --- a/src/Linkifier.test.ts +++ b/src/Linkifier.test.ts @@ -6,7 +6,12 @@ import { assert } from 'chai'; import { ITerminal, ILinkifier } from './Interfaces'; import { Linkifier } from './Linkifier'; -Linkifier.setTimeBeforeLinkifyForTest(0); +class TestLinkifier extends Linkifier { + constructor(document: Document, rows: HTMLElement[]) { + Linkifier.TIME_BEFORE_LINKIFY = 0; + super(document, rows); + } +} describe('Linkifier', () => { let window: Window; diff --git a/src/Linkifier.ts b/src/Linkifier.ts index f15cfe6..f8b8ca8 100644 --- a/src/Linkifier.ts +++ b/src/Linkifier.ts @@ -36,17 +36,17 @@ const strictUrlRegex = new RegExp(start + protocolClause + bodyClause + end); */ const HYPERTEXT_LINK_MATCHER_ID = 0; -/** - * The time to wait after a row is changed before it is linkified. This prevents - * the costly operation of searching every row multiple times, pntentially a - * huge aount of times. - */ -let TIME_BEFORE_LINKIFY = 200; - /** * The Linkifier applies links to rows shortly after they have been refreshed. */ export class Linkifier { + /** + * The time to wait after a row is changed before it is linkified. This prevents + * the costly operation of searching every row multiple times, pntentially a + * huge aount of times. + */ + protected static TIME_BEFORE_LINKIFY = 200; + private _document: Document; private _rows: HTMLElement[]; private _rowTimeoutIds: number[]; @@ -70,7 +70,7 @@ export class Linkifier { if (timeoutId) { clearTimeout(timeoutId); } - this._rowTimeoutIds[rowIndex] = setTimeout(this._linkifyRow.bind(this, rowIndex), TIME_BEFORE_LINKIFY); + this._rowTimeoutIds[rowIndex] = setTimeout(this._linkifyRow.bind(this, rowIndex), Linkifier.TIME_BEFORE_LINKIFY); } /** @@ -284,11 +284,4 @@ export class Linkifier { this._replaceNode(node, leftTextNode, newNode, rightTextNode); } } - - public static setTimeBeforeLinkifyForTest(time: number) { - // This is necessary since it's needs to be used in PhantomJS. Ideally the - // time variable would be a protected static member and a TestLinkifier - // would expose it for the test. - TIME_BEFORE_LINKIFY = time; - } } -- 2.39.5