/* @oracle/oraclejet-preact: undefined */
'use strict';

var jsxRuntime = require('preact/jsx-runtime');
var preact = require('@testing-library/preact');
var chai = require('chai');
require('../../Menu-77687523.js');
var MenuItem = require('../../MenuItem-1878e08e.js');
require('preact/hooks');
require('preact');
require('../../logger-2b636482.js');
require('../../LayerHost-8ec73638.js');
var EnvironmentProvider = require('../../EnvironmentProvider-753342f1.js');


require('../../hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentVariants.css.js');
require('../../tooltipUtils-d461919d.js');

require('../../SelectMenuGroupContext-bbb4f7e0.js');
require('../../UNSAFE_Separator/themes/SeparatorStyles.css.js');


require('../../UNSAFE_Menu/themes/redwood/MenuSeparatorVariants.css.js');
require('preact/compat');
var userEvent = require('@testing-library/user-event');
var menuTestsUtils = require('../../menuTestsUtils-9d5d258a.js');
var matchTranslationBundle = require('../../matchTranslationBundle-99625a42.js');
var PieChart = require('../../PieChart-4ad1a50d.js');
require('../../Dropdown-f12a07c1.js');
require('../../Floating-dd6667de.js');
require('../../useFloating-c64ecd7f.js');
require('../../useUser-c85f9587.js');
require('../../positionUtils-a780137e.js');
require('../../refUtils-915b985d.js');
require('../../useOutsideClick-8e9209c6.js');
require('../../arrayUtils-7d8dcfc3.js');
require('../../Layer-2352de5e.js');
require('../../classNames-c14c6ef3.js');
require('../../UNSAFE_Layer/themes/LayerStyles.css.js');

require('../../useThemeInterpolations-e3c7807c.js');
require('../../useColorScheme-b4de9e67.js');
require('../../useScale-779458a9.js');
require('../../theme-dfd6a9fe.js');
require('../../Theme-f06687af.js');
require('../../mergeInterpolations-6727b536.js');
require('../../mergeDeepWithKey-210b024d.js');
require('../../_curry3-18677bca.js');
require('../../_curry1-e8f0d7ea.js');
require('../../_curry2-c15d89cd.js');
require('../../_isObject-28636267.js');
require('../../useDensity-301606ec.js');
require('../../useModal-0739a528.js');
require('../../useComponentTheme-082fc8e4.js');
require('../../utils-606327d1.js');
require('../../Common/themes/themeContract.css.js');
require('../../colorUtils-fe6f2fbf.js');
require('../../UNSAFE_Floating/themes/redwood/FloatingTheme.js');
require('../../UNSAFE_Floating/themes/FloatingStyles.css.js');

require('../../UNSAFE_Floating/themes/redwood/FloatingBaseTheme.css.js');

require('../../UNSAFE_Floating/themes/redwood/FloatingVariants.css.js');
require('../../vanilla-extract-recipes-createRuntimeFn.esm-d1301b2d.js');
require('../../vanilla-extract-dynamic.esm-d5dffce7.js');
require('../../UNSAFE_Floating/themes/FloatingContract.css.js');
require('../../keyboardUtils-c071859a.js');
require('../../clientHints-89c01238.js');
require('../../tabbableUtils-66ae6ba3.js');
require('../../head-68d0992f.js');
require('../../_arity-c228159c.js');
require('../../_isArray-73160ad5.js');
require('../../_isString-f4443c9e.js');
require('../../usePopupAnimation-be93af25.js');
require('../../useAnimationStatus-e55dfa64.js');
require('../../useAnimation-fb11e4cc.js');
require('../../popupAnimationUtils-dcace427.js');
require('../../CollectionInteractionContext-f84ff7a1.js');
require('../../UNSAFE_Dropdown/themes/dropdownStyles.css.js');

require('../../useOutsideMousedown-a8c09ad9.js');
require('../../animationUtils-54852d03.js');
require('../../mergeProps-e3da7237.js');
require('../../UNSAFE_Menu/themes/MenuStyles.css.js');

