Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions desktop/src/main/__tests__/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import { Readable } from "node:stream"
import { beforeEach, describe, expect, it, vi } from "vitest"
import { CliRunner } from "../cli.js"

type ExecCb = (
error: Error | null,
result: { stdout: string; stderr: string },
) => void

function fakeChild() {
const child = new EventEmitter() as EventEmitter & {
stdout: EventEmitter
Expand Down Expand Up @@ -59,7 +64,7 @@ describe("CliRunner", () => {
typeof vi.fn
>
mockExecFile.mockImplementation(
(_cmd: string, _args: string[], _opts: unknown, callback: Function) => {
(_cmd: string, _args: string[], _opts: unknown, callback: ExecCb) => {
callback(null, { stdout: '[{"id":"ws-1"}]', stderr: "" })
},
)
Expand Down Expand Up @@ -91,7 +96,7 @@ describe("CliRunner", () => {
typeof vi.fn
>
mockExecFile.mockImplementation(
(_cmd: string, _args: string[], _opts: unknown, callback: Function) => {
(_cmd: string, _args: string[], _opts: unknown, callback: ExecCb) => {
const error = new Error("Command failed") as Error & {
code: number
stderr: string
Expand Down Expand Up @@ -122,7 +127,7 @@ describe("CliRunner", () => {
cliError: cliErrorPayload,
})
mockExecFile.mockImplementation(
(_cmd: string, _args: string[], _opts: unknown, callback: Function) => {
(_cmd: string, _args: string[], _opts: unknown, callback: ExecCb) => {
const error = new Error("Command failed") as Error & {
code: number
stderr: string
Expand All @@ -148,7 +153,7 @@ describe("CliRunner", () => {
typeof vi.fn
>
mockExecFile.mockImplementation(
(_cmd: string, _args: string[], _opts: unknown, callback: Function) => {
(_cmd: string, _args: string[], _opts: unknown, callback: ExecCb) => {
callback(null, { stdout: "v0.6.0-dev\n", stderr: "" })
},
)
Expand Down Expand Up @@ -203,7 +208,7 @@ describe("CliRunner", () => {
typeof vi.fn
>
mockExecFile.mockImplementation(
(_cmd: string, _args: string[], _opts: unknown, callback: Function) => {
(_cmd: string, _args: string[], _opts: unknown, callback: ExecCb) => {
callback(null, { stdout: "[]", stderr: "" })
},
)
Expand Down
Loading