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

> 13 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-build-core-formatters-search-formatter-test-ts
Source text: https://banes-lab.com/source/testing/test.build/core/formatters/search.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/route.formatter.test.ts](https://banes-lab.com/source/testing/test.build/core/formatters/route.formatter.test.ts.md) and before [test.build/core/formatters/section.formatter.test.ts](https://banes-lab.com/source/testing/test.build/core/formatters/section.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 { renderSearchAsset } from "@banes-lab/build-scripts/core/formatters/search.formatter.ts";

describe("renderSearchAsset", () => {
    it("writes a typed module whose one export parses back to the asset", () => {
        const asset = { definitions: [], positions: { evidence: {}, links: {}, route: { a: 1 } } };
        const source = renderSearchAsset(asset);
        expect(source.startsWith('import type { SearchAsset } from "#types/search.types";')).toBe(true);
        const start = source.indexOf("JSON.parse(") + "JSON.parse(".length;
        const literal: unknown = JSON.parse(source.slice(start, source.lastIndexOf(");")));
        const parsed: unknown = JSON.parse(String(literal));
        expect(parsed).toStrictEqual(asset);
    });
});
```
