Skip to content

Commit cb1d530

Browse files
committed
test: add timezone boundary alignment coverage
1 parent 2e604a1 commit cb1d530

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

lib/calculate.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,30 @@ describe('calculateStreak — timezone awareness', () => {
13191319
const result = calculateStreak(tzCalendar, 'UTC', nowUTC);
13201320
expect(result.todayDate).toBe('2024-06-16');
13211321
});
1322+
1323+
it('handles timezone boundary alignment between UTC, IST and JST', () => {
1324+
const calendar = {
1325+
totalContributions: 2,
1326+
weeks: [
1327+
{
1328+
contributionDays: [
1329+
{ contributionCount: 1, date: '2024-06-14' },
1330+
{ contributionCount: 1, date: '2024-06-15' },
1331+
],
1332+
},
1333+
],
1334+
};
1335+
1336+
const now = new Date('2024-06-14T20:00:00Z');
1337+
1338+
const utcResult = calculateStreak(calendar, 'UTC', now);
1339+
const istResult = calculateStreak(calendar, 'Asia/Kolkata', now);
1340+
const jstResult = calculateStreak(calendar, 'Asia/Tokyo', now);
1341+
1342+
expect(utcResult.todayDate).toBe('2024-06-14');
1343+
expect(istResult.todayDate).toBe('2024-06-15');
1344+
expect(jstResult.todayDate).toBe('2024-06-15');
1345+
});
13221346
});
13231347

13241348
describe('isStreakAlive', () => {

0 commit comments

Comments
 (0)