Skip to content

Commit e454ec6

Browse files
committed
revised test comments
1 parent 19be0d2 commit e454ec6

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

src/utils/__tests__/autoImportConfig.spec.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ vi.mock("vscode", () => ({
1414
vi.mock("fs/promises", () => ({
1515
__esModule: true,
1616
default: {
17-
readFile: vi.fn(), // This will be fs.default.readFile for the test
18-
// If other default export properties are used by SUT, mock them here
17+
readFile: vi.fn(),
1918
},
20-
// If SUT or tests use named exports from "fs/promises" (e.g. import { stat } from "fs/promises")
21-
readFile: vi.fn(), // Example for a named export
19+
readFile: vi.fn(),
2220
}))
2321

2422
vi.mock("path", () => ({
@@ -51,20 +49,15 @@ vi.mock("../../core/config/ProviderSettingsManager", async (importOriginal) => {
5149
}),
5250
import: vi.fn().mockResolvedValue({ success: true }),
5351
listConfig: vi.fn().mockResolvedValue([]),
54-
// Add other methods of ProviderSettingsManager here if they are called
5552
})),
56-
// Ensure providerProfilesSchema is the actual schema, not a mock fn
57-
// If providerProfilesSchema is exported from this module, it will be retained by the spread.
58-
// If it's a named export and you want to be explicit:
59-
// providerProfilesSchema: (originalModule as any).providerProfilesSchema,
6053
}
6154
})
6255
vi.mock("../../core/config/ContextProxy")
6356
vi.mock("../../core/config/CustomModesManager")
6457

6558
import { autoImportConfig } from "../autoImportConfig"
6659
import * as vscode from "vscode"
67-
import fsPromises from "fs/promises" // Changed from * as fs
60+
import fsPromises from "fs/promises"
6861
import { fileExistsAtPath } from "../fs"
6962

7063
describe("autoImportConfig", () => {
@@ -90,7 +83,7 @@ describe("autoImportConfig", () => {
9083
modeApiConfigs: {},
9184
currentApiConfigName: "default",
9285
}),
93-
import: vi.fn().mockResolvedValue({ success: true }), // Changed to return an object
86+
import: vi.fn().mockResolvedValue({ success: true }),
9487
listConfig: vi.fn().mockResolvedValue([]),
9588
}
9689

@@ -109,10 +102,9 @@ describe("autoImportConfig", () => {
109102
// mockProvider must be initialized AFTER its dependencies
110103
mockProvider = {
111104
providerSettingsManager: mockProviderSettingsManager,
112-
contextProxy: mockContextProxy, // Now mockContextProxy is defined
113-
upsertProviderProfile: vi.fn().mockResolvedValue({ success: true }), // Return an object
114-
postStateToWebview: vi.fn().mockResolvedValue({ success: true }), // Return an object
115-
// settingsImportedAt will be set directly by the SUT
105+
contextProxy: mockContextProxy,
106+
upsertProviderProfile: vi.fn().mockResolvedValue({ success: true }),
107+
postStateToWebview: vi.fn().mockResolvedValue({ success: true }),
116108
}
117109

118110
// Reset fs mock
@@ -192,8 +184,7 @@ describe("autoImportConfig", () => {
192184
customInstructions: "Test instructions",
193185
},
194186
}
195-
// The SUT uses `import fs from "fs/promises"`, then `fs.readFile`.
196-
// In the test, `import * as fs` means this is `fs.default.readFile`.
187+
197188
vi.mocked(fsPromises.readFile).mockResolvedValue(JSON.stringify(mockConfig) as any)
198189

199190
await autoImportConfig({

0 commit comments

Comments
 (0)