From 30ade712bf20924644ece85bbc4db3a22fa6a168 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Mon, 20 Sep 2021 14:53:09 -0700 Subject: [PATCH] feat: add tests for shouldRunVsCodeCli --- test/unit/node/cli.test.ts | 54 +++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/test/unit/node/cli.test.ts b/test/unit/node/cli.test.ts index 93a86776..ff713456 100644 --- a/test/unit/node/cli.test.ts +++ b/test/unit/node/cli.test.ts @@ -3,7 +3,14 @@ import { promises as fs } from "fs" import * as net from "net" import * as os from "os" import * as path from "path" -import { Args, parse, setDefaults, shouldOpenInExistingInstance, splitOnFirstEquals } from "../../../src/node/cli" +import { + Args, + parse, + setDefaults, + shouldOpenInExistingInstance, + shouldRunVsCodeCli, + splitOnFirstEquals, +} from "../../../src/node/cli" import { tmpdir } from "../../../src/node/constants" import { paths } from "../../../src/node/util" @@ -463,3 +470,48 @@ describe("splitOnFirstEquals", () => { expect(actual).toEqual(expect.arrayContaining(expected)) }) }) + +describe("shouldRunVsCodeCli", () => { + it("should return false if no 'extension' related args passed in", () => { + const args = { + _: [], + } + const actual = shouldRunVsCodeCli(args) + const expected = false + + expect(actual).toBe(expected) + }) + + it("should return true if 'list-extensions' passed in", () => { + const args = { + _: [], + ["list-extensions"]: true, + } + const actual = shouldRunVsCodeCli(args) + const expected = true + + expect(actual).toBe(expected) + }) + + it("should return true if 'install-extension' passed in", () => { + const args = { + _: [], + ["install-extension"]: ["hello.world"], + } + const actual = shouldRunVsCodeCli(args) + const expected = true + + expect(actual).toBe(expected) + }) + + it("should return true if 'uninstall-extension' passed in", () => { + const args = { + _: [], + ["uninstall-extension"]: ["hello.world"], + } + const actual = shouldRunVsCodeCli(args) + const expected = true + + expect(actual).toBe(expected) + }) +})