feat(core-dsr): Payload impls, recording doubles, DI binders, contract tests
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { RecordingDataRectify } from "./recording-data-rectify";
|
||||
|
||||
describe("RecordingDataRectify", () => {
|
||||
it("records updateSubjectField calls", async () => {
|
||||
const rectifier = new RecordingDataRectify();
|
||||
await rectifier.updateSubjectField("alice", "users", "name", "Alice New");
|
||||
|
||||
expect(rectifier.calls).toHaveLength(1);
|
||||
expect(rectifier.calls[0]).toEqual({
|
||||
subjectId: "alice",
|
||||
collection: "users",
|
||||
field: "name",
|
||||
value: "Alice New",
|
||||
});
|
||||
});
|
||||
|
||||
it("returns void (undefined)", async () => {
|
||||
const rectifier = new RecordingDataRectify();
|
||||
const result = await rectifier.updateSubjectField(
|
||||
"alice",
|
||||
"users",
|
||||
"name",
|
||||
"x",
|
||||
);
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
it("records multiple calls in order", async () => {
|
||||
const rectifier = new RecordingDataRectify();
|
||||
await rectifier.updateSubjectField("alice", "users", "name", "A");
|
||||
await rectifier.updateSubjectField("alice", "users", "email", "a@ex.com");
|
||||
|
||||
expect(rectifier.calls).toHaveLength(2);
|
||||
expect(rectifier.calls[0]?.field).toBe("name");
|
||||
expect(rectifier.calls[1]?.field).toBe("email");
|
||||
});
|
||||
|
||||
it("reset() clears recorded calls", async () => {
|
||||
const rectifier = new RecordingDataRectify();
|
||||
await rectifier.updateSubjectField("alice", "users", "name", "A");
|
||||
rectifier.reset();
|
||||
|
||||
expect(rectifier.calls).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user