Fix test expectations for AbortSignal parameter

- Update litellm, lmstudio, modelCache, and vercel-ai-gateway tests
- Tests now expect optional AbortSignal parameter (undefined when not provided)
- All 52 tests in affected files now passing
This commit is contained in:
daniel-lxs 2025-10-30 10:15:42 -05:00
parent 6aff586bb5
commit 9d0f01bf92
No known key found for this signature in database
GPG key ID: 21C74479048B3AA6
4 changed files with 26 additions and 20 deletions

View file

@ -35,7 +35,7 @@ describe("getLiteLLMModels", () => {
"Content-Type": "application/json",
...DEFAULT_HEADERS,
},
timeout: 5000,
signal: undefined,
})
})
@ -56,7 +56,7 @@ describe("getLiteLLMModels", () => {
"Content-Type": "application/json",
...DEFAULT_HEADERS,
},
timeout: 5000,
signal: undefined,
})
})
@ -77,7 +77,7 @@ describe("getLiteLLMModels", () => {
"Content-Type": "application/json",
...DEFAULT_HEADERS,
},
timeout: 5000,
signal: undefined,
})
})
@ -98,7 +98,7 @@ describe("getLiteLLMModels", () => {
"Content-Type": "application/json",
...DEFAULT_HEADERS,
},
timeout: 5000,
signal: undefined,
})
})
@ -119,7 +119,7 @@ describe("getLiteLLMModels", () => {
"Content-Type": "application/json",
...DEFAULT_HEADERS,
},
timeout: 5000,
signal: undefined,
})
})
@ -140,7 +140,7 @@ describe("getLiteLLMModels", () => {
"Content-Type": "application/json",
...DEFAULT_HEADERS,
},
timeout: 5000,
signal: undefined,
})
})
@ -161,7 +161,7 @@ describe("getLiteLLMModels", () => {
"Content-Type": "application/json",
...DEFAULT_HEADERS,
},
timeout: 5000,
signal: undefined,
})
})
@ -213,7 +213,7 @@ describe("getLiteLLMModels", () => {
"Content-Type": "application/json",
...DEFAULT_HEADERS,
},
timeout: 5000,
signal: undefined,
})
expect(result).toEqual({
@ -254,7 +254,7 @@ describe("getLiteLLMModels", () => {
"Content-Type": "application/json",
...DEFAULT_HEADERS,
},
timeout: 5000,
signal: undefined,
})
})
@ -381,7 +381,7 @@ describe("getLiteLLMModels", () => {
expect(mockedAxios.get).toHaveBeenCalledWith(
"http://localhost:4000/v1/model/info",
expect.objectContaining({
timeout: 5000,
signal: undefined,
}),
)
})

View file

