"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = function(module) {
        var getter = module && module.__esModule ? function() {
            return module['default'];
        } : function() {
            return module;
        };
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
var __webpack_exports__ = {};
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
require("react");
const client_namespaceObject = require("@tachybase/test/client");
const addonBefore_addonAfter_js_namespaceObject = require("../demos/addonBefore&addonAfter.js");
var addonBefore_addonAfter_js_default = /*#__PURE__*/ __webpack_require__.n(addonBefore_addonAfter_js_namespaceObject);
const highPrecisionDecimals_js_namespaceObject = require("../demos/highPrecisionDecimals.js");
var highPrecisionDecimals_js_default = /*#__PURE__*/ __webpack_require__.n(highPrecisionDecimals_js_namespaceObject);
const inputNumber_js_namespaceObject = require("../demos/inputNumber.js");
var inputNumber_js_default = /*#__PURE__*/ __webpack_require__.n(inputNumber_js_namespaceObject);
const external_ReadPretty_js_namespaceObject = require("../ReadPretty.js");
describe('InputNumber', ()=>{
    it('should display the title', ()=>{
        (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(inputNumber_js_default(), {}));
        expect(client_namespaceObject.screen.getByText('Editable').innerHTML).toBe('Editable');
        expect(client_namespaceObject.screen.getByText('Read pretty').innerHTML).toBe('Read pretty');
    });
    it('should display the value of user input', async ()=>{
        const { container } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(inputNumber_js_default(), {}));
        const input = container.querySelector('input');
        client_namespaceObject.fireEvent.change(input, {
            target: {
                value: 1
            }
        });
        expect(input.value).toBe('1');
        expect(client_namespaceObject.screen.getByText('1')).toBeInTheDocument();
        client_namespaceObject.fireEvent.change(input, {
            target: {
                value: ''
            }
        });
        expect(input.value).toBe('');
        expect(client_namespaceObject.screen.queryByText('NaN')).toBeNull();
    });
});
describe('InputNumber: addonBefore/addonAfter', ()=>{
    it('should display the title', ()=>{
        (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(addonBefore_addonAfter_js_default(), {}));
        expect(client_namespaceObject.screen.getByText('Editable').innerHTML).toBe('Editable');
        expect(client_namespaceObject.screen.getByText('Read pretty').innerHTML).toBe('Read pretty');
    });
    it('should display the value of user input', async ()=>{
        const { container } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(addonBefore_addonAfter_js_default(), {}));
        const input = container.querySelector('input');
        client_namespaceObject.fireEvent.change(input, {
            target: {
                value: 1
            }
        });
        expect(input.value).toBe('1');
        expect(client_namespaceObject.screen.getByText('¥')).toBeInTheDocument();
        client_namespaceObject.fireEvent.change(input, {
            target: {
                value: ''
            }
        });
        expect(input.value).toBe('');
        expect(client_namespaceObject.screen.queryByText('NaN')).toBeNull();
    });
});
describe('InputNumber: High precision decimals', ()=>{
    it('should display the title', ()=>{
        (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(highPrecisionDecimals_js_default(), {}));
        expect(client_namespaceObject.screen.getByText('Editable').innerHTML).toBe('Editable');
        expect(client_namespaceObject.screen.getByText('Read pretty').innerHTML).toBe('Read pretty');
    });
    it('should display the value of user input', async ()=>{
        const { container } = (0, client_namespaceObject.render)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(highPrecisionDecimals_js_default(), {}));
        const input = container.querySelector('input');
        client_namespaceObject.fireEvent.change(input, {
            target: {
                value: 1
            }
        });
        expect(input.value).toBe('1.00');
        expect(client_namespaceObject.screen.getByText('1.00')).toBeInTheDocument();
        client_namespaceObject.fireEvent.change(input, {
            target: {
                value: ''
            }
        });
        expect(input.value).toBe('');
        expect(client_namespaceObject.screen.queryByText('NaN')).toBeNull();
    });
});
describe('ReadPretty:formatNumberWithSeparator', ()=>{
    test('Format number with default separator', ()=>{
        const formatted = (0, external_ReadPretty_js_namespaceObject.formatNumberWithSeparator)(1234567.89);
        expect(formatted).toBe('1234567.9');
    });
    test('Format number with custom separator', ()=>{
        const formatted = (0, external_ReadPretty_js_namespaceObject.formatNumberWithSeparator)(1234567.89, '0,0.00', 1);
        expect(formatted).toBe('1,234,567.9');
    });
});
describe('ReadPretty:formatUnitConversion', ()=>{
    test('Multiply value by 2', ()=>{
        const result = (0, external_ReadPretty_js_namespaceObject.formatUnitConversion)(10, '*', 2);
        expect(result).toBe(20);
    });
    test('Divide value by zero', ()=>{
        const result = (0, external_ReadPretty_js_namespaceObject.formatUnitConversion)(10, '/', 0);
        expect(result).toBe(10);
    });
    test('0.1*0.2', ()=>{
        const result = (0, external_ReadPretty_js_namespaceObject.formatUnitConversion)(0.1, '*', 0.2);
        expect(result).toBe(0.02);
    });
});
describe('ReadPretty:scientificNotation', ()=>{
    test('Format number into scientific notation', ()=>{
        const formatted = (0, external_ReadPretty_js_namespaceObject.scientificNotation)(1234567.89, 2);
        expect(formatted).toBe('1.23×10<sup>6</sup>');
    });
    test('Format number into scientific notation with custom separator', ()=>{
        const formatted = (0, external_ReadPretty_js_namespaceObject.scientificNotation)(1234567.89, 2, '.');
        expect(formatted).toBe('1.23×10<sup>6</sup>');
    });
});
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