require('../../useTestId-32c35bff.js');
require('../../UNSAFE_Menu/themes/DropdownMenuStyles.css.js');

require('../../Sheet-78113d87.js');
require('../../Modal-64a0608b.js');
require('../../UNSAFE_Modal/themes/ModalStyles.css.js');

require('../../popupUtils-79b1d484.js');
require('../../WindowOverlay-7ef8a86f.js');
require('../../UNSAFE_WindowOverlay/themes/WindowOverlayStyles.css.js');

require('../../UNSAFE_WindowOverlay/themes/WindowOverlayContract.css.js');
require('../../UNSAFE_WindowOverlay/themes/redwood/WindowOverlayTheme.js');
require('../../UNSAFE_WindowOverlay/themes/redwood/WindowOverlayBaseTheme.css.js');

require('../../UNSAFE_WindowOverlay/themes/redwood/WindowOverlayVariants.css.js');
require('../../UNSAFE_Sheet/themes/SheetStyles.css.js');

require('../../UNSAFE_Menu/themes/SheetMenuStyles.css.js');

require('../../Text-15923d58.js');
require('../../UNSAFE_Text/themes/TextStyles.css.js');

require('../../useId-6c0eeb27.js');
require('../../usePress-886180e4.js');
require('../../flexitem-fee13e26.js');

require('../../vanilla-extract-sprinkles-createRuntimeSprinkles.esm-d68f3e0f.js');
require('../../useInteractionStyle-379ee8fa.js');
require('../../useHover-c099039f.js');
require('../../useToggle-3ebba7d8.js');
require('../../useActive-6770f917.js');
require('../../UNSAFE_Menu/themes/redwood/MenuItemTheme.js');
require('../../UNSAFE_Menu/themes/MenuItemStyles.css.js');

require('../../UNSAFE_Menu/themes/redwood/MenuItemBaseTheme.css.js');

require('../../UNSAFE_Menu/themes/redwood/MenuItemVariants.css.js');

require('../../Common/themes/redwood/theme.js');
require('../../UNSAFE_Layer/themes/LayerHostStyles.css.js');

require('../../LayerManager-4857dbaf.js');


require('../themes/PieChartStyles.css.js');

require('../../TrackResizeContainer-96619aba.js');
require('../../useSize-e66dc3a5.js');
require('../../useResizeObserver-1597395f.js');
require('../../useVisAddBusyState-1564f647.js');
require('../../VisBusyStateContext-223f53dd.js');
require('../../useVisBusyStateContext-090a1870.js');
require('../../size-0056ef1a.js');
require('../../pathUtils-ba10ce25.js');
require('../../layoutUtils-0615d614.js');
require('../../scale-22a7b539.js');
require('../../labelUtils-552aaaff.js');
require('../../textUtils-e779c845.js');
require('../../accUtils-dcffb3de.js');
require('../../utils-58341a2f.js');
require('../../datatipUtils-1f747b7f.js');
require('../../clientUtils-c5a6872f.js');
require('../../dimensionUtils-3919753d.js');
require('../../getLocale-8e17dc46.js');
require('../../stringUtils-4e4a6b2b.js');
require('../../usePieChartNav-9366534e.js');
require('../../layoutUtils-c2c02501.js');
require('../../eventsUtils-1abb6028.js');
require('../../useVisHover-ad36112d.js');
require('../../useDatatip-14e6aeb0.js');
require('../../hooks/PRIVATE_useDatatip/themes/useDatatip.css.js');

require('../../VisTabularDatatip-275aecb1.js');
require('../../PRIVATE_VisTabularDatatip/themes/VisTabularDatatipStyles.css.js');