@ -113,7 +113,7 @@ describe("LMStudio Fetcher", () => {
const result = await getLMStudioModels(baseUrl)
expect(mockedAxios.get).toHaveBeenCalledTimes(1)
expect(mockedAxios.get).toHaveBeenCalledWith(`${baseUrl}/v1/models`)
expect(mockedAxios.get).toHaveBeenCalledWith(`${baseUrl}/v1/models`, { signal: undefined })
expect(MockedLMStudioClientConstructor).toHaveBeenCalledTimes(1)
expect(MockedLMStudioClientConstructor).toHaveBeenCalledWith({ baseUrl: lmsUrl })
expect(mockListDownloadedModels).toHaveBeenCalledTimes(1)
@ -133,7 +133,7 @@ describe("LMStudio Fetcher", () => {
const result = await getLMStudioModels(baseUrl)
expect(mockedAxios.get).toHaveBeenCalledTimes(1)
expect(mockedAxios.get).toHaveBeenCalledWith(`${baseUrl}/v1/models`)
expect(mockedAxios.get).toHaveBeenCalledWith(`${baseUrl}/v1/models`, { signal: undefined })
expect(MockedLMStudioClientConstructor).toHaveBeenCalledTimes(1)
expect(MockedLMStudioClientConstructor).toHaveBeenCalledWith({ baseUrl: lmsUrl })
expect(mockListDownloadedModels).toHaveBeenCalledTimes(1)
@ -373,7 +373,7 @@ describe("LMStudio Fetcher", () => {
await getLMStudioModels("")
expect(mockedAxios.get).toHaveBeenCalledWith(`${defaultBaseUrl}/v1/models`)
expect(mockedAxios.get).toHaveBeenCalledWith(`${defaultBaseUrl}/v1/models`, { signal: undefined })
expect(MockedLMStudioClientConstructor).toHaveBeenCalledWith({ baseUrl: defaultLmsUrl })
})
@ -385,7 +385,7 @@ describe("LMStudio Fetcher", () => {
await getLMStudioModels(httpsBaseUrl)
expect(mockedAxios.get).toHaveBeenCalledWith(`${httpsBaseUrl}/v1/models`)
expect(mockedAxios.get).toHaveBeenCalledWith(`${httpsBaseUrl}/v1/models`, { signal: undefined })
expect(MockedLMStudioClientConstructor).toHaveBeenCalledWith({ baseUrl: wssLmsUrl })
})
@ -407,7 +407,7 @@ describe("LMStudio Fetcher", () => {
const result = await getLMStudioModels(baseUrl)
expect(mockedAxios.get).toHaveBeenCalledTimes(1)
expect(mockedAxios.get).toHaveBeenCalledWith(`${baseUrl}/v1/models`)
expect(mockedAxios.get).toHaveBeenCalledWith(`${baseUrl}/v1/models`, { signal: undefined })
expect(MockedLMStudioClientConstructor).not.toHaveBeenCalled()
expect(mockListLoaded).not.toHaveBeenCalled()
expect(consoleErrorSpy).toHaveBeenCalledWith(
@ -426,7 +426,7 @@ describe("LMStudio Fetcher", () => {
const result = await getLMStudioModels(baseUrl)
expect(mockedAxios.get).toHaveBeenCalledTimes(1)
expect(mockedAxios.get).toHaveBeenCalledWith(`${baseUrl}/v1/models`)
expect(mockedAxios.get).toHaveBeenCalledWith(`${baseUrl}/v1/models`, { signal: undefined })
expect(MockedLMStudioClientConstructor).not.toHaveBeenCalled()
expect(mockListLoaded).not.toHaveBeenCalled()
expect(consoleInfoSpy).toHaveBeenCalledWith(`Error connecting to LMStudio at ${baseUrl}`)

View file

@ -69,7 +69,11 @@ describe("getModels with new GetModelsOptions", () => {
baseUrl: "http://localhost:4000",
})
expect(mockGetLiteLLMModels).toHaveBeenCalledWith("test-api-key", "http://localhost:4000")
expect(mockGetLiteLLMModels).toHaveBeenCalledWith(
"test-api-key",
"http://localhost:4000",
expect.any(AbortSignal),
)
expect(result).toEqual(mockModels)
})
@ -103,7 +107,7 @@ describe("getModels with new GetModelsOptions", () => {
const result = await getModels({ provider: "requesty", apiKey: DUMMY_REQUESTY_KEY })
expect(mockGetRequestyModels).toHaveBeenCalledWith(undefined, DUMMY_REQUESTY_KEY)
expect(mockGetRequestyModels).toHaveBeenCalledWith(undefined, DUMMY_REQUESTY_KEY, expect.any(AbortSignal))
expect(result).toEqual(mockModels)
})
@ -137,7 +141,7 @@ describe("getModels with new GetModelsOptions", () => {
const result = await getModels({ provider: "unbound", apiKey: DUMMY_UNBOUND_KEY })
expect(mockGetUnboundModels).toHaveBeenCalledWith(DUMMY_UNBOUND_KEY)
expect(mockGetUnboundModels).toHaveBeenCalledWith(DUMMY_UNBOUND_KEY, expect.any(AbortSignal))
expect(result).toEqual(mockModels)
})

View file

@ -77,7 +77,9 @@ describe("Vercel AI Gateway Fetchers", () => {
const models = await getVercelAiGatewayModels()
expect(mockedAxios.get).toHaveBeenCalledWith("https://ai-gateway.vercel.sh/v1/models")
expect(mockedAxios.get).toHaveBeenCalledWith("https://ai-gateway.vercel.sh/v1/models", {
signal: undefined,
})
expect(Object.keys(models)).toHaveLength(2) // Only language models
expect(models["anthropic/claude-sonnet-4"]).toBeDefined()
expect(models["anthropic/claude-3.5-haiku"]).toBeDefined()