# test.content/core/selectors/payload.selector.test.ts

> 18 lines of code and 0 definitions.

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

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

## Contained in

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

## Source

```typescript
import { contentOf, isRecord, listAt, tabsIn, textAt } from "@banes-lab/content/core/selectors/payload.selector.ts";
import { describe, expect, it } from "vitest";

describe("tabsIn", () => {
    it("reads the tabs of a page's content and nothing from a value without tabs", () => {
        expect(tabsIn({ tabs: [{ id: "start" }, "noise"] })).toStrictEqual([{ id: "start" }]);
        expect(tabsIn(null)).toStrictEqual([]);
    });
});

describe("contentOf, listAt, textAt and isRecord", () => {
    it("reads a payload's content, a list of records and a string field, and nothing of another type", () => {
        expect(contentOf({ content: { id: "a" } })).toStrictEqual({ id: "a" });
        expect(contentOf({ content: "text" })).toBeNull();
        expect(listAt({ items: [{ id: "a" }, 3] }, "items")).toStrictEqual([{ id: "a" }]);
        expect(textAt({ count: 1, id: "a" }, "id")).toBe("a");
        expect(textAt({ count: 1, id: "a" }, "count")).toBeNull();
        expect(isRecord(null)).toBe(false);
    });
});
```
