# test.web/core/factories/schema.factory.test.ts

> 41 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-web-core-factories-schema-factory-test-ts
Source text: https://banes-lab.com/source/testing/test.web/core/factories/schema.factory.test.ts.txt

Listed in [test.web/core/factories](https://banes-lab.com/api/source/testing/test.web/core/factories.md), after [test.web/core/factories/evidence.factory.test.ts](https://banes-lab.com/source/testing/test.web/core/factories/evidence.factory.test.ts.md).

## Contained in

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

## Source

```typescript
import { basePage, breadcrumb, datesOf, encoding } from "@banes-lab/web/core/factories/schema.factory.ts";
import { describe, expect, it } from "vitest";
import { SITE_URL } from "@banes-lab/web/core/assets/link.assets.ts";

const SUBJECT = { description: "The terms.", path: "/terms", title: "Terms — Bane's Lab" };

describe("breadcrumb", () => {
    it("numbers each crumb from one and addresses it on the site", () => {
        expect(breadcrumb([{ name: "Home", path: "/" }, { name: "Terms", path: "/terms" }])).toStrictEqual({
            "@type": "BreadcrumbList",
            itemListElement: [
                { "@type": "ListItem", item: `${SITE_URL}/`, name: "Home", position: 1 },
                { "@type": "ListItem", item: `${SITE_URL}/terms`, name: "Terms", position: 2 },
            ],
        });
    });
});

describe("encoding", () => {
    it("names the JSON and the Markdown form of a page by their media types", () => {
        expect(encoding("/json/terms", "/terms.md")).toStrictEqual([
            { "@type": "MediaObject", contentUrl: `${SITE_URL}/json/terms`, encodingFormat: "application/json" },
            { "@type": "MediaObject", contentUrl: `${SITE_URL}/terms.md`, encodingFormat: "text/markdown" },
        ]);
    });
});

describe("datesOf and basePage", () => {
    it("dates a page with the dates it was given and leaves an undated page without them", () => {
        const dates = { modified: "2026-10-07", published: "2026-09-30" };
        expect(datesOf(dates)).toStrictEqual({
            dateModified: "2026-10-07T00:00:00+00:00",
            datePublished: "2026-09-30T00:00:00+00:00",
        });
        expect(datesOf(undefined)).toStrictEqual({});
        const page = basePage({ ...SUBJECT, dates });
        expect([page["@type"], page["url"], page["name"], page["datePublished"]]).toStrictEqual([
            "WebPage",
            `${SITE_URL}/terms`,
            SUBJECT.title,
            "2026-09-30T00:00:00+00:00",
        ]);
        expect(basePage(SUBJECT)["dateModified"]).toBeUndefined();
    });
});
```
