| 1 | import { render } from "ink-testing-library"; |
| 2 | import React from "react"; |
| 3 | import { describe, expect, test } from "vitest"; |
| 4 | |
| 5 | import { ModelCapabilityWarning } from "./ModelCapabilityWarning.js"; |
| 6 | |
| 7 | describe("ModelCapabilityWarning", () => { |
| 8 | test("should render warning message with model name", () => { |
| 9 | const { lastFrame } = render( |
| 10 | React.createElement(ModelCapabilityWarning, { |
| 11 | modelName: "gpt-3-davinci", |
| 12 | }), |
| 13 | ); |
| 14 | |
| 15 | const frame = lastFrame(); |
| 16 | if (frame) { |
| 17 | expect(frame).toContain("Model Capability Warning"); |
| 18 | expect(frame).toContain("gpt-3-davinci"); |
| 19 | expect(frame).toContain( |
| 20 | "is not recommended for use with cn due to limited reasoning and tool", |
| 21 | ); |
| 22 | expect(frame).toContain("calling capabilities"); |
| 23 | } |
| 24 | }); |
| 25 | |
| 26 | test("should handle model names with slashes", () => { |
| 27 | const { lastFrame } = render( |
| 28 | React.createElement(ModelCapabilityWarning, { |
| 29 | modelName: "local/mistral-7b", |
| 30 | }), |
| 31 | ); |
| 32 | |
| 33 | const frame = lastFrame(); |
| 34 | if (frame) { |
| 35 | expect(frame).toContain("local/mistral-7b"); |
| 36 | } |
| 37 | }); |
| 38 | |
| 39 | test("should display warning icon", () => { |
| 40 | const { lastFrame } = render( |
| 41 | React.createElement(ModelCapabilityWarning, { modelName: "test-model" }), |
| 42 | ); |
| 43 | |
| 44 | const frame = lastFrame(); |
| 45 | if (frame) { |
| 46 | expect(frame).toContain("⚠️"); |
| 47 | } |
| 48 | }); |
| 49 | }); |