diff --git a/__tests__/src/components/Display.test.js b/__tests__/src/components/Display.test.js deleted file mode 100644 index 80e31232c8e86c960b14802f197343f230f63527..0000000000000000000000000000000000000000 --- a/__tests__/src/components/Display.test.js +++ /dev/null @@ -1,29 +0,0 @@ -import React from 'react'; -import { shallow } from 'enzyme'; -import Display from '../../../src/components/Display'; -import ManifestMetadata from '../../../src/components/ManifestMetadata'; -import fixture from '../../fixtures/version-2/002.json'; - -describe('Display', () => { - it('renders without an error', () => { - const wrapper = shallow(<Display manifest={{}} />); - expect(wrapper.contains(<div className="Display"><div id="exampleManifest" className=""><ManifestMetadata manifest={{}} /></div></div>)).toBe(true); - }); - it('sets class based on manifest state', () => { - let wrapper = shallow(<Display manifest={{ isFetching: true }} />); - expect(wrapper.find('.mirador-fetching').length).toBe(1); - - wrapper = shallow(<Display manifest={{ error: true }} />); - expect(wrapper.find('.mirador-error').length).toBe(1); - }); - it('displays content', () => { - let wrapper = shallow(<Display manifest={{ isFetching: true }} />); - expect(wrapper.text()).toBe('☕'); - - wrapper = shallow(<Display manifest={{ error: { message: 'bad things' } }} />); - expect(wrapper.text()).toBe('bad things'); - - wrapper = shallow(<Display manifest={{ json: fixture }} />); - expect(wrapper.find(ManifestMetadata).length).toBe(1); - }); -}); diff --git a/src/components/Display.js b/src/components/Display.js deleted file mode 100644 index f9db0dd00071959859696844e527ac7f0f7cd039..0000000000000000000000000000000000000000 --- a/src/components/Display.js +++ /dev/null @@ -1,64 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import ManifestMetadata from './ManifestMetadata'; -import ns from '../config/css-ns'; - -/** - * Determines how to best display the content (or lack thereof) the manifest - * @private - */ -const displayContent = (manifest) => { - if (manifest) { - if (manifest.isFetching) { - return '☕'; - } - if (manifest.error) { - return manifest.error.message; - } - return <ManifestMetadata manifest={manifest} />; - } - return 'Nothing Selected Yet'; -}; - -/** - * Determines which classes should be used for display, based on the state of - * the manifest - * @memberof Display - * @private - */ -const stateClass = (manifest) => { - if (manifest) { - if (manifest.isFetching) { - return 'fetching'; - } - if (manifest.error) { - return 'error'; - } - return ''; - } - return 'empty'; -}; - - -/** - * Displays a manifest - * @param {object} props - * @param {object} [props.manifest = undefined] - */ -const Display = ({ manifest }) => ( - <div className="Display"> - <div id="exampleManifest" className={ns(stateClass(manifest))}> - {displayContent(manifest)} - </div> - </div> -); - -Display.propTypes = { - manifest: PropTypes.object, // eslint-disable-line react/forbid-prop-types -}; - -Display.defaultProps = { - manifest: undefined, -}; - -export default Display;