# test.build/core/formatters/section.formatter.test.ts

> 42 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-build-core-formatters-section-formatter-test-ts
Source text: https://banes-lab.com/source/testing/test.build/core/formatters/section.formatter.test.ts.txt

Listed in [test.build/core/formatters](https://banes-lab.com/api/source/testing/test.build/core/formatters.md), after [test.build/core/formatters/search.formatter.test.ts](https://banes-lab.com/source/testing/test.build/core/formatters/search.formatter.test.ts.md) and before [test.build/core/formatters/server.formatter.test.ts](https://banes-lab.com/source/testing/test.build/core/formatters/server.formatter.test.ts.md).

## Contained in

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

## Source

```typescript
import { describe, expect, it } from "vitest";
import { renderSectionLeaf, renderSectionPart } from "@banes-lab/build-scripts/core/formatters/section.formatter.ts";
import { LINK } from "./link.fixture.ts";

describe("renderSectionPart", () => {
    it("names the part, links its whole section and its own JSON, and lists the subsections it holds", () => {
        const part = renderSectionPart(
            "Big, part 1 of 2",
            "https://x.test/json/m/s/big/_1",
            "https://x.test/m/s/big.md",
            ["First", "Second"],
        );
        expect(part).toContain("# Big, part 1 of 2");
        expect(part).toContain("https://x.test/m/s/big.md");
        expect(part).toContain("https://x.test/json/m/s/big/_1");
        expect(part).toContain("First");
        expect(part).toContain("Second");
    });
});

describe("renderSectionLeaf", () => {
    it("renders a section with its page, its place in the route and its place in its index", () => {
        const section = renderSectionLeaf(
            {
                href: "https://x.test/p#s",
                relations: [{ links: [LINK], relation: "links-to" }],
                route: { next: LINK, position: 2, previous: null, requires: [LINK], total: 9 },
                siblings: { next: null, previous: LINK },
                summary: "S.",
                title: "S",
                up: { ...LINK, label: "Tab", markdown: "https://x.test/api/pages/p/t.md" },
            },
            "Page",
            "Tab",
            "Body.",
        );
        expect(section).toContain("Page: Page · Tab");
        expect(section).toContain(
            "This section is stop 2 of 9 in the learning route, before [A](https://x.test/a.md). It builds on [A](https://x.test/a.md).",
        );
        expect(section).toContain("Listed in [Tab](https://x.test/api/pages/p/t.md), after [A](https://x.test/a.md).");
        expect(section).toContain("## Links to");
    });
});
```
