Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/frontend/packages/swarm-ui/test/max-subagents.test.mjs

26 lines
1,002 B
JavaScript

// The max-subagents field: empty is no cap, 0 is no subagents, and anything
// that is not a whole number up to the limit is refused. Run by `npm test`.
import assert from "node:assert/strict";
import { test } from "node:test";
import {
MAX_SUBAGENTS,
maxSubagentsValue,
} from "../src/agent/detail/max-subagents.ts";
test("empty is no cap, and 0 is a cap of none rather than empty", () => {
assert.equal(maxSubagentsValue(""), undefined);
assert.equal(maxSubagentsValue(" "), undefined);
assert.equal(maxSubagentsValue("0"), 0);
});
test("a whole number up to the limit is taken as typed", () => {
assert.equal(maxSubagentsValue("1"), 1);
assert.equal(maxSubagentsValue(" 3 "), 3);
assert.equal(maxSubagentsValue(String(MAX_SUBAGENTS)), MAX_SUBAGENTS);
});
test("above the limit, negative, fractional or not a number is refused", () => {
for (const text of [String(MAX_SUBAGENTS + 1), "-1", "1.5", "abc", "1e1"]) {
assert.equal(maxSubagentsValue(text), null, text);
}
});