# test.rules/shared/analyzers/check.analyzer.test.ts

> 24 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-rules-shared-analyzers-check-analyzer-test-ts
Source text: https://banes-lab.com/source/testing/test.rules/shared/analyzers/check.analyzer.test.ts.txt

Listed in [test.rules/shared/analyzers](https://banes-lab.com/api/source/testing/test.rules/shared/analyzers.md), before [test.rules/shared/analyzers/composition.analyzer.test.ts](https://banes-lab.com/source/testing/test.rules/shared/analyzers/composition.analyzer.test.ts.md).

## Contained in

- [test.rules/shared/analyzers](https://banes-lab.com/anatomy/testing/folder-testing-test-rules-shared-analyzers.md)

## Source

```typescript
import { DECLARING_CALLEE, declarationsIn } from "@ssot/govlab/shared/analyzers/check.analyzer.ts";
import { checksLine, unreadableDeclaration } from "@ssot/govlab/shared/strings/rule.strings.ts";
import { describe, expect, it } from "vitest";
import type { ReadDeclaration } from "@ssot/govlab/types/check.types.ts";

describe("declarationsIn", () => {
    it("reads each declaration's string-literal refs, wherever the call sits", () => {
        const text = [
            `${DECLARING_CALLEE}({ detects: ["a:b"], enforces: [] });`,
            `export default { meta: { docs: { checks: ${DECLARING_CALLEE}({ detects: [], enforces: ["c:d"] }) } } };`,
        ].join("\n");
        const expected: readonly ReadDeclaration[] = [
            { detects: ["a:b"], enforces: [] },
            { detects: [], enforces: ["c:d"] },
        ];
        expect(declarationsIn("probe.ts", text)).toStrictEqual(expected);
    });

    it("reads a declaration it cannot resolve statically as unreadable", () => {
        expect(declarationsIn("probe.ts", `${DECLARING_CALLEE}({ detects: REFS, enforces: [] });`)).toStrictEqual([
            null,
        ]);
        expect(unreadableDeclaration("probe.ts", DECLARING_CALLEE)).toContain("the index cannot read");
        expect(checksLine(2, "index.json")).toContain("indexed 2 check declaration(s)");
    });
});
```
