# test.govlab/stats/core/classifiers/source.classifier.test.ts

> 23 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-govlab-stats-core-classifiers-source-classifier-test-ts
Source text: https://banes-lab.com/source/testing/test.govlab/stats/core/classifiers/source.classifier.test.ts.txt

Listed in [test.govlab/stats/core/classifiers](https://banes-lab.com/api/source/testing/test.govlab/stats/core/classifiers.md).

## Contained in

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

## Source

```typescript
import { AUTHORED_ROLES, ROLE_BY_EXT } from "@govlab/stats/configuration/constants/source.constants.ts";
import { describe, expect, it } from "vitest";
import { isAuthoredRole, roleOf } from "@govlab/stats/core/classifiers/source.classifier.ts";

describe("roleOf", () => {
    it("maps every declared extension to its declared role", () => {
        for (const [ext, role] of ROLE_BY_EXT) {
            expect(roleOf(ext)).toBe(role);
        }
    });

    it("falls to other for an unmapped extension rather than guessing", () => {
        expect(roleOf(".glsl")).toBe("other");
        expect(roleOf("")).toBe("other");
    });
});

describe("isAuthoredRole", () => {
    it("counts the authored roles as the codebase and nothing else", () => {
        for (const role of AUTHORED_ROLES) {
            expect(isAuthoredRole(role)).toBe(true);
        }
        expect(isAuthoredRole("data")).toBe(false);
        expect(isAuthoredRole("other")).toBe(false);
    });
});
```
