mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-02 22:01:52 +00:00
Added test for toDateRange helper function
This commit is contained in:
@@ -6,8 +6,9 @@ import {
|
||||
intervalToDateRange,
|
||||
rangeIsInterval,
|
||||
rangeOrIntervalToString,
|
||||
} from '../../../../src/utils/helpers/dateIntervals';
|
||||
import { parseDate } from '../../../../src/utils/helpers/date';
|
||||
toDateRange,
|
||||
} from '../../../src/utils/helpers/dateIntervals';
|
||||
import { parseDate } from '../../../src/utils/helpers/date';
|
||||
|
||||
describe('date-types', () => {
|
||||
const now = () => new Date();
|
||||
@@ -116,4 +117,23 @@ describe('date-types', () => {
|
||||
expect(dateToMatchingInterval(date)).toEqual(expectedInterval);
|
||||
});
|
||||
});
|
||||
|
||||
describe('toDateRange', () => {
|
||||
it.each([
|
||||
['today' as DateInterval, intervalToDateRange('today')],
|
||||
['yesterday' as DateInterval, intervalToDateRange('yesterday')],
|
||||
['last7Days' as DateInterval, intervalToDateRange('last7Days')],
|
||||
['last30Days' as DateInterval, intervalToDateRange('last30Days')],
|
||||
['last90Days' as DateInterval, intervalToDateRange('last90Days')],
|
||||
['last180Days' as DateInterval, intervalToDateRange('last180Days')],
|
||||
['last365Days' as DateInterval, intervalToDateRange('last365Days')],
|
||||
['all' as DateInterval, intervalToDateRange('all')],
|
||||
[{}, {}],
|
||||
[{ startDate: now() }, { startDate: now() }],
|
||||
[{ endDate: now() }, { endDate: now() }],
|
||||
[{ startDate: daysBack(10), endDate: now() }, { startDate: daysBack(10), endDate: now() }],
|
||||
])('returns properly parsed interval or range', (rangeOrInterval, expectedResult) => {
|
||||
expect(toDateRange(rangeOrInterval)).toEqual(expectedResult);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user