Skip to content
Snippets Groups Projects
Commit 5201f5b8 authored by Chris Beer's avatar Chris Beer
Browse files

Mark the window object for Window as not required, and guard against missing data

parent 5deee933
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,10 @@ import WindowMiddleContent from '../../../src/containers/WindowMiddleContent';
describe('Window', () => {
let wrapper;
const window = { id: 123, xywh: [0, 0, 400, 500] };
it('should render nothing, if provided with no window data', () => {
wrapper = shallow(<Window />);
expect(wrapper.find('.mirador-window')).toHaveLength(0);
});
it('should render outer element', () => {
wrapper = shallow(<Window window={window} />);
expect(wrapper.find('.mirador-window')).toHaveLength(1);
......
......@@ -15,6 +15,8 @@ class Window extends Component {
*/
render() {
const { manifest, window } = this.props;
if (!window) return <></>;
return (
<div id={window.id} className={ns('window')}>
<WindowTopBar
......@@ -38,11 +40,12 @@ class Window extends Component {
}
Window.propTypes = {
window: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
window: PropTypes.object, // eslint-disable-line react/forbid-prop-types
manifest: PropTypes.object, // eslint-disable-line react/forbid-prop-types
};
Window.defaultProps = {
window: null,
manifest: null,
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment