From fc1e65be00393c627b14849e1d5631b96c45c92c Mon Sep 17 00:00:00 2001 From: KrishnanshPuri Date: Sun, 31 May 2026 11:49:42 +0530 Subject: [PATCH] test(api): validate accent hex color parameter --- app/api/streak/route.test.ts | 5 +++-- lib/validations.test.ts | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/api/streak/route.test.ts b/app/api/streak/route.test.ts index bd6e1405..0030558f 100644 --- a/app/api/streak/route.test.ts +++ b/app/api/streak/route.test.ts @@ -722,9 +722,10 @@ describe('GET /api/streak', () => { expect(response.status).toBe(400); }); + it('returns 400 when an invalid hex color is passed as accent', async () => { - // #ZZZZZZZ contains non-hex characters — schema must reject it with 400 - const response = await GET(makeRequest({ user: 'octocat', accent: '#ZZZZZZZ' })); + // #ZZZZZZ contains non-hex characters — schema must reject it with 400 + const response = await GET(makeRequest({ user: 'octocat', accent: '#ZZZZZZ' })); expect(response.status).toBe(400); }); diff --git a/lib/validations.test.ts b/lib/validations.test.ts index 1aa1b4e9..10bafca5 100644 --- a/lib/validations.test.ts +++ b/lib/validations.test.ts @@ -717,11 +717,11 @@ describe('streakParamsSchema — view fallback behavior', () => { }); describe('streakParamsSchema — accent parameter HEX color validation', () => { - it('rejects an invalid hex color like "#ZZZZZZZ" for accent', () => { - // #ZZZZZZZ contains non-hex characters — must fail schema validation + it('rejects an invalid hex color like "#ZZZZZZ" for accent', () => { + // #ZZZZZZ contains non-hex characters — must fail schema validation const result = streakParamsSchema.safeParse({ user: 'octocat', - accent: '#ZZZZZZZ', + accent: '#ZZZZZZ', }); expect(result.success).toBe(false);