Created
March 16, 2020 10:26
-
-
Save owexroasia/1081e6ae788ea9b7eea3afd27f93d674 to your computer and use it in GitHub Desktop.
unit test
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
import React from 'react'; | |
import { expect } from 'chai'; | |
import { mount, render, shallow } from 'enzyme'; | |
import { spy } from 'sinon'; | |
import configureMockStore from 'redux-mock-store'; | |
import { Provider } from 'react-redux'; | |
import AssessmentDetails from 'components/Species/AssessmentDetails'; | |
describe('Species/AssessmentDetails', () => { | |
it('without data it renders Spinner', () => { | |
const props = { | |
assessment: {}, | |
open: false, | |
toggleDetails: spy(), | |
}; | |
const mockStore = configureMockStore(); | |
const initialState = { | |
expandedAll: false, | |
scrollOffset: 0, | |
detailsOpen: { | |
taxonomy: false, | |
assessment: false, | |
geographicRange: false, | |
population: false, | |
habitat: false, | |
threats: false, | |
useTrade: false, | |
conservationActions: false, | |
bibliography: false, | |
textFields: false, | |
imagesAndExternalLinks: false, | |
speciesPlus: false, | |
conservationEvidence: false, | |
}, | |
}; | |
const store = mockStore(initialState); | |
const wrapper = mount( | |
<Provider store={store}> | |
<AssessmentDetails /> | |
</Provider> | |
); | |
expect(wrapper.find('Spinner')).to.have.length(1); | |
expect(wrapper.find('INaturalistObservations')).to.have.length(0); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment