Skip to content

Commit 5163f7f

Browse files
test(utils): check boundary robustness of date range formatter
1 parent 17e3f28 commit 5163f7f

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

lib/validations.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,3 +647,45 @@ describe('streakParamsSchema — view fallback behavior', () => {
647647
expect(parse({}).view).toBe('default');
648648
});
649649
});
650+
651+
/* ==========================================================================
652+
* DATE RANGE BOUNDARY ROBUSTNESS (VARIATION 1)
653+
* ========================================================================== */
654+
655+
describe('streakParamsSchema — Date Range Boundary Robustness (Variation 1)', () => {
656+
it('should process validation safely and fallback when partial or missing year parameters are passed', () => {
657+
// Arrange: Provide a mock payload missing a full YYYY format sequence
658+
const partialYearPayload = {
659+
user: 'octocat',
660+
from: '05-12',
661+
to: '05-30',
662+
};
663+
664+
// Act: Pass the object through the validator schema matrix
665+
const result = streakParamsSchema.safeParse(partialYearPayload);
666+
667+
// Assert: The validator handles it safely using implicit date engine fallbacks
668+
expect(result.success).toBe(true);
669+
if (result.success) {
670+
expect(result.data.from).toBeDefined();
671+
expect(result.data.to).toBeDefined();
672+
}
673+
});
674+
675+
it('should pass cleanly and fallback to default ranges when date bounds are completely omitted', () => {
676+
// Arrange: Pass only the bare minimum required parameters
677+
const minimalPayload = {
678+
user: 'octocat'
679+
};
680+
681+
// Act
682+
const result = streakParamsSchema.safeParse(minimalPayload);
683+
684+
// Assert: Verify that omitted range options return undefined to use downstream defaults smoothly
685+
expect(result.success).toBe(true);
686+
if (result.success) {
687+
expect(result.data.from).toBeUndefined();
688+
expect(result.data.to).toBeUndefined();
689+
}
690+
});
691+
});

0 commit comments

Comments
 (0)