bb6a1321fb
Multi-line tmux strip (context, quota, tools, todos, git), theme sync with Grok UI, full/essential/minimal presets, one-shot installer, EN+ZH docs, and 40 unit tests.
42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
import { describe, it } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import {
|
|
clampPercent,
|
|
contextPercentFromSignals,
|
|
formatTokenCount,
|
|
renderBar,
|
|
formatDuration,
|
|
projectLabel,
|
|
} from "../src/bar.js";
|
|
|
|
describe("bar", () => {
|
|
it("derives context percent from contextWindowUsage", () => {
|
|
assert.equal(
|
|
contextPercentFromSignals({
|
|
contextWindowUsage: 37,
|
|
contextTokensUsed: 190000,
|
|
contextWindowTokens: 500000,
|
|
}),
|
|
37,
|
|
);
|
|
});
|
|
|
|
it("falls back to used/window ratio", () => {
|
|
assert.equal(
|
|
contextPercentFromSignals({
|
|
contextTokensUsed: 250000,
|
|
contextWindowTokens: 500000,
|
|
}),
|
|
50,
|
|
);
|
|
});
|
|
|
|
it("clamps and formats", () => {
|
|
assert.equal(clampPercent(150), 100);
|
|
assert.equal(renderBar(37, 10).length, 10);
|
|
assert.match(formatTokenCount(190000), /190k|190\.0k/);
|
|
assert.equal(formatDuration(4620), "1h 17m");
|
|
assert.equal(projectLabel("/Users/dex/demo/CoachFlow", 2), "demo/CoachFlow");
|
|
});
|
|
});
|