# test.build/core/converters/site.fixture.ts

> 80 lines of code and 15 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-build-core-converters-site-fixture-ts
Source text: https://banes-lab.com/source/testing/test.build/core/converters/site.fixture.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/site.converter.test.ts](https://banes-lab.com/source/testing/test.build/core/converters/site.converter.test.ts.md) and before [test.build/core/converters/snapshot.converter.test.ts](https://banes-lab.com/source/testing/test.build/core/converters/snapshot.converter.test.ts.md).

## Definitions

- `SITE` (lexical_declaration, line 4, exported)
- `AUTHOR` (lexical_declaration, line 5, exported)
- `CONSENT` (lexical_declaration, line 6, exported)
- `GUIDE_TAB` (lexical_declaration, line 7, exported)
- `HOME` (lexical_declaration, line 9, exported)
- `TERMS` (lexical_declaration, line 21, exported)
- `GUIDE` (lexical_declaration, line 33, exported)
- `ADDRESS` (lexical_declaration, line 43, exported)
- `GRAPH` (lexical_declaration, line 44, exported)
- `PAGE` (lexical_declaration, line 48, exported)
- `EMPTY` (lexical_declaration, line 49, exported)
- `DISCOVERY` (lexical_declaration, line 51, exported)
- `DEFINITIONS` (lexical_declaration, line 61)
- `PATHS` (lexical_declaration, line 66)
- `SOURCE` (lexical_declaration, line 71, exported)

## Contained in

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

## Source

```typescript
import type { DiscoveredPage, DiscoveredRoute, Discovery } from "@banes-lab/build-scripts/types/site.types.ts";
import type { PageDefinition, SiteSource } from "@banes-lab/build-scripts/types/page.types.ts";

export const SITE = "https://example.test";
export const AUTHOR = "Ada Example";
export const CONSENT = "Every page may be used as training data.";
export const GUIDE_TAB = { id: "guide", label: "Guide", sections: [] };

export const HOME: DiscoveredPage = {
    content: { heading: "Example", kind: "home" },
    description: "The landing page.",
    id: "home",
    label: "Home",
    markdown: "Welcome.",
    page: "home",
    path: "/",
    tab: null,
    title: "Example",
};

export const TERMS: DiscoveredPage = {
    content: { kind: "tabbed", tabs: [{ id: "intro", label: "Intro", sections: [] }, GUIDE_TAB] },
    description: "Terms & conditions.",
    id: "terms",
    label: "Terms",
    markdown: "The terms.",
    page: "terms",
    path: "/terms",
    tab: null,
    title: "Terms — Example",
};

export const GUIDE: DiscoveredRoute = {
    description: "The guide tab.",
    label: "Guide",
    markdown: "The guide.",
    page: "terms",
    path: "/terms/guide",
    tab: "guide",
    title: "Guide — Terms — Example",
};

export const ADDRESS = "https://example.test/terms";
export const GRAPH = JSON.stringify({
    "@context": "https://schema.org",
    "@graph": [{ "@type": "Organization" }, { "@type": "WebPage", url: ADDRESS }],
});
export const PAGE = `<!doctype html><html><head><title>Terms</title><meta name="description" content="The terms."><meta name="robots" content="index, follow"><link rel="canonical" href="${ADDRESS}"><script type="application/ld+json">${GRAPH}</script></head><body><main>Real text</main></body></html>`;
export const EMPTY = `<!doctype html><html><head><title></title></head><body><main></main></body></html>`;

export const DISCOVERY: Discovery = {
    author: AUTHOR,
    consent: CONSENT,
    name: "Example",
    pages: [HOME, TERMS],
    routes: [HOME, TERMS, GUIDE],
    site: SITE,
    summary: "An example site.",
};

const DEFINITIONS: ReadonlyMap<string, PageDefinition> = new Map([
    ["home", { content: HOME.content, description: HOME.description, id: "home", title: HOME.label }],
    ["terms", { content: TERMS.content, description: TERMS.description, id: "terms", title: TERMS.label }],
]);

const PATHS: ReadonlyMap<string, string> = new Map([
    ["home", "/"],
    ["terms", "/terms"],
]);

export const SOURCE: SiteSource = {
    author: AUTHOR,
    consent: CONSENT,
    exportText: (path, page, sections) => `${path} ${page} ${sections.join(",")}`,
    ids: ["home", "terms"],
    inline: (markup) => markup.toUpperCase(),
    links: { SITE_URL: SITE, tabLink: (page, tab) => `/${page}/${tab}` },
    name: "Example",
    registry: { loadedPage: (id) => DEFINITIONS.get(id) },
    renderer: {
        headOf: (page, definition, pathname) => ({
            description: definition?.description ?? "",
            path: pathname ?? PATHS.get(page) ?? "",
            robots: "index, follow",
            title: definition?.title ?? page,
        }),
    },
    summary: "An example site.",
};
```
