# test.build/core/predicates/exclusion.predicate.test.ts

> 25 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-build-core-predicates-exclusion-predicate-test-ts
Source text: https://banes-lab.com/source/testing/test.build/core/predicates/exclusion.predicate.test.ts.txt

Listed in [test.build/core/predicates](https://banes-lab.com/api/source/testing/test.build/core/predicates.md), after [test.build/core/predicates/asset.predicate.test.ts](https://banes-lab.com/source/testing/test.build/core/predicates/asset.predicate.test.ts.md) and before [test.build/core/predicates/graph.predicate.test.ts](https://banes-lab.com/source/testing/test.build/core/predicates/graph.predicate.test.ts.md).

## Contained in

- [test.build/core/predicates](https://banes-lab.com/anatomy/testing/folder-testing-test-build-core-predicates.md)

## Source

```typescript
import { describe, expect, it } from "vitest";
import { exclusionOf, isPublished } from "@banes-lab/build-scripts/core/predicates/exclusion.predicate.ts";
import { absolutePath } from "@ssot/paths";
import { join } from "node:path";

describe("exclusionOf", () => {
    it("names the reason a file stays out of a published tree", () => {
        const vendorFile = join(absolutePath("govlab.quality.catalog.data"), "rules.json");
        expect(exclusionOf(vendorFile)).toBe("third-party-rule-text");
        expect(exclusionOf("/member/runtime/backups/nginx.backup.conf")).toBe("backup");
        expect(exclusionOf("/member/cards/home.PNG")).toBe("rendered-media");
        expect(exclusionOf("/member/grammars/tree-sitter.wasm")).toBe("binary");
    });

    it("publishes a file that is not excluded or inherited, and a generated one only where the tree allows it", () => {
        const facts = { generated: false, inherited: false };
        expect(isPublished(facts, false)).toBe(true);
        expect(isPublished({ ...facts, excluded: "backup" }, true)).toBe(false);
        expect(isPublished({ ...facts, inherited: true }, true)).toBe(false);
        expect(isPublished({ ...facts, generated: true }, false)).toBe(false);
        expect(isPublished({ ...facts, generated: true }, true)).toBe(true);
    });

    it("keeps a text file in the tree", () => {
        expect(exclusionOf("/member/core/a.ts")).toBeNull();
        expect(exclusionOf("/member/assets/logo.svg")).toBeNull();
    });
});
```
