snapshot of https://github.com/mountain-loop/yaak.git (main, 2026-09-23; blobs > 131072B omitted)
This commit is contained in:
31
plugins-external/faker/tests/init.test.ts
Normal file
31
plugins-external/faker/tests/init.test.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
describe("template-function-faker", () => {
|
||||
it("exports all expected template functions", async () => {
|
||||
const { plugin } = await import("../src/index");
|
||||
const names = plugin.templateFunctions?.map((fn) => fn.name).sort() ?? [];
|
||||
|
||||
// Snapshot the full list of exported function names so we catch any
|
||||
// accidental additions, removals, or renames across faker upgrades.
|
||||
expect(names).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("renders date results as unquoted ISO strings", async () => {
|
||||
const { plugin } = await import("../src/index");
|
||||
const fn = plugin.templateFunctions?.find((fn) => fn.name === "faker.date.future");
|
||||
// oxlint-disable-next-line unbound-method
|
||||
const onRender = fn?.onRender;
|
||||
|
||||
expect(onRender).toBeTypeOf("function");
|
||||
if (onRender == null) {
|
||||
throw new Error("Expected template function 'faker.date.future' to define onRender");
|
||||
}
|
||||
|
||||
const result = await onRender(
|
||||
{} as Parameters<typeof onRender>[0],
|
||||
{ values: {} } as Parameters<typeof onRender>[1],
|
||||
);
|
||||
|
||||
expect(result).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user