From cdf8d4e3e90752105dd9fc185af667b77f76cf88 Mon Sep 17 00:00:00 2001 From: Ashish Raj Date: Sun, 31 May 2026 10:28:13 +0530 Subject: [PATCH] test(validation): check query validation boundaries for grace param --- lib/validations.test.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/validations.test.ts b/lib/validations.test.ts index 1aa1b4e9..d7540fd5 100644 --- a/lib/validations.test.ts +++ b/lib/validations.test.ts @@ -18,6 +18,18 @@ describe('streakParamsSchema — grace fallback behavior', () => { expect(parse({ grace: '-1' }).grace).toBe(0); }); + it('falls back or clamps a negative non-integer grace input safely', () => { + const result = streakParamsSchema.safeParse({ + user: 'octocat', + grace: '-1.5', + }); + + expect(result.success).toBe(true); + if (result.success) { + expect(result.data.grace).toBe(0); + } + }); + it('falls back to 1 for non-numeric grace value', () => { expect(parse({ grace: 'abc' }).grace).toBe(1); });