# test.govlab/docs/core/validators/readme.validator.test.ts

> 39 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-govlab-docs-core-validators-readme-validator-test-ts
Source text: https://banes-lab.com/source/testing/test.govlab/docs/core/validators/readme.validator.test.ts.txt

Listed in [test.govlab/docs/core/validators](https://banes-lab.com/api/source/testing/test.govlab/docs/core/validators.md), after [test.govlab/docs/core/validators/package.validator.test.ts](https://banes-lab.com/source/testing/test.govlab/docs/core/validators/package.validator.test.ts.md) and before [test.govlab/docs/core/validators/reference.validator.test.ts](https://banes-lab.com/source/testing/test.govlab/docs/core/validators/reference.validator.test.ts.md).

## Contained in

- [test.govlab/docs/core/validators](https://banes-lab.com/anatomy/testing/folder-testing-test-govlab-docs-core-validators.md)

## Source

```typescript
import { describe, expect, it } from "vitest";
import type { ManifestModule } from "@govlab/docs/types/manifest.types.ts";
import { governanceMessages } from "@govlab/docs/core/validators/readme.validator.ts";

const CLEAN = {
    governConcepts: (): never[] => [],
    governDeclaredDocs: (): never[] => [],
    governManifest: (): never[] => [],
    governPrinciples: (): never[] => [],
};

const moduleWith = function moduleWith(manifest: Record<string, unknown>): ManifestModule {
    return {
        dir: "module-under-test",
        group: "test",
        label: "mod",
        manifest,
        pkg: {},
        relPath: "test/mod",
        slug: "mod",
    };
};

describe("governanceMessages", () => {
    it("emits nothing when the engine reports clean", () => {
        expect(
            governanceMessages(CLEAN, moduleWith({ docs: {} }), { generatedPrefix: "<!-- gen", onDiskReadme: "" }),
        ).toStrictEqual([]);
    });

    it("reports a generated README whose manifest lost its docs block", () => {
        const context = { generatedPrefix: "<!-- gen", onDiskReadme: "<!-- gen -->\n# Title" };
        expect(governanceMessages(CLEAN, moduleWith({}), context)).toStrictEqual([
            expect.stringContaining("docs-incomplete"),
        ]);
    });

    it("formats each engine finding with its manifest field", () => {
        const engine = { ...CLEAN, governManifest: () => [{ axis: "history-smell", detail: "d", field: "overview" }] };
        expect(
            governanceMessages(engine, moduleWith({ docs: {} }), { generatedPrefix: "<!-- gen", onDiskReadme: "" }),
        ).toStrictEqual([expect.stringContaining("[docs.overview]")]);
    });
});
```
