Skip to content

Commit 891fd24

Browse files
committed
Add tests
1 parent 3a1f015 commit 891fd24

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

test/unit/router.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ describe("Router", () => {
181181
expect(result).toContain("[ERROR]");
182182
expect(result).toContain("Unsupported");
183183
});
184+
185+
it("routes to zai provider without throwing", async () => {
186+
router.updateProvider("zai", "test-key", "glm-5");
187+
expect(router.getProviderName()).toBe("zai");
188+
expect(router.getCurrentModel()).toBe("glm-5");
189+
});
184190
});
185191

186192
describe("abortCurrentCommand", () => {

test/unit/zai-provider.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { describe, it, expect, beforeEach } from "vitest";
2+
import { loadModelsCatalog, clearCatalogCache } from "../../src/utils/models-catalog-loader";
3+
4+
describe("Z.ai provider", () => {
5+
beforeEach(() => {
6+
clearCatalogCache();
7+
});
8+
9+
describe("model catalog", () => {
10+
it("is discovered by the catalog loader", () => {
11+
const catalog = loadModelsCatalog();
12+
expect(catalog.providers.zai).toBeDefined();
13+
});
14+
15+
it("has correct provider name", () => {
16+
const catalog = loadModelsCatalog();
17+
expect(catalog.providers.zai.name).toBe("Z.ai");
18+
});
19+
20+
it("includes all expected models", () => {
21+
const catalog = loadModelsCatalog();
22+
const ids = catalog.providers.zai.models.map((m) => m.id);
23+
expect(ids).toContain("glm-5");
24+
expect(ids).toContain("glm-4.7");
25+
expect(ids).toContain("glm-4.6");
26+
});
27+
28+
it("has glm-5 marked as recommended", () => {
29+
const catalog = loadModelsCatalog();
30+
const glm5 = catalog.providers.zai.models.find((m) => m.id === "glm-5");
31+
expect(glm5).toBeDefined();
32+
expect(glm5!.recommended).toBe(true);
33+
});
34+
35+
it("every model has a description", () => {
36+
const catalog = loadModelsCatalog();
37+
for (const model of catalog.providers.zai.models) {
38+
expect(model.description).toBeDefined();
39+
expect(model.description.length).toBeGreaterThan(0);
40+
}
41+
});
42+
});
43+
});

0 commit comments

Comments
 (0)