mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
// Novita tests cover index plugin behavior.
|
|
import { registerSingleProviderPlugin } from "openclaw/plugin-sdk/plugin-test-runtime";
|
|
import { describe, expect, it } from "vitest";
|
|
import plugin from "./index.js";
|
|
|
|
function requireCatalogProvider(
|
|
result:
|
|
| { provider: { baseUrl?: string; models?: Array<{ id: string }> } }
|
|
| { providers: Record<string, unknown> }
|
|
| null
|
|
| undefined,
|
|
): { baseUrl?: string; models?: Array<{ id: string }> } {
|
|
if (!result || !("provider" in result)) {
|
|
throw new Error("single provider catalog result missing");
|
|
}
|
|
return result.provider;
|
|
}
|
|
|
|
describe("novita provider plugin", () => {
|
|
it("registers NovitaAI as an OpenAI-compatible provider", async () => {
|
|
const provider = await registerSingleProviderPlugin(plugin);
|
|
|
|
expect(provider.id).toBe("novita");
|
|
expect(provider.aliases).toEqual(["novita-ai", "novitaai"]);
|
|
expect(provider.envVars).toEqual(["NOVITA_API_KEY"]);
|
|
expect(provider.auth?.map((method) => method.id)).toEqual(["api-key"]);
|
|
|
|
const result = await provider.staticCatalog?.run({
|
|
config: {},
|
|
env: {},
|
|
resolveProviderApiKey: () => ({}),
|
|
} as never);
|
|
const catalogProvider = requireCatalogProvider(result);
|
|
expect(catalogProvider.baseUrl).toBe("https://api.novita.ai/openai/v1");
|
|
expect(catalogProvider.models?.map((model) => model.id)).toContain("deepseek/deepseek-v3-0324");
|
|
});
|
|
});
|