Skip to content

Commit 9205427

Browse files
author
Zoo Code Contributor
committed
test(terminal): strengthen fallback assertions with getShell() mock
Mock getShell() to verify the fallback actually uses the detected shell instead of just checking for any string value. Suggested-by: CodeRabbit
1 parent dc4a451 commit 9205427

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/integrations/terminal/__tests__/ExecaTerminalProcess.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { execa } from "execa"
2525
import { ExecaTerminalProcess } from "../ExecaTerminalProcess"
2626
import { BaseTerminal } from "../BaseTerminal"
2727
import type { RooTerminal } from "../types"
28+
import * as shellUtils from "../../../utils/shell"
2829

2930
describe("ExecaTerminalProcess", () => {
3031
let mockTerminal: RooTerminal
@@ -34,6 +35,7 @@ describe("ExecaTerminalProcess", () => {
3435
beforeEach(() => {
3536
originalEnv = { ...process.env }
3637
BaseTerminal.setExecaShellPath(undefined)
38+
vitest.spyOn(shellUtils, "getShell").mockReturnValue("/mock/fallback-shell")
3739
mockTerminal = {
3840
provider: "execa",
3941
id: 1,
@@ -54,7 +56,7 @@ describe("ExecaTerminalProcess", () => {
5456

5557
afterEach(() => {
5658
process.env = originalEnv
57-
vitest.clearAllMocks()
59+
vitest.restoreAllMocks()
5860
})
5961

6062
describe("UTF-8 encoding fix", () => {
@@ -63,7 +65,7 @@ describe("ExecaTerminalProcess", () => {
6365
const execaMock = vitest.mocked(execa)
6466
expect(execaMock).toHaveBeenCalledWith(
6567
expect.objectContaining({
66-
shell: expect.any(String),
68+
shell: "/mock/fallback-shell",
6769
cwd: "/test/cwd",
6870
all: true,
6971
env: expect.objectContaining({
@@ -111,7 +113,7 @@ describe("ExecaTerminalProcess", () => {
111113
const execaMock = vitest.mocked(execa)
112114
expect(execaMock).toHaveBeenCalledWith(
113115
expect.objectContaining({
114-
shell: expect.any(String),
116+
shell: "/mock/fallback-shell",
115117
}),
116118
)
117119
})

0 commit comments

Comments
 (0)