-
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 22, 2023
1 parent
c3bd7d2
commit cd9304a
Showing
44 changed files
with
802 additions
and
639 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
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
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); | ||
}); | ||
}) |
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,35 @@ | ||
import configureStore from 'redux-mock-store' | ||
import { Provider } from 'react-redux' | ||
import { render } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import Zoom from '../../../../components/cmd_bar/02_zoom'; | ||
import { LIST_UI_SWEEP_TYPE } from '../../../../constants/list_ui'; | ||
|
||
const mockStore = configureStore([]); | ||
const store = mockStore({ | ||
ui:{ sweepType: LIST_UI_SWEEP_TYPE.ZOOMIN }, | ||
}); | ||
|
||
const dispatchMock = () => Promise.resolve({}); | ||
store.dispatch = jest.fn(dispatchMock); | ||
|
||
describe('<Zoom />', () => { | ||
let AppWrapper; | ||
beforeEach(() => { | ||
AppWrapper = ({ store, children}) => { | ||
return <Provider store={store}> {children} </Provider> | ||
} | ||
}); | ||
|
||
it('Render Zoom', async () => { | ||
const renderer = | ||
<AppWrapper store={store}> | ||
<Zoom editorOnly={false} /> | ||
</AppWrapper> | ||
; | ||
const { queryByTestId } = render(renderer); | ||
const renderResult = queryByTestId('Zoom'); | ||
expect(renderResult).toBeInTheDocument(); | ||
expect(renderResult.childElementCount).toEqual(2); | ||
}); | ||
}) |
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,24 @@ | ||
import { render } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import { drawMain } from '../../../../components/common/draw'; | ||
import { useEffect } from 'react'; | ||
describe('common/draw', () => { | ||
it('.drawMain()', () => { | ||
function TestComponent({}) { | ||
useEffect(() => { | ||
drawMain('.testsvg', 100, 100) | ||
}, []); | ||
return ( | ||
<div className='testsvg' data-testid="testsvg"></div> | ||
) | ||
} | ||
|
||
const { queryByTestId } = render(<TestComponent />); | ||
const renderResult = queryByTestId('testsvg'); | ||
expect(renderResult).toBeInTheDocument(); | ||
const svgElement = document.querySelector('svg'); | ||
expect(svgElement).toHaveClass('d3Svg'); | ||
expect(svgElement).toHaveAttribute('preserveAspectRatio', 'xMinYMin meet'); | ||
expect(svgElement).toHaveAttribute('viewBox', '0 0 100 100'); | ||
}); | ||
}) |
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.