-
Notifications
You must be signed in to change notification settings - Fork 30
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
Showing
9 changed files
with
77 additions
and
75 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
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
48 changes: 16 additions & 32 deletions
48
...s/lib-classifier/src/components/Classifier/components/SubjectViewer/SubjectViewer.spec.js
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 |
---|---|---|
@@ -1,60 +1,44 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import asyncStates from '@zooniverse/async-states' | ||
import { shallow } from 'enzyme' | ||
|
||
import { SubjectViewer } from './SubjectViewer' | ||
import SingleImageViewer from './components/SingleImageViewer' | ||
import JSONDataViewer from './components/JSONDataViewer' | ||
|
||
describe('Component > SubjectViewer', function () { | ||
it('should render without crashing', function () { | ||
const wrapper = shallow(<SubjectViewer />) | ||
expect(wrapper).to.be.ok() | ||
render(<SubjectViewer />) | ||
expect(screen).to.be.ok() | ||
}) | ||
|
||
it('should render nothing if the subject store is initialized', function () { | ||
const wrapper = shallow(<SubjectViewer subjectQueueState={asyncStates.initialized} />) | ||
expect(wrapper.type()).to.be.null() | ||
const { container } = render(<SubjectViewer subjectQueueState={asyncStates.initialized} />) | ||
expect(container.firstChild).to.be.null() | ||
}) | ||
|
||
|
||
|
||
it('should render a loading indicator if the subject store is loading', function () { | ||
const wrapper = shallow(<SubjectViewer subjectQueueState={asyncStates.loading} />) | ||
expect(wrapper.text()).to.equal('SubjectViewer.loading') | ||
render(<SubjectViewer subjectQueueState={asyncStates.loading} />) | ||
expect(screen.getByText('SubjectViewer.loading')).to.exist() | ||
}) | ||
|
||
it('should render nothing if the subject store errors', function () { | ||
const wrapper = shallow(<SubjectViewer subjectQueueState={asyncStates.error} />) | ||
expect(wrapper.type()).to.be.null() | ||
const { container } = render(<SubjectViewer subjectQueueState={asyncStates.error} />) | ||
expect(container.firstChild).to.be.null() | ||
}) | ||
|
||
it('should render a subject viewer if the subject store successfully loads', function () { | ||
const wrapper = shallow(<SubjectViewer subjectQueueState={asyncStates.success} subject={{ viewer: 'singleImage' }} />) | ||
expect(wrapper.find(SingleImageViewer)).to.have.lengthOf(1) | ||
}) | ||
|
||
it('should pass along the viewer configuration', function () { | ||
const viewerConfiguration = { | ||
zoomConfiguration: { | ||
direction: 'both', | ||
minZoom: 1, | ||
maxZoom: 10, | ||
zoomInValue: 1.2, | ||
zoomOutValue: 0.8 | ||
} | ||
} | ||
|
||
const wrapper = shallow(<SubjectViewer subjectQueueState={asyncStates.success} subject={{ viewer: 'variableStar', viewerConfiguration }} />) | ||
expect(wrapper.find(JSONDataViewer).props().viewerConfiguration).to.deep.equal(viewerConfiguration) | ||
xit('should render a subject viewer if the subject store successfully loads', function () { | ||
render(<SubjectViewer subjectQueueState={asyncStates.success} subject={{ viewer: '__TEST__' }} />) | ||
expect(screen.findByText('viewer.test')).to.exist() | ||
}) | ||
|
||
describe('when there is an null viewer because of invalid subject media', function () { | ||
it('should render null', function () { | ||
const wrapper = shallow( | ||
const { container } = render( | ||
<SubjectViewer | ||
subjectQueueState={asyncStates.success} | ||
subject={{ viewer: null }} | ||
/> | ||
) | ||
expect(wrapper.html()).to.be.null() | ||
expect(container.firstChild).to.be.null() | ||
}) | ||
}) | ||
}) |
9 changes: 9 additions & 0 deletions
9
...sifier/src/components/Classifier/components/SubjectViewer/helpers/getViewer/MockViewer.js
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,9 @@ | ||
function MockViewer() { | ||
return ( | ||
<div>viewer.test</div> | ||
) | ||
} | ||
|
||
MockViewer.propTypes = {} | ||
|
||
export default MockViewer |
4 changes: 3 additions & 1 deletion
4
...ssifier/src/components/Classifier/components/SubjectViewer/helpers/getViewer/getViewer.js
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