# test.govlab/context/core/matchers/filename.matcher.test.ts

> 25 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-govlab-context-core-matchers-filename-matcher-test-ts
Source text: https://banes-lab.com/source/testing/test.govlab/context/core/matchers/filename.matcher.test.ts.txt

Listed in [test.govlab/context/core/matchers](https://banes-lab.com/api/source/testing/test.govlab/context/core/matchers.md), after [test.govlab/context/core/matchers/architecture.matcher.test.ts](https://banes-lab.com/source/testing/test.govlab/context/core/matchers/architecture.matcher.test.ts.md) and before [test.govlab/context/core/matchers/lexicon.matcher.test.ts](https://banes-lab.com/source/testing/test.govlab/context/core/matchers/lexicon.matcher.test.ts.md).

## Contained in

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

## Source

```typescript
import assert from "node:assert/strict";
import { placedFileOf } from "@govlab/context/core/matchers/filename.matcher.ts";
import { test } from "vitest";

test("a placed file is one folder, a slash and a subject, an optional variant, a tag and an extension", () => {
    assert.deepEqual(placedFileOf("stores/cart.store.ts"), {
        extension: "ts",
        folder: "stores",
        subject: "cart",
        tag: "store",
        variant: null,
    });
    assert.equal(placedFileOf("stores/cart.lru.store.ts")?.variant, "lru");
});

test("a path that is not one folder over a subject, a tag and an extension is no placed file", () => {
    for (const path of [
        "cart.store.ts",
        "app/stores/cart.store.ts",
        "stores/cart.ts",
        "stores/store.store.ts",
        "stores/Cart.store.ts",
        "stores/-cart.store.ts",
    ]) {
        assert.equal(placedFileOf(path), null, path);
    }
});
```
