Files
agentic-dev/packages/blog/src/__factories__/article.factory.test.ts
Danijel Martinek 53c2fbb9e1 feat(features): add test factories to all 5 features
Adds src/__factories__/<entity>.factory.ts to auth, blog, marketing-pages,
navigation, media. Each factory uses defineFactory from @repo/core-testing
with stable date defaults (2026-01-01) so snapshot diffs reflect SUT
behavior only. Refactors mechanical inline-fixture tests to use factories.

Also adds vitest.config.ts and tsconfig path alias to @repo/media (lacked
both), and adds @repo/core-testing devDependency to @repo/media.

Spec: §5.1, §6.3
2026-05-05 14:56:50 +02:00

28 lines
876 B
TypeScript

import { describe, it, expect, beforeEach } from "vitest";
import { articleFactory } from "@/__factories__/article.factory";
describe("articleFactory", () => {
beforeEach(() => articleFactory.reset());
it("returns an Article with stable defaults", () => {
const a = articleFactory.build();
expect(a.title).toBe("Article 1");
expect(a.slug).toBe("article-1");
expect(a.status).toBe("draft");
expect(a.createdAt).toEqual(new Date("2026-01-01T00:00:00Z"));
});
it("applies overrides", () => {
const a = articleFactory.build({ status: "published", title: "X" });
expect(a.status).toBe("published");
expect(a.title).toBe("X");
});
it("increments sequence per build", () => {
const a = articleFactory.build();
const b = articleFactory.build();
expect(a.id).toBe("article-1");
expect(b.id).toBe("article-2");
});
});