Open History to see the last commit
1import { RUN_STOPPED_BY_PROVIDER_REASON, RUN_STOPPED_BY_USER_REASON } from "@t3tools/contracts";
2import { mFallback } from "gt-i18n";
3import type { MFunctionType } from "gt-i18n/types";
4import { describe, expect, it } from "vite-plus/test";
5
6import { runStopReasonLabel } from "./contractLabels.ts";
7
8describe("runStopReasonLabel", () => {
9 const german = ((message, options) => `de: ${mFallback(message, options)}`) as MFunctionType;
10
11 it("translates the reasons the server writes when no one gave one", () => {
12 expect(runStopReasonLabel(RUN_STOPPED_BY_USER_REASON, german)).toBe("de: Stopped by user");
13 expect(runStopReasonLabel(RUN_STOPPED_BY_PROVIDER_REASON, german)).toBe(
14 "de: Stopped by the provider",
15 );
16 });
17
18 it("shows an agent's own reason as written", () => {
19 expect(runStopReasonLabel("Stopped by an agent: tests pass", german)).toBe(
20 "Stopped by an agent: tests pass",
21 );
22 });
23});