Skip to content

Commit 76f3d95

Browse files
committed
refactor: tests from mocha to jest
1 parent 4c30276 commit 76f3d95

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

Diff for: test/cli.test.ts

+17-24
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ describe("parser", () => {
3131
}
3232

3333
it("should parse nothing", () => {
34-
expect(parse([])).toBe({ _: [] })
35-
})
34+
expect(parse([])).toStrictEqual({ _: [] }) })
3635

3736
it("should parse all available options", () => {
3837
expect(
@@ -114,7 +113,7 @@ describe("parser", () => {
114113

115114
process.env.LOG_LEVEL = "debug"
116115
const defaults = await setDefaults(args)
117-
expect(defaults).toEqual({
116+
expect(defaults).toStrictEqual({
118117
...defaults,
119118
_: [],
120119
log: "debug",
@@ -125,7 +124,7 @@ describe("parser", () => {
125124

126125
process.env.LOG_LEVEL = "trace"
127126
const updated = await setDefaults(args)
128-
expect(updated).toBe( {
127+
expect(updated).toStrictEqual( {
129128
...updated,
130129
_: [],
131130
log: "trace",
@@ -353,53 +352,47 @@ describe("cli", () => {
353352
})
354353

355354
it("should use existing if inside code-server", async () => {
356-
process.env.VSCODE_IPC_HOOK_CLI = "test"
357-
const shouldOpen = await shouldOpenInExistingInstance(args)
358-
expect(shouldOpen).toStrictEqual("test")
355+
process.env.VSCODE_IPC_HOOK_CLI = "test"
356+
expect(await shouldOpenInExistingInstance(args)).toStrictEqual("test")
359357

360358
args.port = 8081
361-
args._.push("./file")
362-
const _shouldOpen = await shouldOpenInExistingInstance(args)
363-
expect(_shouldOpen).toStrictEqual("test")
359+
args._.push("./file")
360+
expect(await shouldOpenInExistingInstance(args)).toStrictEqual("test")
364361
})
365362

366363
it("should use existing if --reuse-window is set", async () => {
367364
args["reuse-window"] = true
368-
const shouldOpen = await shouldOpenInExistingInstance(args)
369-
await expect(shouldOpen).toStrictEqual(undefined)
365+
await expect(await shouldOpenInExistingInstance(args)).toStrictEqual(undefined)
370366

371367
await fs.writeFile(vscodeIpcPath, "test")
372368
await expect(shouldOpenInExistingInstance(args)).resolves.toStrictEqual("test")
373369

374370
args.port = 8081
375371
await expect(shouldOpenInExistingInstance(args)).resolves.toStrictEqual("test")
376372
})
377-
378-
// TODO
379-
// fix red squiggles
380-
// and don't use should Open on all these
373+
381374
it("should use existing if --new-window is set", async () => {
382375
args["new-window"] = true
383-
expect(await shouldOpenInExistingInstance(args).toStrictEqual(undefined)
376+
expect(await shouldOpenInExistingInstance(args)).toStrictEqual(undefined)
384377

385378
await fs.writeFile(vscodeIpcPath, "test")
386-
expect(await shouldOpenInExistingInstance(args).toStrictEqual("test")
379+
expect(await shouldOpenInExistingInstance(args)).toStrictEqual("test")
387380

388381
args.port = 8081
389-
expect(await shouldOpenInExistingInstance(args).toStrictEqual("test")
382+
expect(await shouldOpenInExistingInstance(args)).toStrictEqual("test")
390383
})
391384

392385
it(
393386
"should use existing if no unrelated flags are set, has positional, and socket is active",
394387
async () => {
395-
expect(await shouldOpenInExistingInstance(args).toStrictEqual(undefined)
388+
expect(await shouldOpenInExistingInstance(args)).toStrictEqual(undefined)
396389

397390
args._.push("./file")
398-
expect(await shouldOpenInExistingInstance(args).toStrictEqual(undefined)
391+
expect(await shouldOpenInExistingInstance(args)).toStrictEqual(undefined)
399392

400393
const socketPath = path.join(testDir, "socket")
401394
await fs.writeFile(vscodeIpcPath, socketPath)
402-
expect(await shouldOpenInExistingInstance(args).toStrictEqual(undefined)
395+
expect(await shouldOpenInExistingInstance(args)).toStrictEqual(undefined)
403396

404397
await new Promise((resolve) => {
405398
const server = net.createServer(() => {
@@ -410,10 +403,10 @@ describe("cli", () => {
410403
server.listen(socketPath)
411404
})
412405

413-
expect(await shouldOpenInExistingInstance(args).toStrictEqual(socketPath)
406+
expect(await shouldOpenInExistingInstance(args)).toStrictEqual(socketPath)
414407

415408
args.port = 8081
416-
expect(await shouldOpenInExistingInstance(args).toStrictEqual(undefined)
409+
expect(await shouldOpenInExistingInstance(args)).toStrictEqual(undefined)
417410
}
418411
)
419412
})

0 commit comments

Comments
 (0)