# test.deploy/core/converters/search.converter.test.ts

> 40 lines of code and 0 definitions.

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

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

## Contained in

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

## Source

```typescript
import { changedLocations, stampsOf } from "@banes-lab/deploy/core/converters/search.converter.ts";
import { describe, expect, it } from "vitest";

const HOME = "https://x.test/";
const TERMS = "https://x.test/terms";
const ABOUT = "https://x.test/about";
const FIRST = "2026-10-01";
const LATER = "2026-10-07";

const sitemapOf = function sitemapOf(rows: readonly (readonly [string, string | null])[]): string {
    const urls = rows.map(([loc, lastmod]) =>
        lastmod === null ? `<url><loc>${loc}</loc></url>` : `<url><loc>${loc}</loc><lastmod>${lastmod}</lastmod></url>`,
    );
    return `<?xml version="1.0"?><urlset>${urls.join("")}</urlset>`;
};

describe("stampsOf", () => {
    it("reads each location with its last modification day, and none where the entry has no day", () => {
        const stamps = stampsOf(sitemapOf([[HOME, FIRST], [TERMS, null]]));
        expect([...stamps]).toStrictEqual([
            [HOME, FIRST],
            [TERMS, null],
        ]);
    });
});

describe("changedLocations", () => {
    const before = sitemapOf([
        [HOME, FIRST],
        [TERMS, FIRST],
    ]);

    it("names a location whose day moved and a location the live sitemap lacks, and none that held", () => {
        const after = sitemapOf([
            [HOME, LATER],
            [TERMS, FIRST],
            [ABOUT, LATER],
        ]);
        expect(changedLocations(before, after)).toStrictEqual([HOME, ABOUT]);
        expect(changedLocations(before, before)).toStrictEqual([]);
    });

    it("names every location when no live sitemap was read", () => {
        expect(changedLocations(null, before)).toStrictEqual([HOME, TERMS]);
    });
});
```
