1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| import { describe, expect, it } from 'vitest';
|
| import {
| RELATIVE_DATE_VALUE,
| createRelativeDateValue,
| getDateSystemValue,
| getRelativeDateConfig,
| getRelativeDateUnits,
| isRelativeDateValue,
| } from '../relativeDate';
|
| describe('relativeDate', () => {
| it('serializes and parses a calendar-relative date', () => {
| const value = createRelativeDateValue({ anchor: 'currentDate', offset: 3, unit: 'month' });
|
| expect(value).toBe('@relativeDate:currentDate:3:month');
| expect(isRelativeDateValue(value)).toBe(true);
| expect(getDateSystemValue(value)).toBe(RELATIVE_DATE_VALUE);
| expect(getRelativeDateConfig(value, 'datePicker')).toEqual({ anchor: 'currentDate', offset: 3, unit: 'month' });
| });
|
| it('uses only minute and hour offsets for time fields', () => {
| expect(getRelativeDateUnits('timePicker').map((item) => item.id)).toEqual(['minute', 'hour']);
| expect(getRelativeDateConfig(undefined, 'timePicker')).toEqual({ anchor: 'currentTime', offset: 1, unit: 'hour' });
| });
| });
|
|