Skip to content

Commit 4c42f91

Browse files
zoomote[bot]roomote
andauthored
refactor: reuse shared reset helper in semble and terminal specs (#1201)
Co-authored-by: Roomote <roomote@roomote.dev>
1 parent 03db526 commit 4c42f91

4 files changed

Lines changed: 12 additions & 4 deletions

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import { ExecaTerminalProcess } from "../ExecaTerminalProcess"
2828
import { BaseTerminal } from "../BaseTerminal"
2929
import type { RooTerminal } from "../types"
3030

31+
import { clearAllMocks } from "../../../test-utils/reset"
32+
3133
describe("ExecaTerminalProcess", () => {
3234
let mockTerminal: RooTerminal
3335
let terminalProcess: ExecaTerminalProcess
@@ -56,7 +58,7 @@ describe("ExecaTerminalProcess", () => {
5658

5759
afterEach(() => {
5860
process.env = originalEnv
59-
vitest.clearAllMocks()
61+
clearAllMocks()
6062
})
6163

6264
describe("UTF-8 encoding fix", () => {

‎src/services/code-index/semble/__tests__/provider.spec.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { SembleProvider } from "../provider"
44
import { SembleCLI } from "../semble-cli"
55
import { SEMBLE_DEFAULTS } from "../types"
66

7+
import { clearAllMocks } from "../../../../test-utils/reset"
8+
79
// Mock SembleCLI - use a shared mock instance
810
const sharedMockCli = {
911
checkInstalled: vi.fn(),
@@ -72,7 +74,7 @@ describe("SembleProvider", () => {
7274
let mockContext: any
7375

7476
beforeEach(() => {
75-
vi.clearAllMocks()
77+
clearAllMocks()
7678
;(isSembleSupportedPlatform as any).mockReturnValue(true)
7779
;(downloadSemble as any).mockResolvedValue("/mock/storage/semble/semble")
7880

‎src/services/code-index/semble/__tests__/semble-cli.spec.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { describe, it, expect, vi, beforeEach } from "vitest"
22
import { EventEmitter } from "events"
33
import { SembleCLI } from "../semble-cli"
44

5+
import { clearAllMocks } from "../../../../test-utils/reset"
6+
57
// Mock spawn
68
const mockSpawn = vi.fn()
79

@@ -46,7 +48,7 @@ describe("SembleCLI", () => {
4648
let cli: SembleCLI
4749

4850
beforeEach(() => {
49-
vi.clearAllMocks()
51+
clearAllMocks()
5052
cli = new SembleCLI("semble")
5153
})
5254

‎src/services/code-index/semble/__tests__/semble-downloader.spec.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import * as fs from "fs/promises"
33
import * as path from "path"
44
import { EventEmitter } from "events"
55

6+
import { clearAllMocks } from "../../../../test-utils/reset"
7+
68
// Mock crypto — verifyChecksum reads the archive file (mocked via createReadStream)
79
// and computes a SHA-256. We make digest() dynamically return the expected checksum
810
// for the current process.platform/arch so verification always passes in unit tests.
@@ -111,7 +113,7 @@ describe("SEMBLE_SHA256 checksum fixture", () => {
111113

112114
describe("semble-downloader", () => {
113115
beforeEach(() => {
114-
vi.clearAllMocks()
116+
clearAllMocks()
115117
closeHandler = undefined
116118
mockWriteStream.on = vi.fn(onWriteStreamEvent)
117119
mockWriteStream.close = vi.fn(() => closeHandler?.())

0 commit comments

Comments
 (0)