53 lines
1.7 KiB
JavaScript
53 lines
1.7 KiB
JavaScript
// Which terminal rows the two preferences hide. Run by `npm test`, which
|
|
// imports the `.ts` module as it is.
|
|
import assert from "node:assert/strict";
|
|
import { test } from "node:test";
|
|
import {
|
|
rowHidden,
|
|
rowIsFilterable,
|
|
} from "../../shared/src/terminal/row-visibility.ts";
|
|
|
|
const thinking = { level: "debug", kind: "thinking" };
|
|
const chatter = { level: "debug" };
|
|
const info = { level: "info" };
|
|
|
|
test("thinking follows show thinking alone", () => {
|
|
assert.equal(rowHidden(thinking, false, true), false);
|
|
assert.equal(
|
|
rowHidden(thinking, true, true),
|
|
false,
|
|
"developer details are hidden, thinking is not",
|
|
);
|
|
assert.equal(
|
|
rowHidden(thinking, false, false),
|
|
true,
|
|
"developer details are shown, thinking is not",
|
|
);
|
|
assert.equal(rowHidden(thinking, true, false), true);
|
|
});
|
|
|
|
test("other debug rows follow hide developer details alone", () => {
|
|
assert.equal(rowHidden(chatter, false, true), false);
|
|
assert.equal(rowHidden(chatter, true, true), true);
|
|
assert.equal(rowHidden(chatter, true, false), true);
|
|
assert.equal(
|
|
rowHidden(chatter, false, false),
|
|
false,
|
|
"hiding thinking leaves the rest",
|
|
);
|
|
});
|
|
|
|
test("a row of any other level is always shown", () => {
|
|
for (const hide of [true, false])
|
|
for (const show of [true, false]) {
|
|
assert.equal(rowHidden(info, hide, show), false);
|
|
assert.equal(rowHidden({ level: "error" }, hide, show), false);
|
|
}
|
|
});
|
|
|
|
test("only debug and thinking rows can be hidden", () => {
|
|
assert.equal(rowIsFilterable(thinking), true);
|
|
assert.equal(rowIsFilterable(chatter), true);
|
|
assert.equal(rowIsFilterable(info), false);
|
|
assert.equal(rowIsFilterable({ level: "warn" }), false);
|
|
});
|