From a6bfd73de9dee8af0d0a70fb25d1075310730f47 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Tue, 14 Jul 2020 15:29:49 -0400 Subject: [PATCH] fix test Signed-off-by: Sebastian Malton --- src/common/user-store_spec.ts | 3 --- src/main/context-handler.ts | 1 - src/main/kubectl.ts | 2 +- src/renderer/utils/__tests__/formatDuration.test.ts | 8 +++++++- src/renderer/utils/formatDuration.ts | 2 +- tsconfig.json | 12 +++++++++--- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/common/user-store_spec.ts b/src/common/user-store_spec.ts index 53901732c6..657dced485 100644 --- a/src/common/user-store_spec.ts +++ b/src/common/user-store_spec.ts @@ -13,7 +13,6 @@ describe("for an empty config", () => { } } mockFs(mockOpts) - const userStore = UserStore.getInstance() }) afterEach(() => { @@ -57,12 +56,10 @@ describe("migrations", () => { 'config.json': JSON.stringify({ user: { username: 'foobar' }, preferences: { colorTheme: 'light' }, - lastSeenAppVersion: '1.2.3' }) } } mockFs(mockOpts) - const userStore = UserStore.getInstance() }) afterEach(() => { diff --git a/src/main/context-handler.ts b/src/main/context-handler.ts index ad0bd85019..6dd8daa0f4 100644 --- a/src/main/context-handler.ts +++ b/src/main/context-handler.ts @@ -1,5 +1,4 @@ import { CoreV1Api, KubeConfig } from "@kubernetes/client-node" -import http from "http" import { ServerOptions } from "http-proxy" import * as url from "url" import logger from "./logger" diff --git a/src/main/kubectl.ts b/src/main/kubectl.ts index 73efc507b3..a4c21095d6 100644 --- a/src/main/kubectl.ts +++ b/src/main/kubectl.ts @@ -125,7 +125,7 @@ export class Kubectl { } try { - const { stdout, stderr } = await promiseExec(`"${this.path}" version --client=true -o json`) + const { stdout } = await promiseExec(`"${this.path}" version --client=true -o json`) const output = JSON.parse(stdout) let version: string = output.clientVersion.gitVersion if (version[0] === 'v') { diff --git a/src/renderer/utils/__tests__/formatDuration.test.ts b/src/renderer/utils/__tests__/formatDuration.test.ts index bad84c4af1..13086c099d 100644 --- a/src/renderer/utils/__tests__/formatDuration.test.ts +++ b/src/renderer/utils/__tests__/formatDuration.test.ts @@ -1,5 +1,4 @@ import { formatDuration } from "../formatDuration"; -import { min } from "moment"; const second = 1000; const minute = 60 * second; @@ -44,4 +43,11 @@ describe("human format durations", () => { const significant = formatDuration(31 * second, false); expect(significant).toBe("31s"); }); + + test("zero duration should output something", () => { + const zero = formatDuration(0, false); + + expect(zero).not.toHaveLength(0); + expect(zero).toBe("0s"); + }); }); diff --git a/src/renderer/utils/formatDuration.ts b/src/renderer/utils/formatDuration.ts index fc11636c79..1731e1c5cd 100644 --- a/src/renderer/utils/formatDuration.ts +++ b/src/renderer/utils/formatDuration.ts @@ -24,7 +24,7 @@ export function formatDuration(timeValue: number, compact: boolean) { .map(([dur, suf]) => dur + suf); if (compact) { - return meaningfulValues[0]; + return meaningfulValues[0] || "0s"; } return meaningfulValues.join(" "); diff --git a/tsconfig.json b/tsconfig.json index 2a110d2c5a..4cdd1a6d95 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,12 +6,11 @@ "target": "ES2017", "module": "ESNext", "lib": ["ESNext", "DOM", "DOM.Iterable"], - "importsNotUsedAsValues": "preserve", "moduleResolution": "Node", "sourceMap": true, "strict": false, "noImplicitAny": true, - "noUnusedLocals": false, + "noUnusedLocals": true, "noImplicitReturns": false, "experimentalDecorators": true, "emitDecoratorMetadata": true, @@ -32,5 +31,12 @@ "compilerOptions": { "module": "CommonJS" } - } + }, + "exclude": [ + "node_modules", + "dist", + "coverage", + "dashboard", + "binaries" + ] }