tests pass again

This commit is contained in:
Devin Howard 2017-05-06 18:21:51 -07:00
parent 6eccfe05ef
commit 4acfe495c0

View file

@ -7,39 +7,45 @@ import { shallow } from 'enzyme'
import sinon from 'sinon'
describe('ImportDialogBox', function() {
const csvExport = sinon.spy()
const jsonExport = sinon.spy()
const onExport = format => () => {
if (format === 'csv') {
csvExport()
} else if (format === 'json') {
jsonExport()
}
}
it('has an Export CSV button', () => {
const onExport = sinon.spy()
const wrapper = shallow(<ImportDialogBox onExport={onExport} />)
const button = wrapper.find('.export-csv')
expect(button).to.exist
//button.simulate('click')
expect(onExport).to.have.property('callCount', 1)
expect(onExport.calledWith('csv')).to.equal(true)
button.simulate('click')
expect(csvExport).to.have.property('callCount', 1)
})
it('has an Export JSON button', () => {
const onExport = sinon.spy()
const wrapper = shallow(<ImportDialogBox onExport={onExport} />)
const button = wrapper.find('.export-json')
expect(button).to.exist
//button.simulate('click')
expect(onExport).to.have.property('callCount', 1)
expect(onExport.calledWith('json')).to.equal(true)
button.simulate('click')
expect(jsonExport).to.have.property('callCount', 1)
})
it('has a Download screenshot button', () => {
const onExport = sinon.spy()
const wrapper = shallow(<ImportDialogBox onExport={onExport} />)
const downloadScreenshot = sinon.spy()
const wrapper = shallow(<ImportDialogBox onExport={() => null} downloadScreenshot={downloadScreenshot} />)
const button = wrapper.find('.download-screenshot')
expect(button).to.exist
//button.simulate('click')
expect(onExport).to.have.property('callCount', 1)
button.simulate('click')
expect(downloadScreenshot).to.have.property('callCount', 1)
})
it('has a file uploader', () => {
const uploadedFile = {}
const onFileAdded = sinon.spy()
const wrapper = shallow(<ImportDialogBox onExport={() => {}} onFileAdded={onFileAdded} />)
const wrapper = shallow(<ImportDialogBox onExport={() => null} onFileAdded={onFileAdded} />)
const dropzone = wrapper.find(Dropzone)
dropzone.props().onDropAccepted([uploadedFile], { preventDefault: () => {} })
expect(onFileAdded).to.have.property('callCount', 1)