Skip to content

Commit 8f2af07

Browse files
committed
Update openAI pinecone mocking to avoid error
1 parent 07221e5 commit 8f2af07

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

course-matrix/backend/__tests__/timetablesController.test.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,20 @@ jest.mock("@ai-sdk/openai", () => ({
1515

1616
jest.mock("ai", () => ({
1717
streamText: jest.fn(() =>
18-
Promise.resolve({ pipeDataStreamToResponse: jest.fn() }),
18+
Promise.resolve({ pipeDataStreamToResponse: jest.fn() })
1919
),
2020
}));
2121

22+
jest.mock("@pinecone-database/pinecone", () => ({
23+
Pinecone: jest.fn(() => ({
24+
Index: jest.fn(() => ({
25+
query: jest.fn(),
26+
upsert: jest.fn(),
27+
delete: jest.fn(),
28+
})),
29+
})),
30+
}));
31+
2232
// Function to create authenticated session dynamically based as provided user_id
2333
const mockAuthHandler = (user_id: string) => {
2434
return (req: Request, res: Response, next: NextFunction) => {
@@ -179,7 +189,7 @@ describe("GET /api/timetables", () => {
179189
(
180190
authHandler as jest.MockedFunction<typeof authHandler>
181191
).mockImplementationOnce(
182-
mockAuthHandler("testuser01-ab9e6877-f603-4c6a-9832-864e520e4d01"),
192+
mockAuthHandler("testuser01-ab9e6877-f603-4c6a-9832-864e520e4d01")
183193
);
184194

185195
const response = await request(app).get("/api/timetables");
@@ -194,7 +204,7 @@ describe("GET /api/timetables", () => {
194204
(
195205
authHandler as jest.MockedFunction<typeof authHandler>
196206
).mockImplementationOnce(
197-
mockAuthHandler("testuser02-1d3f02df-f926-4c1f-9f41-58ca50816a33"),
207+
mockAuthHandler("testuser02-1d3f02df-f926-4c1f-9f41-58ca50816a33")
198208
);
199209

200210
const response = await request(app).get("/api/timetables");

0 commit comments

Comments
 (0)