require('../../colorUtils-d762d81b.js');
require('../../useVisTouchResponse-376e11d5.js');
require('../../useContextMenu-24530094.js');
require('../../useContextMenuGesture-fb7f7df5.js');
require('../../textSelectionUtils-432ab66b.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var userEvent__default = /*#__PURE__*/_interopDefaultLegacy(userEvent);

function __variableDynamicImportRuntime0__(path) {
  switch (path) {
    case '../../resources/nls/ar/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/ar/bundle.js'); });
    case '../../resources/nls/ar-XB/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/ar-XB/bundle.js'); });
    case '../../resources/nls/bg/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/bg/bundle.js'); });
    case '../../resources/nls/bs/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/bs/bundle.js'); });
    case '../../resources/nls/bs-Cyrl/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/bs-Cyrl/bundle.js'); });
    case '../../resources/nls/cs/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/cs/bundle.js'); });
    case '../../resources/nls/da/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/da/bundle.js'); });
    case '../../resources/nls/de/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/de/bundle.js'); });
    case '../../resources/nls/el/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/el/bundle.js'); });
    case '../../resources/nls/en/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/en/bundle.js'); });
    case '../../resources/nls/en-XA/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/en-XA/bundle.js'); });
    case '../../resources/nls/en-XC/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/en-XC/bundle.js'); });
    case '../../resources/nls/es/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/es/bundle.js'); });
    case '../../resources/nls/et/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/et/bundle.js'); });
    case '../../resources/nls/fi/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/fi/bundle.js'); });
    case '../../resources/nls/fr/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/fr/bundle.js'); });
    case '../../resources/nls/fr-CA/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/fr-CA/bundle.js'); });
    case '../../resources/nls/he/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/he/bundle.js'); });
    case '../../resources/nls/hr/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/hr/bundle.js'); });
    case '../../resources/nls/hu/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/hu/bundle.js'); });
    case '../../resources/nls/is/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/is/bundle.js'); });
    case '../../resources/nls/it/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/it/bundle.js'); });
    case '../../resources/nls/ja/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/ja/bundle.js'); });
    case '../../resources/nls/ko/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/ko/bundle.js'); });
    case '../../resources/nls/lt/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/lt/bundle.js'); });
    case '../../resources/nls/lv/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/lv/bundle.js'); });
    case '../../resources/nls/ms/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/ms/bundle.js'); });
    case '../../resources/nls/nl/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/nl/bundle.js'); });
    case '../../resources/nls/no/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/no/bundle.js'); });
    case '../../resources/nls/pl/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/pl/bundle.js'); });
    case '../../resources/nls/pt/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/pt/bundle.js'); });
    case '../../resources/nls/pt-PT/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/pt-PT/bundle.js'); });
    case '../../resources/nls/ro/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/ro/bundle.js'); });
    case '../../resources/nls/ru/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/ru/bundle.js'); });
    case '../../resources/nls/sk/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/sk/bundle.js'); });
    case '../../resources/nls/sl/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/sl/bundle.js'); });
    case '../../resources/nls/sr/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/sr/bundle.js'); });
    case '../../resources/nls/sr-Latn/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/sr-Latn/bundle.js'); });
    case '../../resources/nls/sv/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/sv/bundle.js'); });
    case '../../resources/nls/th/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/th/bundle.js'); });
    case '../../resources/nls/tr/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/tr/bundle.js'); });
    case '../../resources/nls/uk/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/uk/bundle.js'); });
    case '../../resources/nls/vi/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/vi/bundle.js'); });
    case '../../resources/nls/zh-Hans/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/zh-Hans/bundle.js'); });
    case '../../resources/nls/zh-Hant/bundle.ts': return Promise.resolve().then(function () { return require('../../resources/nls/zh-Hant/bundle.js'); });
    default: return new Promise(function(resolve, reject) {
      (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)(
        reject.bind(null, new Error("Unknown variable dynamic import: " + path))
      );
    })
   }
 }
