diff --git a/frontend/src/components/ImportDialogBox.js b/frontend/src/components/ImportDialogBox.js index 6c2d7413..90fdc271 100644 --- a/frontend/src/components/ImportDialogBox.js +++ b/frontend/src/components/ImportDialogBox.js @@ -2,13 +2,6 @@ import React, { PropTypes, Component } from 'react' import Dropzone from 'react-dropzone' class ImportDialogBox extends Component { - constructor(props) { - super(props) - - this.state = { - } - } - handleExport = format => () => { window.open(`${window.location.pathname}/export.${format}`, '_blank') } diff --git a/frontend/test/support/dom.js b/frontend/test/support/dom.js new file mode 100644 index 00000000..71d4d82e --- /dev/null +++ b/frontend/test/support/dom.js @@ -0,0 +1,21 @@ +import jsdom from 'jsdom' + +const doc = jsdom.jsdom('') +const win = doc.defaultView + +global.document = doc +global.window = win + +// take all properties of the window object and also attach it to the +// mocha global object +propagateToGlobal(win) + +// from mocha-jsdom https://github.com/rstacruz/mocha-jsdom/blob/master/index.js#L80 +function propagateToGlobal (window) { + for (let key in window) { + if (!window.hasOwnProperty(key)) continue + if (key in global) continue + + global[key] = window[key] + } +} diff --git a/package.json b/package.json index 5c72ffe6..8fb346a7 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "build": "webpack", "build:watch": "webpack --watch", - "test": "mocha-webpack --webpack-config webpack.test.config.js frontend/test", + "test": "mocha-webpack --webpack-config webpack.test.config.js --require frontend/test/support/dom.js frontend/test", "eslint": "eslint frontend", "eslint:fix": "eslint --fix frontend" }, @@ -61,6 +61,7 @@ "eslint-plugin-promise": "^3.4.0", "eslint-plugin-react": "^6.8.0", "eslint-plugin-standard": "^2.0.1", + "jsdom": "^9.11.0", "mocha": "^3.2.0", "mocha-webpack": "^0.7.0" },