# test.govlab/patterns/core/selectors/code.selector.test.ts

> 19 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-govlab-patterns-core-selectors-code-selector-test-ts
Source text: https://banes-lab.com/source/testing/test.govlab/patterns/core/selectors/code.selector.test.ts.txt

Listed in [test.govlab/patterns/core/selectors](https://banes-lab.com/api/source/testing/test.govlab/patterns/core/selectors.md), before [test.govlab/patterns/core/selectors/counter.selector.test.ts](https://banes-lab.com/source/testing/test.govlab/patterns/core/selectors/counter.selector.test.ts.md).

## Contained in

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

## Source

```typescript
import { describe, expect, it } from "vitest";
import { sortedEdges, unresolvedNames } from "@govlab/patterns/core/selectors/code.selector.ts";

describe("the code selectors", () => {
    it("sort edges deterministically and list unresolved names once, in order", () => {
        const graph = {
            edges: [
                { file: "b", from: "b", line: 1, to: "c" },
                { file: "a", from: "a", line: 1, to: "b" },
            ],
            external: [
                { caller: "x", file: "f", line: 1, name: "log" },
                { caller: "y", file: "f", line: 2, name: "fetch" },
                { caller: "z", file: "f", line: 3, name: "log" },
            ],
        };
        expect(sortedEdges(graph).map((edge) => edge.from)).toStrictEqual(["a", "b"]);
        expect(unresolvedNames(graph)).toStrictEqual(["fetch", "log"]);
    });
});
```
