"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var mdm_sdk_1 = require("@reltio/mdm-sdk");
var helpers_1 = require("./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((0, helpers_1.toEditorValue)(mdm_sdk_1.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 = (0, helpers_1.toEditorValue)(mdm_sdk_1.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((0, helpers_1.fromEditorValue)(mdm_sdk_1.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 = (0, helpers_1.fromEditorValue)(mdm_sdk_1.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((0, helpers_1.toEditorValue)(mdm_sdk_1.DataTypes.TYPE_TIMESTAMP, { disableTimestampLocalization: true })('lastDay')).toBe('lastDay');
            expect((0, helpers_1.fromEditorValue)(mdm_sdk_1.DataTypes.TYPE_TIMESTAMP, { disableTimestampLocalization: true })('lastDay')).toBe('lastDay');
        });
    });
});
