feat(profile): add the manual candidate profile contract and storage

This commit is contained in:
shira committed 2026-10-06 21:10:04 +03:00
1 parent d21fd49a42
commit e52ffe7bcb
97 files changed
+20442 -63

No files matched your search

+21 -4
View File
@@ -138,17 +138,34 @@ describe("rewriteMockSource", () => {
);
});
it("fails when the schemas disagree on the bounds", () => {
const ambiguous = buildPatternBoundsIndex({
it("uses the common bounds when schemas share a property name and a pattern", () => {
const shared = buildPatternBoundsIndex({
components: {
schemas: {
A: { properties: { id: { type: "string", maxLength: 8, pattern: "^a+$" } } },
A: {
properties: { id: { type: "string", minLength: 1, maxLength: 8, pattern: "^a+$" } },
},
B: { properties: { id: { type: "string", maxLength: 9, pattern: "^a+$" } } },
},
},
});
const source = `${header}\nexport const m = () => ({id: faker.helpers.fromRegExp("^a+$")})\n`;
expect(() => rewrite(source, ambiguous)).toThrow("so the mock bounds are ambiguous");
expect(rewrite(source, shared).text).toContain(
'fakeFromPattern("^a+$", {minLength: 1, maxLength: 8})',
);
});
it("fails when the bounds of schemas have no common value", () => {
const disjoint = buildPatternBoundsIndex({
components: {
schemas: {
A: { properties: { id: { type: "string", maxLength: 3, pattern: "^a+$" } } },
B: { properties: { id: { type: "string", minLength: 5, pattern: "^a+$" } } },
},
},
});
const source = `${header}\nexport const m = () => ({id: faker.helpers.fromRegExp("^a+$")})\n`;
expect(() => rewrite(source, disjoint)).toThrow("so the mock bounds are ambiguous");
});
it("fails on a call that it cannot attribute to a property", () => {