1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-11 00:08:30 +01:00
unleash.unleash/src/lib/util/time-utils.test.ts
2024-01-11 10:39:41 +01:00

17 lines
495 B
TypeScript

import { generateDayBuckets, generateHourBuckets } from './time-utils';
import { endOfDay, subDays } from 'date-fns';
test('generateHourBuckets', () => {
const result = generateHourBuckets(24);
expect(result).toHaveLength(24);
});
test('generateDayBuckets', () => {
const result = generateDayBuckets(7);
const endOfDayYesterday = endOfDay(subDays(new Date(), 1));
expect(result).toHaveLength(7);
expect(result[0]).toMatchObject({ timestamp: endOfDayYesterday });
});