Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

claudeCompaction.test.ts

33 lines1.2 KB

1import { describe, expect, it } from "vite-plus/test";
2​
3import {
4 formatClaudeResumeCompactionQuestion,
5 isClaudeResumeCompactionQuestion,
6} from "./claudeCompaction.ts";
7​
8describe("claude resume compaction copy", () => {
9 it.each([
10 { ageMinutes: 145, estimatedTokens: 275_123 },
11 { ageMinutes: 70, estimatedTokens: 100_000 },
12 { ageMinutes: 59, estimatedTokens: 1_234_567 },
13 { ageMinutes: 0, estimatedTokens: 0 },
14 ])("matches its own formatted question (%o)", (input) => {
15 const question = formatClaudeResumeCompactionQuestion(input);
16 expect(isClaudeResumeCompactionQuestion(question)).toBe(true);
17 });
18​
19 it("formats ages above and below one hour", () => {
20 expect(
21 formatClaudeResumeCompactionQuestion({ ageMinutes: 145, estimatedTokens: 275_123 }),
22 ).toBe("This session is 2h 25m old and uses 275,123 tokens. Compact it before continuing?");
23 expect(formatClaudeResumeCompactionQuestion({ ageMinutes: 45, estimatedTokens: 1_000 })).toBe(
24 "This session is 45m old and uses 1,000 tokens. Compact it before continuing?",
25 );
26 });
27​
28 it("does not match unrelated questions", () => {
29 expect(
30 isClaudeResumeCompactionQuestion("The build cache is large. Compact it before continuing?"),
31 ).toBe(false);
32 });
33});