"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const Dimension_js_1 = require("./Dimension.js");
(0, vitest_1.describe)('Dimension math functions', () => {
    (0, vitest_1.it)('works with two grid units', () => {
        const added = Dimension_js_1.Dimension.add(Dimension_js_1.Dimension.gridUnit(1), Dimension_js_1.Dimension.gridUnit(3));
        const minused = Dimension_js_1.Dimension.minus(Dimension_js_1.Dimension.gridUnit(1), Dimension_js_1.Dimension.gridUnit(3));
        const maxed = Dimension_js_1.Dimension.max(Dimension_js_1.Dimension.gridUnit(1), Dimension_js_1.Dimension.gridUnit(3));
        const minned = Dimension_js_1.Dimension.min(Dimension_js_1.Dimension.gridUnit(1), Dimension_js_1.Dimension.gridUnit(3));
        (0, vitest_1.expect)(added.asFirst()).toEqual({
            value: 4,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(added.asSecond()).toEqual({
            value: 4,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(added.value).toEqual(4);
        (0, vitest_1.expect)(minused.asFirst()).toEqual({
            value: -2,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(minused.asSecond()).toEqual({
            value: -2,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(minused.value).toEqual(-2);
        (0, vitest_1.expect)(maxed.asFirst()).toEqual({
            value: 3,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(maxed.asSecond()).toEqual({
            value: 3,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(maxed.value).toEqual(3);
        (0, vitest_1.expect)(minned.asFirst()).toEqual({
            value: 1,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(minned.asSecond()).toEqual({
            value: 1,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(minned.value).toEqual(1);
    });
    (0, vitest_1.it)('works with two grid like units', () => {
        const added = Dimension_js_1.Dimension.add(Dimension_js_1.Dimension.gridUnit(1), Dimension_js_1.Dimension.fitContent(3));
        const minused = Dimension_js_1.Dimension.minus(Dimension_js_1.Dimension.gridUnit(1), Dimension_js_1.Dimension.fitContent(3));
        const maxed = Dimension_js_1.Dimension.max(Dimension_js_1.Dimension.gridUnit(1), Dimension_js_1.Dimension.fitContent(3));
        const minned = Dimension_js_1.Dimension.min(Dimension_js_1.Dimension.gridUnit(1), Dimension_js_1.Dimension.fitContent(3));
        (0, vitest_1.expect)(added.asFirst()).toEqual({
            value: 4,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(added.asSecond()).toEqual({
            value: 4,
            mode: 'fitContent'
        });
        (0, vitest_1.expect)(added.value).toEqual(4);
        (0, vitest_1.expect)(added.as('gridUnit')).toEqual({
            value: 4,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(added.as('fitContent')).toEqual({
            value: 4,
            mode: 'fitContent'
        });
        (0, vitest_1.expect)(minused.asFirst()).toEqual({
            value: -2,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(minused.asSecond()).toEqual({
            value: -2,
            mode: 'fitContent'
        });
        (0, vitest_1.expect)(minused.value).toEqual(-2);
        (0, vitest_1.expect)(minused.as('gridUnit')).toEqual({
            value: -2,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(minused.as('fitContent')).toEqual({
            value: -2,
            mode: 'fitContent'
        });
        (0, vitest_1.expect)(maxed.asFirst()).toEqual({
            value: 3,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(maxed.asSecond()).toEqual({
            value: 3,
            mode: 'fitContent'
        });
        (0, vitest_1.expect)(maxed.value).toEqual(3);
        (0, vitest_1.expect)(maxed.as('gridUnit')).toEqual({
            value: 3,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(maxed.as('fitContent')).toEqual({
            value: 3,
            mode: 'fitContent'
        });
        (0, vitest_1.expect)(minned.asFirst()).toEqual({
            value: 1,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(minned.asSecond()).toEqual({
            value: 1,
            mode: 'fitContent'
        });
        (0, vitest_1.expect)(minned.value).toEqual(1);
        (0, vitest_1.expect)(minned.as('gridUnit')).toEqual({
            value: 1,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(minned.as('fitContent')).toEqual({
            value: 1,
            mode: 'fitContent'
        });
    });
    (0, vitest_1.it)('works with two px units', () => {
        const added = Dimension_js_1.Dimension.add(Dimension_js_1.Dimension.px(1), Dimension_js_1.Dimension.px(3));
        const minused = Dimension_js_1.Dimension.minus(Dimension_js_1.Dimension.px(1), Dimension_js_1.Dimension.px(3));
        const maxed = Dimension_js_1.Dimension.max(Dimension_js_1.Dimension.px(1), Dimension_js_1.Dimension.px(3));
        const minned = Dimension_js_1.Dimension.min(Dimension_js_1.Dimension.px(1), Dimension_js_1.Dimension.px(3));
        (0, vitest_1.expect)(added.asFirst()).toEqual({
            value: 4,
            mode: 'px'
        });
        (0, vitest_1.expect)(added.asSecond()).toEqual({
            value: 4,
            mode: 'px'
        });
        (0, vitest_1.expect)(added.value).toEqual(4);
        (0, vitest_1.expect)(added.as('px')).toEqual({
            value: 4,
            mode: 'px'
        });
        // testing just-in-case behavior
        (0, vitest_1.expect)(added.as('gridUnit')).toEqual({
            value: 4 / 12,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(minused.asFirst()).toEqual({
            value: -2,
            mode: 'px'
        });
        (0, vitest_1.expect)(minused.asSecond()).toEqual({
            value: -2,
            mode: 'px'
        });
        (0, vitest_1.expect)(minused.value).toEqual(-2);
        (0, vitest_1.expect)(maxed.asFirst()).toEqual({
            value: 3,
            mode: 'px'
        });
        (0, vitest_1.expect)(maxed.asSecond()).toEqual({
            value: 3,
            mode: 'px'
        });
        (0, vitest_1.expect)(maxed.value).toEqual(3);
        (0, vitest_1.expect)(minned.asFirst()).toEqual({
            value: 1,
            mode: 'px'
        });
        (0, vitest_1.expect)(minned.asSecond()).toEqual({
            value: 1,
            mode: 'px'
        });
        (0, vitest_1.expect)(minned.value).toEqual(1);
    });
    (0, vitest_1.it)('works with px and grid like units', () => {
        const inPx = Dimension_js_1.Dimension.px(70);
        const inGU = Dimension_js_1.Dimension.gridUnit(3);
        const inFitContent = Dimension_js_1.Dimension.fitContent(3);
        const parentSpace = 10;
        const added1 = Dimension_js_1.Dimension.add(inPx, inGU, parentSpace);
        const added2 = Dimension_js_1.Dimension.add(inGU, inPx, parentSpace);
        const added3 = Dimension_js_1.Dimension.add(inPx, inFitContent, parentSpace);
        // just going to assume if added1, added2, added3 both work then the permutations for the others will work too
        const minused1 = Dimension_js_1.Dimension.minus(inPx, inGU, parentSpace);
        const maxed1 = Dimension_js_1.Dimension.max(inPx, inGU, parentSpace);
        const minned1 = Dimension_js_1.Dimension.min(inPx, inGU, parentSpace);
        (0, vitest_1.expect)(added1.asFirst()).toEqual({
            value: 100,
            mode: 'px'
        });
        (0, vitest_1.expect)(added1.asSecond()).toEqual({
            value: 10,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(added1.value).toEqual(100);
        (0, vitest_1.expect)(added1.as('px')).toEqual({
            value: 100,
            mode: 'px'
        });
        (0, vitest_1.expect)(added1.as('gridUnit')).toEqual({
            value: 10,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(added2.asFirst()).toEqual({
            value: 10,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(added2.asSecond()).toEqual({
            value: 100,
            mode: 'px'
        });
        (0, vitest_1.expect)(added2.value).toEqual(100);
        (0, vitest_1.expect)(added2.as('px')).toEqual({
            value: 100,
            mode: 'px'
        });
        (0, vitest_1.expect)(added2.as('gridUnit')).toEqual({
            value: 10,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(added3.asFirst()).toEqual({
            value: 100,
            mode: 'px'
        });
        (0, vitest_1.expect)(added3.asSecond()).toEqual({
            value: 10,
            mode: 'fitContent'
        });
        (0, vitest_1.expect)(added3.value).toEqual(100);
        (0, vitest_1.expect)(added3.as('px')).toEqual({
            value: 100,
            mode: 'px'
        });
        (0, vitest_1.expect)(added3.as('fitContent')).toEqual({
            value: 10,
            mode: 'fitContent'
        });
        (0, vitest_1.expect)(minused1.asFirst()).toEqual({
            value: 40,
            mode: 'px'
        });
        (0, vitest_1.expect)(minused1.asSecond()).toEqual({
            value: 4,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(minused1.value).toEqual(40);
        (0, vitest_1.expect)(minused1.as('px')).toEqual({
            value: 40,
            mode: 'px'
        });
        (0, vitest_1.expect)(minused1.as('gridUnit')).toEqual({
            value: 4,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(maxed1.asFirst()).toEqual({
            value: 70,
            mode: 'px'
        });
        (0, vitest_1.expect)(maxed1.asSecond()).toEqual({
            value: 7,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(maxed1.value).toEqual(70);
        (0, vitest_1.expect)(maxed1.as('px')).toEqual({
            value: 70,
            mode: 'px'
        });
        (0, vitest_1.expect)(maxed1.as('gridUnit')).toEqual({
            value: 7,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(minned1.asFirst()).toEqual({
            value: 30,
            mode: 'px'
        });
        (0, vitest_1.expect)(minned1.asSecond()).toEqual({
            value: 3,
            mode: 'gridUnit'
        });
        (0, vitest_1.expect)(minned1.value).toEqual(30);
        (0, vitest_1.expect)(minned1.as('px')).toEqual({
            value: 30,
            mode: 'px'
        });
        (0, vitest_1.expect)(minned1.as('gridUnit')).toEqual({
            value: 3,
            mode: 'gridUnit'
        });
    });
});
// eslint-disable-next-line
const typeTest = () => {
    // This should cause typescript error because if we're mixing px with non px then parentColumnSpace should be required
    // @ts-expect-error
    Dimension_js_1.Dimension.add(Dimension_js_1.Dimension.gridUnit(1), Dimension_js_1.Dimension.px(1));
    Dimension_js_1.Dimension.add(Dimension_js_1.Dimension.gridUnit(1), Dimension_js_1.Dimension.px(1), 1);
    // should be allowed to pass parentColumnSpace even if we know we're not mixing types
    Dimension_js_1.Dimension.add(Dimension_js_1.Dimension.gridUnit(1), Dimension_js_1.Dimension.gridUnit(1), 1);
};
//# sourceMappingURL=Dimension.test.js.map