mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-14 12:38:34 +00:00
Configure: improve searchable model picker token matching
This commit is contained in:
35
src/wizard/clack-prompter.test.ts
Normal file
35
src/wizard/clack-prompter.test.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { tokenizedOptionFilter } from "./clack-prompter.js";
|
||||
|
||||
describe("tokenizedOptionFilter", () => {
|
||||
it("matches tokens regardless of order", () => {
|
||||
const option = {
|
||||
value: "openai/gpt-5.2",
|
||||
label: "openai/gpt-5.2",
|
||||
hint: "ctx 400k",
|
||||
};
|
||||
|
||||
expect(tokenizedOptionFilter("gpt-5.2 openai/", option)).toBe(true);
|
||||
expect(tokenizedOptionFilter("openai/ gpt-5.2", option)).toBe(true);
|
||||
});
|
||||
|
||||
it("requires all tokens to match", () => {
|
||||
const option = {
|
||||
value: "openai/gpt-5.2",
|
||||
label: "openai/gpt-5.2",
|
||||
};
|
||||
|
||||
expect(tokenizedOptionFilter("gpt-5.2 anthropic/", option)).toBe(false);
|
||||
});
|
||||
|
||||
it("matches against label, hint, and value", () => {
|
||||
const option = {
|
||||
value: "openai/gpt-5.2",
|
||||
label: "GPT 5.2",
|
||||
hint: "provider openai",
|
||||
};
|
||||
|
||||
expect(tokenizedOptionFilter("provider openai", option)).toBe(true);
|
||||
expect(tokenizedOptionFilter("openai gpt-5.2", option)).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user