Skip to content

Commit 30ade71

Browse files
committed
feat: add tests for shouldRunVsCodeCli
1 parent 92d0d28 commit 30ade71

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

test/unit/node/cli.test.ts

+53-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ import { promises as fs } from "fs"
33
import * as net from "net"
44
import * as os from "os"
55
import * as path from "path"
6-
import { Args, parse, setDefaults, shouldOpenInExistingInstance, splitOnFirstEquals } from "../../../src/node/cli"
6+
import {
7+
Args,
8+
parse,
9+
setDefaults,
10+
shouldOpenInExistingInstance,
11+
shouldRunVsCodeCli,
12+
splitOnFirstEquals,
13+
} from "../../../src/node/cli"
714
import { tmpdir } from "../../../src/node/constants"
815
import { paths } from "../../../src/node/util"
916

@@ -463,3 +470,48 @@ describe("splitOnFirstEquals", () => {
463470
expect(actual).toEqual(expect.arrayContaining(expected))
464471
})
465472
})
473+
474+
describe("shouldRunVsCodeCli", () => {
475+
it("should return false if no 'extension' related args passed in", () => {
476+
const args = {
477+
_: [],
478+
}
479+
const actual = shouldRunVsCodeCli(args)
480+
const expected = false
481+
482+
expect(actual).toBe(expected)
483+
})
484+
485+
it("should return true if 'list-extensions' passed in", () => {
486+
const args = {
487+
_: [],
488+
["list-extensions"]: true,
489+
}
490+
const actual = shouldRunVsCodeCli(args)
491+
const expected = true
492+
493+
expect(actual).toBe(expected)
494+
})
495+
496+
it("should return true if 'install-extension' passed in", () => {
497+
const args = {
498+
_: [],
499+
["install-extension"]: ["hello.world"],
500+
}
501+
const actual = shouldRunVsCodeCli(args)
502+
const expected = true
503+
504+
expect(actual).toBe(expected)
505+
})
506+
507+
it("should return true if 'uninstall-extension' passed in", () => {
508+
const args = {
509+
_: [],
510+
["uninstall-extension"]: ["hello.world"],
511+
}
512+
const actual = shouldRunVsCodeCli(args)
513+
const expected = true
514+
515+
expect(actual).toBe(expected)
516+
})
517+
})

0 commit comments

Comments
 (0)