From 7fbcea99af2d35f209970213e6458eeace01f275 Mon Sep 17 00:00:00 2001 From: ryanluker Date: Sun, 1 Jul 2018 13:14:24 -0700 Subject: [PATCH] [#134] Fix tests and adjust send event --- src/extension.ts | 4 ---- src/renderer.ts | 4 ++-- src/reporter.ts | 2 +- src/wrappers/lcov-parse.ts | 11 ----------- src/wrappers/xml-parse.ts | 11 ----------- test/renderer.test.ts | 6 +++++- 6 files changed, 8 insertions(+), 30 deletions(-) delete mode 100644 src/wrappers/lcov-parse.ts delete mode 100644 src/wrappers/xml-parse.ts diff --git a/src/extension.ts b/src/extension.ts index 19f85ef..ecb0d20 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -7,14 +7,10 @@ import {Reporter} from "./reporter"; import {StatusBarToggler} from "./statusbartoggler"; import {Fs} from "./wrappers/fs"; import {Glob} from "./wrappers/glob"; -import {LcovParse} from "./wrappers/lcov-parse"; import {Request} from "./wrappers/request"; import {Vscode} from "./wrappers/vscode"; -import {XmlParse} from "./wrappers/xml-parse"; const fsImpl = new Fs(); -const xmlParseImpl = new XmlParse(); -const lcovParseImpl = new LcovParse(); const vscodeImpl = new Vscode(); const globImpl = new Glob(); diff --git a/src/renderer.ts b/src/renderer.ts index 12bc31b..9986f9f 100644 --- a/src/renderer.ts +++ b/src/renderer.ts @@ -124,8 +124,8 @@ export class Renderer { const message = template + `${filePath} [exactness score]: ${topSection.score}`; this.outputChannel.appendLine(message); // log event and file type - this.eventReporter.sendEvent("system", "renderer", "correctness", topSection.score); - this.eventReporter.sendEvent("system", "renderer", "fileType", extname(filePath)); + this.eventReporter.sendEvent("system", "renderer-correctness", topSection.score.toString()); + this.eventReporter.sendEvent("system", "renderer-fileType", extname(filePath)); } return topSection.section; diff --git a/src/reporter.ts b/src/reporter.ts index be7baab..1621401 100644 --- a/src/reporter.ts +++ b/src/reporter.ts @@ -20,7 +20,7 @@ export class Reporter { category: string, action: string, label?: string, - value?: number | string, + value?: number, ) { if (!this.enableMetrics) { return; } const data = { diff --git a/src/wrappers/lcov-parse.ts b/src/wrappers/lcov-parse.ts deleted file mode 100644 index ad63e22..0000000 --- a/src/wrappers/lcov-parse.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {Section, source as sourceLcovParse} from "lcov-parse"; - -export interface InterfaceLcovParse { - source(file: string, cb: (err: Error, data: Section[]) => void): void; -} - -export class LcovParse implements InterfaceLcovParse { - public source(file: string, cb: (err: Error, data: Section[]) => void): void { - return sourceLcovParse(file, cb); - } -} diff --git a/src/wrappers/xml-parse.ts b/src/wrappers/xml-parse.ts deleted file mode 100644 index 736a97f..0000000 --- a/src/wrappers/xml-parse.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {parseContent, Section} from "cobertura-parse"; - -export interface InterfaceXmlParse { - parseContent(file: string, cb: (err: Error, data: Section[]) => void): void; -} - -export class XmlParse implements InterfaceXmlParse { - public parseContent(file: string, cb: (err: Error, data: Section[]) => void): void { - return parseContent(file, cb); - } -} diff --git a/test/renderer.test.ts b/test/renderer.test.ts index fcf8bcf..157ae8b 100644 --- a/test/renderer.test.ts +++ b/test/renderer.test.ts @@ -31,8 +31,12 @@ suite("Renderer Tests", function() { show: () => {}, }; + const fakeReporter = { + sendEvent: () => {}, + } + test("Constructor should setup properly @unit", function(done) { - assert.doesNotThrow(() => new Renderer(fakeConfig, fakeOutput)); + assert.doesNotThrow(() => new Renderer(fakeConfig, fakeOutput, fakeReporter as any)); return done(); }); });