+
Download screenshot
IMPORT
@@ -39,8 +35,8 @@ class ImportDialogBox extends Component {
ImportDialogBox.propTypes = {
onFileAdded: PropTypes.func,
- exampleImageUrl: PropTypes.string,
- downloadScreenshot: PropTypes.func
+ downloadScreenshot: PropTypes.func,
+ onExport: PropTypes.func
}
export default ImportDialogBox
diff --git a/frontend/test/Metamaps.Import.spec.js b/frontend/test/Metamaps/Import.spec.js
similarity index 100%
rename from frontend/test/Metamaps.Import.spec.js
rename to frontend/test/Metamaps/Import.spec.js
diff --git a/frontend/test/Metamaps.Util.spec.js b/frontend/test/Metamaps/Util.spec.js
similarity index 100%
rename from frontend/test/Metamaps.Util.spec.js
rename to frontend/test/Metamaps/Util.spec.js
diff --git a/frontend/test/components/ImportDialogBox.spec.js b/frontend/test/components/ImportDialogBox.spec.js
new file mode 100644
index 00000000..f14e04b3
--- /dev/null
+++ b/frontend/test/components/ImportDialogBox.spec.js
@@ -0,0 +1,50 @@
+/* global describe, it */
+import React from 'react'
+import TestUtils from 'react-addons-test-utils' // ES6
+import ImportDialogBox from '../../src/components/ImportDialogBox.js'
+import Dropzone from 'react-dropzone'
+import chai from 'chai'
+
+const { expect } = chai
+
+describe('ImportDialogBox', function() {
+ it('has an Export CSV button', function(done) {
+ const onExport = format => {
+ if (format === 'csv') done()
+ }
+ const detachedComp = TestUtils.renderIntoDocument(
)
+ const button = TestUtils.findRenderedDOMComponentWithClass(detachedComp, 'export-csv')
+ const buttonNode = React.findDOMNode(button)
+ expect(button).to.exist;
+ TestUtils.Simulate.click(buttonNode)
+ })
+
+ it('has an Export JSON button', function(done) {
+ const onExport = format => {
+ if (format === 'json') done()
+ }
+ const detachedComp = TestUtils.renderIntoDocument(
)
+ const button = TestUtils.findRenderedDOMComponentWithClass(detachedComp, 'export-json')
+ const buttonNode = React.findDOMNode(button)
+ expect(button).to.exist;
+ TestUtils.Simulate.click(buttonNode)
+ })
+
+ it('has a Download screenshot button', function(done) {
+ const downloadScreenshot = () => { done() }
+ const detachedComp = TestUtils.renderIntoDocument(
)
+ const button = TestUtils.findRenderedDOMComponentWithClass(detachedComp, 'download-screenshot')
+ const buttonNode = React.findDOMNode(button)
+ expect(button).to.exist;
+ TestUtils.Simulate.click(buttonNode)
+ })
+
+ it('has a file uploader', function(done) {
+ const uploadedFile = { file: 'mock a file' }
+ const onFileAdded = file => { if (file === uploadedFile) done() }
+ const detachedComp = TestUtils.renderIntoDocument(
{}} onFileAdded={onFileAdded} />)
+ const dropzone = TestUtils.findRenderedComponentWithType(detachedComp, Dropzone)
+ expect(dropzone).to.exist;
+ dropzone.props.onDropAccepted([uploadedFile], { preventDefault: () => {} })
+ })
+})
diff --git a/package.json b/package.json
index 076b69c4..84eff416 100644
--- a/package.json
+++ b/package.json
@@ -63,7 +63,8 @@
"eslint-plugin-standard": "^2.0.1",
"jsdom": "^9.11.0",
"mocha": "^3.2.0",
- "mocha-webpack": "^0.7.0"
+ "mocha-webpack": "^0.7.0",
+ "react-addons-test-utils": "^15.4.2"
},
"optionalDependencies": {
"raml2html": "4.0.5"