forked from ericc-ch/copilot-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilter-models.test.ts
More file actions
48 lines (39 loc) · 1.42 KB
/
filter-models.test.ts
File metadata and controls
48 lines (39 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { describe, it, expect } from "bun:test"
import { filterModels, isInternalModel } from "./filter-models"
describe("isInternalModel", () => {
it("returns true for IDs containing 'internal'", () => {
expect(isInternalModel("gpt-internal-v1")).toBe(true)
})
it("returns true for IDs starting with 'accounts/'", () => {
expect(isInternalModel("accounts/my-org/model")).toBe(true)
})
it("returns false for normal IDs", () => {
expect(isInternalModel("gpt-4o")).toBe(false)
})
})
describe("filterModels", () => {
const models = [
{ id: "gpt-4o", owned_by: "OpenAI" },
{ id: "internal-preview", owned_by: "OpenAI" },
{ id: "accounts/org/custom", owned_by: "Custom" },
{ id: "claude-sonnet-4", owned_by: "Anthropic" },
]
it("returns all models when no filters", () => {
expect(filterModels(models, false)).toHaveLength(4)
})
it("filters internal models", () => {
const result = filterModels(models, true)
expect(result).toHaveLength(2)
expect(result.map((m) => m.id)).toEqual(["gpt-4o", "claude-sonnet-4"])
})
it("filters by vendor", () => {
const result = filterModels(models, false, "anthropic")
expect(result).toHaveLength(1)
expect(result[0].id).toBe("claude-sonnet-4")
})
it("combines internal + vendor filters", () => {
const result = filterModels(models, true, "openai")
expect(result).toHaveLength(1)
expect(result[0].id).toBe("gpt-4o")
})
})