# tests/core/predicates/text.predicate.test.ts

> 24 lines of code and 0 definitions.

Tree: Coordination tree
Language: typescript
Canonical: https://banes-lab.com/anatomy/coordination#file-coordination-tests-core-predicates-text-predicate-test-ts
Source text: https://banes-lab.com/assets/sources/source.65508183d69695005e97f0de67394f0379d80a305aa2f7253a4df34b21e4827c.generated.txt

## Source

```typescript
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(""), []);
    });
});
```
