Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

1.7 KB
Raw Blame
import { describe, expect, it } from "vitest";
import { issueLabel } from "./issueLabel";

describe("issueLabel", () => {
  it("names the Input field for both endpoints instead of the JSON key", () => {
    expect(issueLabel(["state"])).toBe("Input");
    expect(issueLabel(["input"])).toBe("Input");
  });

  it("names top-level fields and the request itself", () => {
    expect(issueLabel(["model"])).toBe("Model");
    expect(issueLabel(["questions"])).toBe("Questions");
    expect(issueLabel(["safety_identifier"])).toBe("Safety identifier");
    expect(issueLabel([])).toBe("Request");
    expect(issueLabel(["syntax"])).toBe("Request");
  });

  it("names a keyed question by its key, even an all-digit or dotted one, and the field inside it", () => {
    expect(issueLabel(["questions", "urgency"])).toBe('Question "urgency"');
    expect(issueLabel(["questions", "urgency", "criteria"])).toBe('Question "urgency" options');
    expect(issueLabel(["questions", "urgency", "criteria", 1])).toBe('Question "urgency" options');
    expect(issueLabel(["questions", "category", "instructions"])).toBe('Question "category" instructions');
    expect(issueLabel(["questions", "2", "criteria"])).toBe('Question "2" options');
    expect(issueLabel(["questions", "v1.2", "type"])).toBe('Question "v1.2" answer type');
  });

  it("names a listed question by its 1-based position", () => {
    expect(issueLabel(["questions", 0, "name"])).toBe("Question 1 name");
    expect(issueLabel(["questions", 2, "type"])).toBe("Question 3 answer type");
  });

  it("falls back to the humanized key for anything unknown", () => {
    expect(issueLabel(["max_tokens"])).toBe("max tokens");
    expect(issueLabel(["questions", "a", "max_items"])).toBe('Question "a" max items');
  });
});