import { DataTypes } from '@reltio/mdm-sdk';
import { fromEditorValue, toEditorValue } from './helpers';
describe('FilterValueEditor helpers', function () {
    describe('TYPE_TIMESTAMP', function () {
        it('toEditorValue returns Date constructed from value when flag is off', function () {
            var ms = Date.UTC(2020, 1, 20, 7, 0, 0);
            expect(toEditorValue(DataTypes.TYPE_TIMESTAMP)(ms)).toEqual(new Date(ms));
        });
        it('toEditorValue uses toLocalDate when flag is on (numeric input)', function () {
            var ms = Date.UTC(2020, 1, 20, 7, 0, 0);
            var result = toEditorValue(DataTypes.TYPE_TIMESTAMP, { disableTimestampLocalization: true })(ms);
            var utcDate = new Date(ms);
            var expected = new Date(utcDate.getUTCFullYear(), utcDate.getUTCMonth(), utcDate.getUTCDate(), utcDate.getUTCHours(), utcDate.getUTCMinutes(), utcDate.getUTCSeconds(), utcDate.getUTCMilliseconds());
            expect(result.getTime()).toBe(expected.getTime());
        });
        it('fromEditorValue returns local epoch ms when flag is off', function () {
            var localDate = new Date(2020, 1, 20, 7, 0, 0);
            expect(fromEditorValue(DataTypes.TYPE_TIMESTAMP)(localDate)).toBe(localDate.valueOf());
        });
        it('fromEditorValue preserves local parts as UTC when flag is on', function () {
            var localDate = new Date(2020, 1, 20, 7, 0, 0);
            var result = fromEditorValue(DataTypes.TYPE_TIMESTAMP, { disableTimestampLocalization: true })(localDate);
            expect(result).toBe(Date.UTC(localDate.getFullYear(), localDate.getMonth(), localDate.getDate(), localDate.getHours(), localDate.getMinutes(), localDate.getSeconds(), localDate.getMilliseconds()));
        });
        it('passes through DateRange values regardless of flag', function () {
            expect(toEditorValue(DataTypes.TYPE_TIMESTAMP, { disableTimestampLocalization: true })('lastDay')).toBe('lastDay');
            expect(fromEditorValue(DataTypes.TYPE_TIMESTAMP, { disableTimestampLocalization: true })('lastDay')).toBe('lastDay');
        });
    });
});
