import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE__testing_library_react__ from "@testing-library/react";
import * as __WEBPACK_EXTERNAL_MODULE__JsonViewer_mjs__ from "./JsonViewer.mjs";
describe('<JsonViewer />', ()=>{
    beforeEach(()=>{
        Object.defineProperty(window, 'matchMedia', {
            writable: true,
            value: jest.fn().mockImplementation((query)=>({
                    matches: false,
                    media: query,
                    onchange: null,
                    addListener: jest.fn(),
                    removeListener: jest.fn(),
                    addEventListener: jest.fn(),
                    removeEventListener: jest.fn(),
                    dispatchEvent: jest.fn()
                }))
        });
    });
    test('should render a JSON viewer', async ()=>{
        const mockJson = {
            id: 'ce0fbga92d3occ2me5rg',
            name: 'some-fake-cluster-name',
            orgId: 'e862d95e-8fce-424d-a2b3-ab71ed591ab3',
            customerTier: 'CUSTOMER_TIER_STANDARD',
            tags: {
                organizationId: 'e862d95e-8fce-424d-a2b3-ab71ed591ab3',
                ownerId: 'auth0_633b51e692c042646faea4a3',
                networkId: 'ce0fb8i92d3occ2me5qg',
                ownerName: 'test-fake@redpanda.com',
                ownerEmail: 'test-fake@redpanda.com',
                namespaceId: '32b647fc-1945-4b65-842f-5fc9108e4fd7',
                maxThroughput: '1'
            }
        };
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__JsonViewer_mjs__["default"], {
            value: mockJson
        }));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('json-viewer')).toBeVisible();
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('json-viewer')).toHaveTextContent('"root":{5 Items"id":string"ce0fbga92d3occ2me5rg""name":string"some-fake-cluster-name""orgId":string"e862d95e-8fce-424d-a2b3-ab71ed591ab3""customerTier":string"CUSTOMER_TIER_STANDARD""tags":{7 Items"organizationId":string"e862d95e-8fce-424d-a2b3-ab71ed591ab3""ownerId":string"auth0_633b51e692c042646faea4a3""networkId":string"ce0fb8i92d3occ2me5qg""ownerName":string"test-fake@redpanda.com""ownerEmail":string"test-fake@redpanda.com""namespaceId":string"32b647fc-1945-4b65-842f-5fc9108e4fd7""maxThroughput":string"1"}}');
        });
    });
    test('should render JSON with special characters', async ()=>{
        const mockBrokenJson = [
            {
                asdf: {
                    'test2%^@&()': {
                        key: "<>{}$\"\"''@%()/!&123"
                    }
                }
            }
        ];
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__JsonViewer_mjs__["default"], {
            value: mockBrokenJson
        }));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('json-viewer')).toBeVisible();
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('json-viewer')).toHaveTextContent('"root":[1 Items0:{1 Items"asdf":{1 Items"test2%^@&()":{1 Items"key":string"<>{}$""\'\'@%()/!&123"}}}]');
        });
    });
    it('should render undefined value', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__JsonViewer_mjs__["default"], {
            value: void 0
        }));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('json-viewer')).toHaveTextContent('"root":undefined');
        });
    });
    it('should render null value', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__JsonViewer_mjs__["default"], {
            value: null
        }));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('json-viewer')).toHaveTextContent('"root":NULL');
        });
    });
    it('should render NaN value', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__JsonViewer_mjs__["default"], {
            value: NaN
        }));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('json-viewer')).toHaveTextContent('"":NaN');
        });
    });
    it('should render number value', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__JsonViewer_mjs__["default"], {
            value: 12345
        }));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('json-viewer')).toHaveTextContent('"root":int12345');
        });
    });
    it('should render value for negative value', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__JsonViewer_mjs__["default"], {
            value: -0
        }));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('json-viewer')).toHaveTextContent('"root":int0');
        });
    });
    it('should render value for positive value', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__JsonViewer_mjs__["default"], {
            value: 0
        }));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('json-viewer')).toHaveTextContent('"root":int0');
        });
    });
    it('should render value for decimals', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__JsonViewer_mjs__["default"], {
            value: 114.245
        }));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('json-viewer')).toHaveTextContent('"root":float114.245');
        });
    });
    it('should render value for Infinity', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__JsonViewer_mjs__["default"], {
            value: 1 / 0
        }));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('json-viewer')).toHaveTextContent('"root":floatInfinity');
        });
    });
    it('should render value for BigInt', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__JsonViewer_mjs__["default"], {
            value: BigInt(114514)
        }));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('json-viewer')).toHaveTextContent('"root":bigint114514n');
        });
    });
    it('should render everything', async ()=>{
        const everything = {
            longArray: Array.from({
                length: 10
            }).map((_, i)=>i),
            string: 'this is a string',
            integer: 521,
            array: [
                19,
                19,
                810,
                'test',
                NaN
            ],
            nestedArray: [
                [
                    1,
                    2
                ],
                [
                    3,
                    4
                ]
            ],
            map: new Map(),
            set: new Set(),
            float: 114.514,
            undefined,
            superLongString: '11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111',
            object: {
                'first-child': true,
                'second-child': false,
                'last-child': null
            },
            fn: (a, b)=>a + b,
            string_number: '1234',
            timer: 0,
            date: new Date('Tue Sep 13 2022 14:07:44 GMT-0500 (Central Daylight Time)'),
            bigint: BigInt(110101195306153019)
        };
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__JsonViewer_mjs__["default"], {
            value: everything
        }));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('json-viewer').textContent).not.toBeNull();
        });
    });
});
