Skip to content

Commit 7466221

Browse files
committed
fix: update service-factory tests to expect outputChannel parameter
The embedder constructors now accept an optional outputChannel parameter for logging. Updated all test expectations to include this new parameter using expect.objectContaining() to match the mock output channel object structure.
1 parent c41ccbf commit 7466221

File tree

1 file changed

+74
-18
lines changed

1 file changed

+74
-18
lines changed

src/services/code-index/__tests__/service-factory.spec.ts

Lines changed: 74 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,19 @@ describe("CodeIndexServiceFactory", () => {
7373
factory.createEmbedder()
7474

7575
// Assert
76-
expect(MockedOpenAiEmbedder).toHaveBeenCalledWith({
77-
openAiNativeApiKey: "test-api-key",
78-
openAiEmbeddingModelId: testModelId,
79-
})
76+
expect(MockedOpenAiEmbedder).toHaveBeenCalledWith(
77+
{
78+
openAiNativeApiKey: "test-api-key",
79+
openAiEmbeddingModelId: testModelId,
80+
},
81+
expect.objectContaining({
82+
append: expect.any(Function),
83+
appendLine: expect.any(Function),
84+
clear: expect.any(Function),
85+
dispose: expect.any(Function),
86+
show: expect.any(Function),
87+
}), // outputChannel
88+
)
8089
})
8190

8291
it("should pass model ID to Ollama embedder when using Ollama provider", () => {
@@ -95,10 +104,19 @@ describe("CodeIndexServiceFactory", () => {
95104
factory.createEmbedder()
96105

97106
// Assert
98-
expect(MockedCodeIndexOllamaEmbedder).toHaveBeenCalledWith({
99-
ollamaBaseUrl: "http://localhost:11434",
100-
ollamaModelId: testModelId,
101-
})
107+
expect(MockedCodeIndexOllamaEmbedder).toHaveBeenCalledWith(
108+
{
109+
ollamaBaseUrl: "http://localhost:11434",
110+
ollamaModelId: testModelId,
111+
},
112+
expect.objectContaining({
113+
append: expect.any(Function),
114+
appendLine: expect.any(Function),
115+
clear: expect.any(Function),
116+
dispose: expect.any(Function),
117+
show: expect.any(Function),
118+
}), // outputChannel
119+
)
102120
})
103121

104122
it("should handle undefined model ID for OpenAI embedder", () => {
@@ -116,10 +134,19 @@ describe("CodeIndexServiceFactory", () => {
116134
factory.createEmbedder()
117135

118136
// Assert
119-
expect(MockedOpenAiEmbedder).toHaveBeenCalledWith({
120-
openAiNativeApiKey: "test-api-key",
121-
openAiEmbeddingModelId: undefined,
122-
})
137+
expect(MockedOpenAiEmbedder).toHaveBeenCalledWith(
138+
{
139+
openAiNativeApiKey: "test-api-key",
140+
openAiEmbeddingModelId: undefined,
141+
},
142+
expect.objectContaining({
143+
append: expect.any(Function),
144+
appendLine: expect.any(Function),
145+
clear: expect.any(Function),
146+
dispose: expect.any(Function),
147+
show: expect.any(Function),
148+
}), // outputChannel
149+
)
123150
})
124151

125152
it("should handle undefined model ID for Ollama embedder", () => {
@@ -137,10 +164,19 @@ describe("CodeIndexServiceFactory", () => {
137164
factory.createEmbedder()
138165

139166
// Assert
140-
expect(MockedCodeIndexOllamaEmbedder).toHaveBeenCalledWith({
141-
ollamaBaseUrl: "http://localhost:11434",
142-
ollamaModelId: undefined,
143-
})
167+
expect(MockedCodeIndexOllamaEmbedder).toHaveBeenCalledWith(
168+
{
169+
ollamaBaseUrl: "http://localhost:11434",
170+
ollamaModelId: undefined,
171+
},
172+
expect.objectContaining({
173+
append: expect.any(Function),
174+
appendLine: expect.any(Function),
175+
clear: expect.any(Function),
176+
dispose: expect.any(Function),
177+
show: expect.any(Function),
178+
}), // outputChannel
179+
)
144180
})
145181

146182
it("should throw error when OpenAI API key is missing", () => {
@@ -299,7 +335,17 @@ describe("CodeIndexServiceFactory", () => {
299335
factory.createEmbedder()
300336

301337
// Assert
302-
expect(MockedGeminiEmbedder).toHaveBeenCalledWith("test-gemini-api-key", undefined)
338+
expect(MockedGeminiEmbedder).toHaveBeenCalledWith(
339+
"test-gemini-api-key",
340+
undefined,
341+
expect.objectContaining({
342+
append: expect.any(Function),
343+
appendLine: expect.any(Function),
344+
clear: expect.any(Function),
345+
dispose: expect.any(Function),
346+
show: expect.any(Function),
347+
}), // outputChannel
348+
)
303349
})
304350

305351
it("should create GeminiEmbedder with specified modelId", () => {
@@ -317,7 +363,17 @@ describe("CodeIndexServiceFactory", () => {
317363
factory.createEmbedder()
318364

319365
// Assert
320-
expect(MockedGeminiEmbedder).toHaveBeenCalledWith("test-gemini-api-key", "text-embedding-004")
366+
expect(MockedGeminiEmbedder).toHaveBeenCalledWith(
367+
"test-gemini-api-key",
368+
"text-embedding-004",
369+
expect.objectContaining({
370+
append: expect.any(Function),
371+
appendLine: expect.any(Function),
372+
clear: expect.any(Function),
373+
dispose: expect.any(Function),
374+
show: expect.any(Function),
375+
}), // outputChannel
376+
)
321377
})
322378

323379
it("should throw error when Gemini API key is missing", () => {

0 commit comments

Comments
 (0)