updates on the minor changes like zone updates and datepicker fix
This commit is contained in:
@@ -52,3 +52,33 @@ describe('toDateRange', () => {
|
||||
expect(toDateRange(true)).toEqual({ from: '', to: '' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('toReportRange — DatePicker value → report { from, to }', () => {
|
||||
const { toReportRange } = require('@/lib/dateRange');
|
||||
const dayjsLib = require('dayjs');
|
||||
const todayStr = dayjsLib().format('YYYY-MM-DD');
|
||||
const past = (n) => dayjsLib().subtract(n, 'day').format('YYYY-MM-DD');
|
||||
const future = (n) => dayjsLib().add(n, 'day').format('YYYY-MM-DD');
|
||||
|
||||
it('turns a single day into a one-day range', () => {
|
||||
expect(toReportRange(past(3))).toEqual({ from: past(3), to: past(3) });
|
||||
});
|
||||
|
||||
it('keeps a valid range as it is', () => {
|
||||
expect(toReportRange({ from: past(7), to: past(1) })).toEqual({ from: past(7), to: past(1) });
|
||||
});
|
||||
|
||||
it('puts an inverted range in order', () => {
|
||||
expect(toReportRange({ from: past(1), to: past(7) })).toEqual({ from: past(7), to: past(1) });
|
||||
});
|
||||
|
||||
it('never goes past today', () => {
|
||||
expect(toReportRange(future(2))).toEqual({ from: todayStr, to: todayStr });
|
||||
expect(toReportRange({ from: past(2), to: future(5) })).toEqual({ from: past(2), to: todayStr });
|
||||
});
|
||||
|
||||
it('falls back to today for "all" or nothing', () => {
|
||||
expect(toReportRange('all')).toEqual({ from: todayStr, to: todayStr });
|
||||
expect(toReportRange(undefined)).toEqual({ from: todayStr, to: todayStr });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user