fix(tests): address Task 4 code review feedback
- Deprecate mockPayloadModule with throw guard (hoisting incompatible) - Replace `as never` with stubPayloadConfig in payload-articles test (consistency) - Tighten pages contract to use toHaveLength (exact assertions) - Header contract: define CONTRACT_HEADER_SEED, assert item count + order Reviewer: superpowers:code-reviewer (Task 4 of Plan 7). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -109,8 +109,6 @@ describe("PayloadArticlesRepository", () => {
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
describe("Payload doc → domain mapping", () => {
|
||||
const mockConfig = {} as never;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
@@ -135,7 +133,7 @@ describe("PayloadArticlesRepository", () => {
|
||||
find: findMock,
|
||||
});
|
||||
|
||||
const repo = new PayloadArticlesRepository(mockConfig);
|
||||
const repo = new PayloadArticlesRepository(stubPayloadConfig);
|
||||
const result = await repo.getArticleBySlug("hello");
|
||||
|
||||
expect(findMock).toHaveBeenCalledWith({
|
||||
@@ -157,7 +155,7 @@ describe("PayloadArticlesRepository", () => {
|
||||
find: vi.fn().mockResolvedValue({ docs: [] }),
|
||||
});
|
||||
|
||||
const repo = new PayloadArticlesRepository(mockConfig);
|
||||
const repo = new PayloadArticlesRepository(stubPayloadConfig);
|
||||
const result = await repo.getArticleBySlug("missing");
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user