forked from Lilly-Protocol/agentlily-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel-provider.test.ts
More file actions
59 lines (48 loc) · 1.92 KB
/
Copy pathmodel-provider.test.ts
File metadata and controls
59 lines (48 loc) · 1.92 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
49
50
51
52
53
54
55
56
57
58
59
import { describe, it, expect } from "vitest";
import { UnconfiguredModelProvider } from "../../src/providers/model-provider.js";
describe("UnconfiguredModelProvider", () => {
const provider = new UnconfiguredModelProvider();
it("has name set to 'unconfigured'", () => {
expect(provider.name).toBe("unconfigured");
});
it("returns stable outputText regardless of prompt input", async () => {
const response = await provider.generate({
instructions: "ignored-instructions",
input: "ignored-input"
});
expect(response.outputText).toBe(
"No model provider is configured. Contributors can implement one behind the ModelProvider interface."
);
});
it("returns same response shape for empty prompt", async () => {
const response = await provider.generate({ instructions: "", input: "" });
expect(response).toHaveProperty("outputText");
expect(typeof response.outputText).toBe("string");
expect(response.outputText.length).toBeGreaterThan(0);
});
it("reports zero lengths when prompt fields are absent at runtime", async () => {
const response = await provider.generate(
{} as { instructions: string; input: string }
);
expect(response.metadata).toMatchObject({
instructionsLength: 0,
inputLength: 0
});
});
it("ignores prompt arguments completely", async () => {
const r1 = await provider.generate({ instructions: "a", input: "b" });
const r2 = await provider.generate({
instructions: "completely-different",
input: "also-different"
});
expect(r1.outputText).toBe(r2.outputText);
});
it("handles undefined instructions or input gracefully in metadata", async () => {
const response = await provider.generate({} as unknown as { instructions: string; input: string });
expect(response.metadata).toEqual({
warning: "unconfigured_provider",
instructionsLength: 0,
inputLength: 0
});
});
});