fix(tests): use UTC methods for timezone-independent schedule assertions (#3052)

This commit is contained in:
Waleed
2026-01-28 13:50:22 -08:00
committed by GitHub
parent 78410eef84
commit c00f05c346
2 changed files with 9 additions and 9 deletions

View File

@@ -344,7 +344,7 @@ describe('Schedule PUT API (Reactivate)', () => {
expect(nextRunAt).toBeGreaterThan(beforeCall)
expect(nextRunAt).toBeLessThanOrEqual(afterCall + 5 * 60 * 1000 + 1000)
// Should align with 5-minute intervals (minute divisible by 5)
expect(new Date(nextRunAt).getMinutes() % 5).toBe(0)
expect(new Date(nextRunAt).getUTCMinutes() % 5).toBe(0)
})
it('calculates nextRunAt from daily cron expression', async () => {
@@ -572,7 +572,7 @@ describe('Schedule PUT API (Reactivate)', () => {
expect(nextRunAt.getTime()).toBeGreaterThan(beforeCall)
expect(nextRunAt.getTime()).toBeLessThanOrEqual(beforeCall + 10 * 60 * 1000 + 1000)
// Should align with 10-minute intervals
expect(nextRunAt.getMinutes() % 10).toBe(0)
expect(nextRunAt.getUTCMinutes() % 10).toBe(0)
})
it('handles hourly schedules with timezone correctly', async () => {
@@ -598,8 +598,8 @@ describe('Schedule PUT API (Reactivate)', () => {
// Should be a future date at minute 15
expect(nextRunAt.getTime()).toBeGreaterThan(beforeCall)
expect(nextRunAt.getMinutes()).toBe(15)
expect(nextRunAt.getSeconds()).toBe(0)
expect(nextRunAt.getUTCMinutes()).toBe(15)
expect(nextRunAt.getUTCSeconds()).toBe(0)
})
it('handles custom cron expressions with complex patterns and timezone', async () => {

View File

@@ -266,9 +266,9 @@ describe('Schedule Utilities', () => {
const nextRun = calculateNextRunTime('minutes', scheduleValues)
// Should return the future start date with time
expect(nextRun.getFullYear()).toBe(2025)
expect(nextRun.getMonth()).toBe(3) // April
expect(nextRun.getDate()).toBe(15)
expect(nextRun.getUTCFullYear()).toBe(2025)
expect(nextRun.getUTCMonth()).toBe(3) // April
expect(nextRun.getUTCDate()).toBe(15)
})
it.concurrent('should calculate next run for hourly schedule using Croner', () => {
@@ -292,7 +292,7 @@ describe('Schedule Utilities', () => {
expect(nextRun instanceof Date).toBe(true)
expect(nextRun > new Date()).toBe(true)
// Croner calculates based on cron "30 * * * *"
expect(nextRun.getMinutes()).toBe(30)
expect(nextRun.getUTCMinutes()).toBe(30)
})
it.concurrent('should calculate next run for daily schedule using Croner with timezone', () => {
@@ -439,7 +439,7 @@ describe('Schedule Utilities', () => {
// Should not use the past date but calculate normally
expect(nextRun > new Date()).toBe(true)
expect(nextRun.getMinutes() % 10).toBe(0) // Should align with the interval
expect(nextRun.getUTCMinutes() % 10).toBe(0) // Should align with the interval
})
})