30 lines
994 B
TypeScript
30 lines
994 B
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import {
|
|
BTW_TITLE_MAX_LENGTH,
|
|
deriveBtwTitle,
|
|
isModelVisible,
|
|
} from "./src/by-the-way.ts";
|
|
|
|
test("deriveBtwTitle uses the first non-empty line and bounds the title", () => {
|
|
assert.equal(
|
|
deriveBtwTitle("\n Why does this work? \nignore me"),
|
|
"Why does this work?",
|
|
);
|
|
assert.equal(deriveBtwTitle(" \n\t"), "by the way");
|
|
|
|
const title = deriveBtwTitle("x".repeat(BTW_TITLE_MAX_LENGTH + 10));
|
|
assert.equal(title.length, BTW_TITLE_MAX_LENGTH);
|
|
assert.equal(title, `${"x".repeat(BTW_TITLE_MAX_LENGTH - 1)}…`);
|
|
|
|
const emojiTitle = deriveBtwTitle(
|
|
`${"x".repeat(BTW_TITLE_MAX_LENGTH - 2)}😀 more`,
|
|
);
|
|
assert.equal(emojiTitle, `${"x".repeat(BTW_TITLE_MAX_LENGTH - 2)}😀…`);
|
|
});
|
|
|
|
test("only model-origin snapshots are visible to model-facing tools", () => {
|
|
assert.equal(isModelVisible({ origin: "model" }), true);
|
|
assert.equal(isModelVisible({ origin: "btw" }), false);
|
|
});
|