# test.build/core/converters/tab.converter.test.ts

> 24 lines of code and 0 definitions.

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

Listed in [test.build/core/converters](https://banes-lab.com/api/source/testing/test.build/core/converters.md), after [test.build/core/converters/surface.converter.test.ts](https://banes-lab.com/source/testing/test.build/core/converters/surface.converter.test.ts.md) and before [test.build/core/converters/view.converter.test.ts](https://banes-lab.com/source/testing/test.build/core/converters/view.converter.test.ts.md).

## Contained in

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

## Source

```typescript
import { describe, expect, it } from "vitest";
import { pageTabsOf } from "@banes-lab/build-scripts/core/converters/tab.converter.ts";

const tabsFor = function tabsFor(): readonly { readonly id: unknown; readonly label: unknown }[] {
    return [
        { id: "intro", label: "Intro" },
        { id: "guide", label: "Guide" },
        { id: 3, label: "Broken" },
    ];
};

describe("pageTabsOf", () => {
    it("serves the first tab at the page path and each other tab at its own link, dropping a tab with no id", () => {
        const router = {
            pagePath: (page: string) => `/${page}`,
            tabLink: (page: string, tab: string) => `/${page}/${tab}`,
        };
        expect(pageTabsOf(router, "terms", tabsFor)).toStrictEqual({
            page: "terms",
            tabs: [
                { id: "intro", label: "Intro", path: "/terms" },
                { id: "guide", label: "Guide", path: "/terms/guide" },
            ],
        });
    });
});
```
