mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> Co-authored-by: CellenLee <99465814+CellenLee@users.noreply.github.com>
64 lines
1.8 KiB
TypeScript
64 lines
1.8 KiB
TypeScript
// npx vitest run src/shared/__tests__/checkExistApiConfig.spec.ts
|
|
|
|
import type { ProviderSettings } from "@roo-code/types"
|
|
|
|
import { checkExistKey } from "../checkExistApiConfig"
|
|
|
|
describe("checkExistKey", () => {
|
|
it("should return false for undefined config", () => {
|
|
expect(checkExistKey(undefined)).toBe(false)
|
|
})
|
|
|
|
it("should return false for empty config", () => {
|
|
const config: ProviderSettings = {}
|
|
expect(checkExistKey(config)).toBe(false)
|
|
})
|
|
|
|
it("should return true when one key is defined", () => {
|
|
const config: ProviderSettings = {
|
|
apiKey: "test-key",
|
|
}
|
|
expect(checkExistKey(config)).toBe(true)
|
|
})
|
|
|
|
it("should return true when multiple keys are defined", () => {
|
|
const config: ProviderSettings = {
|
|
apiKey: "test-key",
|
|
glamaApiKey: "glama-key",
|
|
openRouterApiKey: "openrouter-key",
|
|
}
|
|
expect(checkExistKey(config)).toBe(true)
|
|
})
|
|
|
|
it("should return true when only non-key fields are undefined", () => {
|
|
const config: ProviderSettings = {
|
|
apiKey: "test-key",
|
|
apiProvider: undefined,
|
|
anthropicBaseUrl: undefined,
|
|
modelMaxThinkingTokens: undefined,
|
|
}
|
|
expect(checkExistKey(config)).toBe(true)
|
|
})
|
|
|
|
it("should return false when all key fields are undefined", () => {
|
|
const config: ProviderSettings = {
|
|
apiKey: undefined,
|
|
glamaApiKey: undefined,
|
|
openRouterApiKey: undefined,
|
|
awsRegion: undefined,
|
|
vertexProjectId: undefined,
|
|
openAiApiKey: undefined,
|
|
ollamaModelId: undefined,
|
|
lmStudioModelId: undefined,
|
|
geminiApiKey: undefined,
|
|
openAiNativeApiKey: undefined,
|
|
deepSeekApiKey: undefined,
|
|
moonshotApiKey: undefined,
|
|
mistralApiKey: undefined,
|
|
vsCodeLmModelSelector: undefined,
|
|
requestyApiKey: undefined,
|
|
unboundApiKey: undefined,
|
|
}
|
|
expect(checkExistKey(config)).toBe(false)
|
|
})
|
|
})
|