diff --git a/src/__tests__/units/components/cmd_bar/01_viewer.test.js b/src/__tests__/units/components/cmd_bar/01_viewer.test.js new file mode 100644 index 00000000..994f026b --- /dev/null +++ b/src/__tests__/units/components/cmd_bar/01_viewer.test.js @@ -0,0 +1,49 @@ +import configureStore from 'redux-mock-store' +import { Provider } from 'react-redux' +import { render } from '@testing-library/react'; +import '@testing-library/jest-dom'; +import Viewer from '../../../../components/cmd_bar/01_viewer' +import { LIST_UI_VIEWER_TYPE } from '../../../../constants/list_ui'; +import { LIST_LAYOUT } from '../../../../constants/list_layout'; + +const mockStore = configureStore([]); +const store = mockStore({ + ui: LIST_UI_VIEWER_TYPE.SPECTRUM, + layout: LIST_LAYOUT.H1, +}); + +const dispatchMock = () => Promise.resolve({}); +store.dispatch = jest.fn(dispatchMock); + +describe('', () => { + let AppWrapper; + beforeEach(() => { + AppWrapper = ({ store, children}) => { + return {children} + } + }); + + it('Render Viewer', async () => { + const renderer = + + + + ; + const { queryByTestId } = render(renderer); + const renderResult = queryByTestId('Viewer'); + expect(renderResult).toBeInTheDocument(); + expect(renderResult.childElementCount).toEqual(2); + }); + + it('Render Viewer in editor only mode', () => { + const renderer = + + + + ; + const { queryByTestId } = render(renderer); + const renderResult = queryByTestId('Viewer'); + expect(renderResult).toBeInTheDocument(); + expect(renderResult.childElementCount).toEqual(1); + }); +})