add jsdom for tests
This commit is contained in:
parent
79cdb93ee6
commit
f6b8f8c7c8
3 changed files with 23 additions and 8 deletions
|
@ -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')
|
||||
}
|
||||
|
|
21
frontend/test/support/dom.js
Normal file
21
frontend/test/support/dom.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
import jsdom from 'jsdom'
|
||||
|
||||
const doc = jsdom.jsdom('<!doctype html><html><body></body></html>')
|
||||
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]
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue