Skip to content

Commit fc29d24

Browse files
committed
test(api validation): check query validation boundaries for ?user= parameter (Variation 3)
1 parent a4dcf09 commit fc29d24

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

lib/validations.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,3 +1013,33 @@ describe('streakParamsSchema — layout query validation boundaries (Variation 2
10131013
}
10141014
});
10151015
});
1016+
1017+
/* ==========================================================================
1018+
* USER PARAMETER — QUERY VALIDATION BOUNDARIES (VARIATION 3)
1019+
* ========================================================================== */
1020+
1021+
describe('streakParamsSchema user maxLength validation boundaries (Variation 3)', () => {
1022+
it('rejects a GitHub username that exceeds the 39 character length threshold', () => {
1023+
const invalidPayload = {
1024+
user: 'a'.repeat(40),
1025+
};
1026+
1027+
const parseResult = streakParamsSchema.safeParse(invalidPayload);
1028+
1029+
expect(parseResult.success).toBe(false);
1030+
if (!parseResult.success) {
1031+
const fieldErrors = parseResult.error.flatten().fieldErrors;
1032+
expect(fieldErrors.user).toBeDefined();
1033+
expect(fieldErrors.user?.[0]).toContain('cannot exceed 39 characters');
1034+
}
1035+
});
1036+
1037+
it('accepts a username exactly at the upper limit of 39 characters', () => {
1038+
const validPayload = {
1039+
user: 'a'.repeat(39),
1040+
};
1041+
1042+
const parseResult = streakParamsSchema.safeParse(validPayload);
1043+
expect(parseResult.success).toBe(true);
1044+
});
1045+
});

0 commit comments

Comments
 (0)