import * as __WEBPACK_EXTERNAL_MODULE__tachybase_utils_client__ from "@tachybase/utils/client";
import * as __WEBPACK_EXTERNAL_MODULE_dayjs__ from "dayjs";
import * as __WEBPACK_EXTERNAL_MODULE__util_mjs__ from "../util.mjs";
describe('str2moment', ()=>{
    describe('string value', ()=>{
        test('gmt date', async ()=>{
            const m = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_utils_client__.str2moment)('2022-06-21T00:00:00.000Z', {
                gmt: true
            });
            expect(m.format('YYYY-MM-DD HH:mm:ss')).toBe('2022-06-21 00:00:00');
        });
        test('local date', async ()=>{
            const m = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_utils_client__.str2moment)('2022-06-21T00:00:00.000Z');
            expect(m.toISOString()).toBe('2022-06-21T00:00:00.000Z');
        });
        test('value is null', async ()=>{
            const m = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_utils_client__.str2moment)(null);
            expect(m).toBeNull();
        });
        test('picker is month', async ()=>{
            const m = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_utils_client__.str2moment)('2022-06-01T00:00:00.000Z', {
                picker: 'month'
            });
            expect(m.format('YYYY-MM-DD HH:mm:ss')).toBe('2022-06-01 00:00:00');
        });
    });
    describe('array value', ()=>{
        test('gmt date', async ()=>{
            const arr = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_utils_client__.str2moment)([
                '2022-06-21T00:00:00.000Z',
                '2022-06-21T00:00:00.000Z'
            ], {
                gmt: true
            });
            for (const m of arr)expect(m.format('YYYY-MM-DD HH:mm:ss')).toBe('2022-06-21 00:00:00');
        });
        test('local date', async ()=>{
            const arr = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_utils_client__.str2moment)([
                '2022-06-21T00:00:00.000Z',
                '2022-06-21T00:00:00.000Z'
            ]);
            for (const m of arr)expect(m.toISOString()).toBe('2022-06-21T00:00:00.000Z');
        });
    });
});
describe('moment2str', ()=>{
    test('gmt date', ()=>{
        const m = (0, __WEBPACK_EXTERNAL_MODULE_dayjs__["default"])('2023-06-21 10:10:00');
        const str = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.moment2str)(m, {
            showTime: true,
            gmt: true
        });
        expect(str).toBe('2023-06-21T10:10:00.000Z');
    });
    test('showTime is true, gmt is false', ()=>{
        const m = (0, __WEBPACK_EXTERNAL_MODULE_dayjs__["default"])('2023-06-21 10:10:00');
        const str = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.moment2str)(m, {
            showTime: true,
            gmt: false
        });
        expect(str).toBe(m.toISOString());
    });
    test('gmt is true', ()=>{
        const m = (0, __WEBPACK_EXTERNAL_MODULE_dayjs__["default"])('2023-06-21 10:10:00');
        const str = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.moment2str)(m, {
            gmt: true
        });
        expect(str).toBe('2023-06-21T10:10:00.000Z');
    });
    test('gmt is false', ()=>{
        const m = (0, __WEBPACK_EXTERNAL_MODULE_dayjs__["default"])('2023-06-21 10:10:00');
        const str = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.moment2str)(m, {
            gmt: false
        });
        expect(str).toBe((0, __WEBPACK_EXTERNAL_MODULE_dayjs__["default"])('2023-06-21 10:10:00').toISOString());
    });
    test('with time', ()=>{
        const m = (0, __WEBPACK_EXTERNAL_MODULE_dayjs__["default"])('2023-06-21 10:10:00');
        const str = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.moment2str)(m, {
            showTime: true
        });
        expect(str).toBe(m.toISOString());
    });
    test('picker is year, gmt is false', ()=>{
        const m = (0, __WEBPACK_EXTERNAL_MODULE_dayjs__["default"])('2023-06-21 10:10:00');
        const str = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.moment2str)(m, {
            picker: 'year',
            gmt: false
        });
        expect(str).toBe((0, __WEBPACK_EXTERNAL_MODULE_dayjs__["default"])('2023-01-01 00:00:00').toISOString());
    });
    test('picker is year, gmt is true', ()=>{
        const m = (0, __WEBPACK_EXTERNAL_MODULE_dayjs__["default"])('2023-06-21 10:10:00');
        const str = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.moment2str)(m, {
            picker: 'year',
            gmt: true
        });
        expect(str).toBe('2023-01-01T00:00:00.000Z');
    });
    test('picker is year', ()=>{
        const m = (0, __WEBPACK_EXTERNAL_MODULE_dayjs__["default"])('2023-06-21 10:10:00');
        const str = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.moment2str)(m, {
            picker: 'year'
        });
        expect(str).toBe('2023-01-01T00:00:00.000Z');
    });
    test('picker is quarter, gmt is false', ()=>{
        const m = (0, __WEBPACK_EXTERNAL_MODULE_dayjs__["default"])('2023-06-21 10:10:00');
        const str = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.moment2str)(m, {
            picker: 'quarter',
            gmt: false
        });
        expect(str).toBe((0, __WEBPACK_EXTERNAL_MODULE_dayjs__["default"])('2023-04-01 00:00:00').toISOString());
    });
    test('picker is quarter, gmt is true', ()=>{
        const m = (0, __WEBPACK_EXTERNAL_MODULE_dayjs__["default"])('2023-06-21 10:10:00');
        const str = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.moment2str)(m, {
            picker: 'quarter',
            gmt: true
        });
        expect(str).toBe('2023-04-01T00:00:00.000Z');
    });
    test('picker is month, gmt is false', ()=>{
        const m = (0, __WEBPACK_EXTERNAL_MODULE_dayjs__["default"])('2023-06-21 10:10:00');
        const str = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.moment2str)(m, {
            picker: 'month',
            gmt: false
        });
        expect(str).toBe((0, __WEBPACK_EXTERNAL_MODULE_dayjs__["default"])('2023-06-01 00:00:00').toISOString());
    });
    test('picker is month, gmt is true', ()=>{
        const m = (0, __WEBPACK_EXTERNAL_MODULE_dayjs__["default"])('2023-06-21 10:10:00');
        const str = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.moment2str)(m, {
            picker: 'month',
            gmt: true
        });
        expect(str).toBe('2023-06-01T00:00:00.000Z');
    });
    test('picker is month', ()=>{
        const m = (0, __WEBPACK_EXTERNAL_MODULE_dayjs__["default"])('2023-06-21 10:10:00');
        const str = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.moment2str)(m, {
            picker: 'month'
        });
        expect(str).toBe('2023-06-01T00:00:00.000Z');
    });
    test('picker is week, gmt is false', ()=>{
        const m = (0, __WEBPACK_EXTERNAL_MODULE_dayjs__["default"])('2023-06-21 10:10:00');
        const str = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.moment2str)(m, {
            picker: 'week',
            gmt: false
        });
        expect(str).toBe((0, __WEBPACK_EXTERNAL_MODULE_dayjs__["default"])('2023-06-19 00:00:00').toISOString());
    });
    test('picker is week, gmt is true', ()=>{
        const m = (0, __WEBPACK_EXTERNAL_MODULE_dayjs__["default"])('2023-06-21 10:10:00');
        const str = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.moment2str)(m, {
            picker: 'week',
            gmt: true
        });
        expect(str).toBe('2023-06-19T00:00:00.000Z');
    });
    test('value is null', async ()=>{
        const m = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.moment2str)(null);
        expect(m).toBeNull();
    });
});
