switch ImportDialogBox to using enzyme but tests are still failing
This commit is contained in:
parent
84e268be2d
commit
b1c6aec050
1 changed files with 35 additions and 37 deletions
|
@ -1,50 +1,48 @@
|
|||
/* global describe, it */
|
||||
import React from 'react'
|
||||
import TestUtils from 'react-addons-test-utils' // ES6
|
||||
import ImportDialogBox from '../../../src/components/ImportDialogBox.js'
|
||||
import ImportDialogBox from '../../../src/components/MapView/ImportDialogBox.js'
|
||||
import Dropzone from 'react-dropzone'
|
||||
import chai from 'chai'
|
||||
|
||||
const { expect } = chai
|
||||
import { expect } from 'chai'
|
||||
import { shallow } from 'enzyme'
|
||||
import sinon from 'sinon'
|
||||
|
||||
describe('ImportDialogBox', function() {
|
||||
it('has an Export CSV button', function(done) {
|
||||
const onExport = format => {
|
||||
if (format === 'csv') done()
|
||||
}
|
||||
const detachedComp = TestUtils.renderIntoDocument(<ImportDialogBox onExport={onExport} />)
|
||||
const button = TestUtils.findRenderedDOMComponentWithClass(detachedComp, 'export-csv')
|
||||
const buttonNode = React.findDOMNode(button)
|
||||
expect(button).to.exist;
|
||||
TestUtils.Simulate.click(buttonNode)
|
||||
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)
|
||||
})
|
||||
|
||||
it('has an Export JSON button', function(done) {
|
||||
const onExport = format => {
|
||||
if (format === 'json') done()
|
||||
}
|
||||
const detachedComp = TestUtils.renderIntoDocument(<ImportDialogBox onExport={onExport} />)
|
||||
const button = TestUtils.findRenderedDOMComponentWithClass(detachedComp, 'export-json')
|
||||
const buttonNode = React.findDOMNode(button)
|
||||
expect(button).to.exist;
|
||||
TestUtils.Simulate.click(buttonNode)
|
||||
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)
|
||||
})
|
||||
|
||||
it('has a Download screenshot button', function(done) {
|
||||
const downloadScreenshot = () => { done() }
|
||||
const detachedComp = TestUtils.renderIntoDocument(<ImportDialogBox downloadScreenshot={downloadScreenshot()} />)
|
||||
const button = TestUtils.findRenderedDOMComponentWithClass(detachedComp, 'download-screenshot')
|
||||
const buttonNode = React.findDOMNode(button)
|
||||
expect(button).to.exist;
|
||||
TestUtils.Simulate.click(buttonNode)
|
||||
it('has a Download screenshot button', () => {
|
||||
const onExport = sinon.spy()
|
||||
const wrapper = shallow(<ImportDialogBox onExport={onExport} />)
|
||||
const button = wrapper.find('.download-screenshot')
|
||||
expect(button).to.exist
|
||||
//button.simulate('click')
|
||||
expect(onExport).to.have.property('callCount', 1)
|
||||
})
|
||||
|
||||
it('has a file uploader', function(done) {
|
||||
const uploadedFile = { file: 'mock a file' }
|
||||
const onFileAdded = file => { if (file === uploadedFile) done() }
|
||||
const detachedComp = TestUtils.renderIntoDocument(<ImportDialogBox onExport={() => {}} onFileAdded={onFileAdded} />)
|
||||
const dropzone = TestUtils.findRenderedComponentWithType(detachedComp, Dropzone)
|
||||
expect(dropzone).to.exist;
|
||||
dropzone.props.onDropAccepted([uploadedFile], { preventDefault: () => {} })
|
||||
it('has a file uploader', () => {
|
||||
const uploadedFile = {}
|
||||
const onFileAdded = sinon.spy()
|
||||
const wrapper = shallow(<ImportDialogBox onExport={() => {}} onFileAdded={onFileAdded} />)
|
||||
const dropzone = wrapper.find(Dropzone)
|
||||
dropzone.props().onDropAccepted([uploadedFile], { preventDefault: () => {} })
|
||||
expect(onFileAdded).to.have.property('callCount', 1)
|
||||
expect(onFileAdded.calledWith(uploadedFile)).to.equal(true)
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue