# test.govlab/docs/core/analyzers/markdown.analyzer.test.ts

> 31 lines of code and 0 definitions.

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

Listed in [test.govlab/docs/core/analyzers](https://banes-lab.com/api/source/testing/test.govlab/docs/core/analyzers.md), after [test.govlab/docs/core/analyzers/machine.analyzer.test.ts](https://banes-lab.com/source/testing/test.govlab/docs/core/analyzers/machine.analyzer.test.ts.md) and before [test.govlab/docs/core/analyzers/orchestration.analyzer.test.ts](https://banes-lab.com/source/testing/test.govlab/docs/core/analyzers/orchestration.analyzer.test.ts.md).

## Contained in

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

## Source

`````typescript
import { describe, expect, it } from "vitest";
import { conventionHits } from "@govlab/docs/core/analyzers/markdown.analyzer.ts";

const UNLABELED = "unlabeled-code-fence";

const codesOf = function codesOf(source: string, code: string): string[] {
    return conventionHits(source)
        .filter((hit) => hit.code === code)
        .map((hit) => hit.token);
};

describe("conventionHits", () => {
    it("flags a bare path in prose, not a backticked or linked one", () => {
        const bare = codesOf("See src/index.ts here. But `src/ok.ts` and [x](./y.md) are fine.", "bare-path");
        expect(bare).toContain("src/index.ts");
        expect(bare).not.toContain("src/ok.ts");
        expect(bare.some((token) => token.includes("y.md"))).toBe(false);
    });

    it("ignores slashes that are not paths, and still sees a path before a CRLF", () => {
        expect(codesOf("either and/or, TCP/IP, or 12/25 dates", "bare-path")).toStrictEqual([]);
        expect(codesOf("see config/foo.js\r\nmore", "bare-path")).toHaveLength(1);
    });

    it("flags a fence with no language, not a tagged one", () => {
        expect(codesOf("```\ncode\n```\n\ntext\n\n```ts EXAMPLE: ok\nok\n```", "untagged-code-fence")).toHaveLength(1);
    });

    it("requires an intent label from the vocabulary on a code fence", () => {
        expect(codesOf("```ts\nconst x = 1;\n```", UNLABELED)).toHaveLength(1);
        expect(codesOf("```ts EXAMPLE: usage\nconst x = 1;\n```", UNLABELED)).toHaveLength(0);
        expect(codesOf("```ts API: createFoo(o)\nx\n```", UNLABELED)).toHaveLength(0);
        expect(codesOf("```ts NOTE: whatever\nx\n```", UNLABELED)).toHaveLength(1);
        expect(codesOf("```text\ntree\n```", UNLABELED)).toHaveLength(0);
        expect(codesOf("````ts\ncode\n````", UNLABELED)).toHaveLength(1);
    });
});
`````
