# test.govlab/quality/core/selectors/syntax.selector.test.ts

> 17 lines of code and 0 definitions.

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

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

## Contained in

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

## Source

```typescript
import { asNode, identName, propKeyName } from "@govlab/quality/core/selectors/syntax.selector.ts";
import { expect, test } from "vitest";

test("asNode narrows a typed record and refuses anything else", () => {
    expect(asNode({ type: "Identifier" })).toStrictEqual({ type: "Identifier" });
    expect(asNode(null)).toBeNull();
    expect(asNode("x")).toBeNull();
});

test("identName reads an Identifier's name only", () => {
    expect(identName({ name: "a", type: "Identifier" })).toBe("a");
    expect(identName({ type: "Literal", value: "a" })).toBeNull();
    expect(identName()).toBeNull();
});

test("propKeyName reads an identifier or string key and refuses a computed one", () => {
    expect(propKeyName({ key: { name: "a", type: "Identifier" }, type: "Property" })).toBe("a");
    expect(propKeyName({ key: { type: "Literal", value: "b" }, type: "Property" })).toBe("b");
    expect(propKeyName({ computed: true, key: { name: "c", type: "Identifier" }, type: "Property" })).toBeNull();
});
```
