import { contains, hasPrefix, splitWords } from "../../../tools/core/predicates/text.predicate.ts"; import { describe, it } from "node:test"; import assert from "node:assert/strict"; describe("contains and hasPrefix", () => { it("answers substring and prefix questions, treating the empty needle as present", () => { assert.equal(contains("board.rule.ts", "rule"), true); assert.equal(contains("a", ""), true); assert.equal(contains("a", "ab"), false); assert.equal(hasPrefix("tools/core", "tools"), true); assert.equal(hasPrefix("to", "tools"), false); }); }); describe("splitWords", () => { it("splits a command on blanks, keeping quoted runs whole without their quotes", () => { assert.deepEqual(splitWords(`node tools/run.ts --name "two words"\t'x'`), [ "node", "tools/run.ts", "--name", "two words", "x", ]); assert.deepEqual(splitWords(""), []); }); });