Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma strängvärde byggs med konkatenering i stället för att matcha mönstret.
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { incrementalLookbackDays } from '../cron-lookback'
|
|
|
|
const NOW = Date.parse('2026-09-02T05:00:00Z')
|
|
const daysAgo = (d: number) => new Date(NOW - d * 24 * 60 * 60 * 1000).toISOString()
|
|
|
|
describe('incrementalLookbackDays', () => {
|
|
it('keeps the 7-day window when the last sync is recent', () => {
|
|
expect(incrementalLookbackDays(daysAgo(0), NOW)).toBe(7)
|
|
expect(incrementalLookbackDays(daysAgo(1), NOW)).toBe(7)
|
|
expect(incrementalLookbackDays(daysAgo(5), NOW)).toBe(7)
|
|
})
|
|
|
|
it('widens the window to cover a gap, with one day of overlap', () => {
|
|
expect(incrementalLookbackDays(daysAgo(7), NOW)).toBe(8)
|
|
expect(incrementalLookbackDays(daysAgo(20), NOW)).toBe(21)
|
|
})
|
|
|
|
it('rounds a partial day up so the gap is never under-covered', () => {
|
|
expect(incrementalLookbackDays(daysAgo(10.4), NOW)).toBe(12)
|
|
})
|
|
|
|
it('caps at the 90-day PSD2 limit', () => {
|
|
expect(incrementalLookbackDays(daysAgo(200), NOW)).toBe(90)
|
|
expect(incrementalLookbackDays(daysAgo(89), NOW)).toBe(90)
|
|
})
|
|
|
|
it('falls back to 7 days when there is no usable timestamp', () => {
|
|
expect(incrementalLookbackDays(null, NOW)).toBe(7)
|
|
expect(incrementalLookbackDays(undefined, NOW)).toBe(7)
|
|
expect(incrementalLookbackDays('not a date', NOW)).toBe(7)
|
|
})
|
|
|
|
it('never goes below 7 days for a future timestamp (clock skew)', () => {
|
|
expect(incrementalLookbackDays(daysAgo(-2), NOW)).toBe(7)
|
|
})
|
|
})
|