Skip to content

Commit db82f65

Browse files
committed
test(calculate): verify streak formulas for different starting days of the week timeline (Variation 3) (JhaSourav07#1496)
1 parent a4dcf09 commit db82f65

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

lib/calculate.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,37 @@ describe('calculateStreak', () => {
708708
expect(result.longestStreak).toBe(15);
709709
});
710710

711+
it('verify streak formulas for different starting days of the week timeline (Variation 3)', () => {
712+
// Week 1: 0, 0, 0, 0, 1, 1, 1 (Starts on Friday, 3 days)
713+
// Week 2: 1, 1, 1, 1, 1, 1, 1 (7 days)
714+
// Week 3: 1, 1, 1, 1, 1 // Ends on Friday (5 days)
715+
// Total continuous streak = 15 days, ending on the last day.
716+
const calendar = buildCalendar([
717+
0,
718+
0,
719+
0,
720+
0,
721+
1,
722+
1,
723+
1, // Week 1 (Starts Fri)
724+
1,
725+
1,
726+
1,
727+
1,
728+
1,
729+
1,
730+
1, // Week 2
731+
1,
732+
1,
733+
1,
734+
1,
735+
1, // Week 3 (Ends Fri)
736+
]);
737+
const result = calculateStreak(calendar);
738+
expect(result.currentStreak).toBe(15);
739+
expect(result.longestStreak).toBe(15);
740+
});
741+
711742
it('verify streak formulas for multiple weeks gaps timeline (Variation 3)', () => {
712743
// Streak 1: 5 days
713744
// Gap 1: 14 days (2 weeks of zeros)

0 commit comments

Comments
 (0)