-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Lan Le
committed
Sep 20, 2023
1 parent
f7ba3b6
commit 3342db5
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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('<Viewer />', () => { | ||
let AppWrapper; | ||
beforeEach(() => { | ||
AppWrapper = ({ store, children}) => { | ||
return <Provider store={store}> {children} </Provider> | ||
} | ||
}); | ||
|
||
it('Render Viewer', async () => { | ||
const renderer = | ||
<AppWrapper store={store}> | ||
<Viewer editorOnly={false} /> | ||
</AppWrapper> | ||
; | ||
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 = | ||
<AppWrapper store={store}> | ||
<Viewer editorOnly={true} /> | ||
</AppWrapper> | ||
; | ||
const { queryByTestId } = render(renderer); | ||
const renderResult = queryByTestId('Viewer'); | ||
expect(renderResult).toBeInTheDocument(); | ||
expect(renderResult.childElementCount).toEqual(1); | ||
}); | ||
}) |