const pieData = [
    { id: 1, value: 5 },
    { id: 2, value: 4 },
    { id: 3, value: 4 }
];
describe('Test PieChart component', () => {
    it('render', async function () {
        preact.render(jsxRuntime.jsx(PieChart.PieChart, { data: pieData, width: '400px', height: '400px', "aria-label": "pie chart label" }));
        const ariaText = preact.screen.getAllByLabelText('pie chart label');
        chai.expect(ariaText).not.null;
        const ariaRole = preact.screen.getByRole('application');
        chai.expect(ariaRole).not.null;
    });
    if (typeof jest === 'undefined') {
        it('trigger context menu on right click', async () => {
            const config = {
                // The menu items returned by itemsRenderer must be valid children for the Menu component
                itemsRenderer: () => {
                    return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MenuItem.MenuItem, { label: `MenuItem1` }), jsxRuntime.jsx(MenuItem.MenuItem, { label: `MenuItem2` })] }));
                }
            };
            const { container } = await setupPieChart(config);
            const root = 
            // eslint-disable-next-line
            container.firstElementChild?.firstElementChild?.firstElementChild?.firstElementChild;
            const firstElement = root;
            //We do the necessary to have firstItem as current item
            preact.fireEvent.contextMenu(firstElement, {
                clientX: 50,
                clientY: 50,
                currentTarget: root
            });
            const menu = menuTestsUtils.getMenuItemByRole('menu');
            const menuItems = menuTestsUtils.getAllMenuItemsByRole('menuitem');
            //With this we check context menu context was set correctly
            const menuItemGotByLabel = menuTestsUtils.getLabel('MenuItem1');
            chai.expect(menu).not.null;
            chai.expect(menuItems.length).equals(2);
            chai.expect(menuItemGotByLabel).not.null;
        });
        it('trigger context menu from Keyboard (shift + f10) ', async () => {
            const config = {
                // The menu items returned by itemsRenderer must be valid children for the Menu component
                itemsRenderer: () => {
                    return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MenuItem.MenuItem, { label: `MenuItem1` }), jsxRuntime.jsx(MenuItem.MenuItem, { label: `MenuItem2` })] }));
                }
            };
            const { container } = await setupPieChart(config);
            // eslint-disable-next-line
            const root = // eslint-disable-next-line
             container.firstElementChild?.firstElementChild?.firstElementChild;
            await userEvent__default["default"].tab();
            await userEvent__default["default"].keyboard('[ENTER]');
            preact.fireEvent.keyDown(root, { key: 'F10', shiftKey: true });
            const menu = menuTestsUtils.getMenuItemByRole('menu');
            const menuItems = menuTestsUtils.getAllMenuItemsByRole('menuitem');
            //With this we check context menu context was set correctly
            const menuItemGotByLabel = menuTestsUtils.getLabel('MenuItem1');
            chai.expect(menu).not.null;
            chai.expect(menuItems.length).equals(2);
            chai.expect(menuItemGotByLabel).not.null;
        });
        it('should not trigger context menu when there is no data ', async () => {
            const config = {
                // The menu items returned by itemsRenderer must be valid children for the Menu component
                itemsRenderer: () => {
                    return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MenuItem.MenuItem, { label: `MenuItem1` }), jsxRuntime.jsx(MenuItem.MenuItem, { label: `MenuItem2` })] }));
                }
            };
            const { container } = await setupPieChart(config, []);
            // eslint-disable-next-line
            const root = // eslint-disable-next-line
             container.firstElementChild;
            await userEvent__default["default"].tab();
            await userEvent__default["default"].keyboard('[ENTER]');
            preact.fireEvent.keyDown(root, { key: 'F10', shiftKey: true });
            const menu = preact.screen.queryByRole('menu');
            chai.expect(menu).null;
        });
    }
});
const setupPieChart = async (contextMenuConfig, data = pieData) => {
    const locale = matchTranslationBundle.matchTranslationBundle(['en'], new Set(['en-US', 'en']));
    const { default: translations } = await __variableDynamicImportRuntime0__(`../../resources/nls/${locale}/bundle.ts`);
    const env = {
        translations: { '@oracle/oraclejet-preact': translations }
    };
    return preact.render(jsxRuntime.jsx(EnvironmentProvider.RootEnvironmentProvider, { environment: env, children: jsxRuntime.jsx(PieChart.PieChart, { contextMenuConfig: contextMenuConfig, data: data, width: '400px', height: '400px', "aria-label": "pie chart label" }) }));
};
//# sourceMappingURL=PieChart.spec.js.map
