Initial Commit

This commit is contained in:
2026-05-27 23:29:53 +01:00
commit fbc70f96e6
10000 changed files with 1102152 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
import { describe, expect, it } from "@suaveplan/testing/runner";
import fc from "fast-check";
import { UpdateUserProfileBodySchema } from "../src/schemas/user-profile.js";
const KNOWN_FIELDS = ["displayName", "avatarUrl", "locale", "timezone"];
const valueArb = fc.oneof(
fc.string({ minLength: 1, maxLength: 16 }),
fc.integer(),
fc.boolean()
);
const keyArb = fc.string({ minLength: 1, maxLength: 16 });
describe("UpdateUserProfileBodySchema strict-mode fast-check", () => {
it("rejects every payload that contains an unknown key", {
timeout: 30_000,
}, () => {
fc.assert(
fc.property(
fc.dictionary(keyArb, valueArb, {
minKeys: 1,
maxKeys: 6,
}),
(input) => {
const keys = Object.keys(input);
const hasUnknown = keys.some(
(k) => !KNOWN_FIELDS.includes(k)
);
const result = UpdateUserProfileBodySchema.safeParse(input);
if (hasUnknown) {
return result.success === false;
}
// No unknown keys — accept depends on per-field value
// validation; this branch verifies that strict-mode
// alone does not reject a known-key payload.
return true;
}
),
{ numRuns: 200 }
);
});
it("accepts the canonical empty patch", { timeout: 5000 }, () => {
const r = UpdateUserProfileBodySchema.safeParse({});
expect(r.success).toBe(true);
});
});