UNPKG

react-openfin-mat-impl

Version:
123 lines 5.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const React = require("react"); const react_openfin_1 = require("react-openfin"); const styles_1 = require("@material-ui/core/styles"); const styles_2 = require("@material-ui/styles"); const test_utils_1 = require("@material-ui/core/test-utils"); const react_router_dom_1 = require("react-router-dom"); const Snackbar_1 = require("@material-ui/core/Snackbar"); const Dashboard_1 = require("./Dashboard"); const components_1 = require("../../components"); const SvgIcon_1 = require("@material-ui/core/SvgIcon/SvgIcon"); const muiTheme = styles_1.createMuiTheme({}); let ViewOne; let dashboardRoutes; describe('Dashboard layout', () => { let shallow; let mount; beforeAll(() => { react_openfin_1.InitializeReactOpenfin({ finUuid: process.env.REACT_APP_FIN_UUID, finMockupForceSilentMode: true, i18n: {}, hist: {}, configTabs: [], launchBarItems: [], }); }); beforeEach(() => { mount = test_utils_1.createMount(); shallow = test_utils_1.createShallow(); ViewOne = ({}) => { return (React.createElement(React.Fragment, null, "dummy view one")); }; dashboardRoutes = [ { path: '/dashboard/view-one', sidebarName: "viewOne.sidebar", navbarName: "viewOne.navbar", icon: SvgIcon_1.default, component: ViewOne, }, ]; }); afterEach(() => { // mount.cleanUp(); }); it('render in normal state correctly by default', () => { const wrapper = mount(React.createElement(react_openfin_1.ReactOpenfin, null, React.createElement(styles_2.ThemeProvider, { theme: muiTheme }, React.createElement(react_router_dom_1.MemoryRouter, { initialEntries: ['/dashboard/view-one'] }, React.createElement(Dashboard_1.default, { appLogo: '', routes: dashboardRoutes, location: { pathname: '/dashboard/view-one' } }))))); expect(wrapper.find(ViewOne)).toHaveLength(1); expect(wrapper.find(Dashboard_1.default)).toHaveLength(1); wrapper.find(components_1.Header).props().handleDrawerToggle(); wrapper.find(components_1.Header).props().onSwitchToLaunchBar(); wrapper.find(components_1.Header).props().onMinimize(); wrapper.find(components_1.Header).props().onMaximize(); wrapper.find(components_1.Header).props().onClose(); // snackbar events expect(wrapper.find(Snackbar_1.default)).toHaveLength(1); // wrapper.find(Snackbar).props().onClose(); // wrapper.find(Snackbar).props().onExited(); }); // it('render SnackbarContent and could be closed correctly',()=>{ // const initialState = { // application:{ // username:'', // computerName:'', // machineId:null, // deviceUserId:null, // loading:true, // drawerOpen:true, // launchBarCollapse:false, // snackBarOpen:true, // snackBarMsgInfo:{ // variant:'primary', // message:'message', // }, // snackBarMsgQueue:[], // openfinVersion:'n/a', // openfinHostSpec:{}, // windowsState:'normal', // }, // client:{ // count:0, // }, // config:{ // application:{ // theme:MuiTheme.DARK, // } // } // }; // // const store = mockStore(initialState); // const wrapper = mount( // <ThemeProvider theme={muiTheme}> // <Provider store={store}> // <MemoryRouter initialEntries={['/dashboard/view-one']}> // <GlobalContext // config={initialState.config} // > // <Dashboard location={{pathname:'/dashboard/view-one'}}/> // </GlobalContext> // </MemoryRouter> // </Provider> // </ThemeProvider> // ); // expect(wrapper.find(ViewOne)).toHaveLength(1); // expect(wrapper.find(Dashboard)).toHaveLength(1); // wrapper.find(Header).props().handleDrawerToggle(); // wrapper.find(Header).props().onSwitchToLaunchBar(); // wrapper.find(Header).props().onMinimize(); // wrapper.find(Header).props().onMaximize(); // wrapper.find(Header).props().onClose(); // // SnackbarContent events // expect(wrapper.find(SnackbarContent)).toHaveLength(1); // wrapper.find(SnackbarContent).props().onClose(); // // expect(store.getActions()).toMatchSnapshot(); // }) }); //# sourceMappingURL=Dashboard.spec.js.map