diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..facd180 --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015", "react"] +} \ No newline at end of file diff --git a/package.json b/package.json index bdec96c..47ae899 100644 --- a/package.json +++ b/package.json @@ -7,10 +7,10 @@ "build:test": "webpack --config ./tests/webpack.config.test.js", "build:testrig": "npm run build:test && open ./tests/index.html", "watch:testrig": "npm run build:test -- --progress --colors --watch", - "test": "istanbul cover _mocha -- --compilers js:babel/register ./tests/**/*tests.js", + "test": "babel-node ./node_modules/istanbul/lib/cli cover _mocha ./tests/**/*tests.js", "posttest": "npm run lint && cat ./coverage/lcov.info | coveralls", - "test:simple": "mocha ./tests/**/*tests.js --compilers js:babel/register", - "test:spec": "mocha ./tests/stand-alone/link-list/link-list-tests --compilers js:babel/register", + "test:simple": "mocha ./tests/**/*tests.js --compilers js:babel-core/register", + "test:spec": "mocha ./tests/stand-alone/link-list/link-list-tests --compilers js:babel-core/register", "lint": "eslint ./src ./tests ./index.js" }, "repository": { @@ -37,24 +37,25 @@ }, "homepage": "https://github.com/craigbilner/react-component-tester#readme", "devDependencies": { - "babel": "5.8.23", - "babel-core": "5.8.25", - "babel-eslint": "4.1.3", - "babel-loader": "5.3.2", - "coveralls": "2.11.4", - "eslint": "1.7.3", - "eslint-config-airbnb": "0.1.0", - "eslint-plugin-react": "3.6.3", + "babel-cli": "6.3.17", + "babel-core": "6.3.26", + "babel-loader": "6.2.0", + "babel-preset-es2015": "6.3.13", + "babel-preset-react": "6.3.13", + "coveralls": "2.11.6", + "eslint": "1.10.3", + "eslint-config-airbnb": "2.1.1", + "eslint-plugin-react": "3.13.0", "istanbul": "0.4.1", - "mocha": "2.3.3", - "radium": "0.14.3", - "react-dom": "0.14.0", - "webpack": "1.12.2" + "mocha": "2.3.4", + "radium": "0.15.3", + "react-dom": "0.14.3", + "webpack": "1.12.9" }, "dependencies": { "lodash": "3.10.1", - "react": "0.14.0", - "react-addons-test-utils": "0.14.0", + "react": "0.14.3", + "react-addons-test-utils": "0.14.3", "sinon": "1.17.2", "stampit": "2.1.1" } diff --git a/src/index.js b/src/index.js index adc28fe..5103dc1 100644 --- a/src/index.js +++ b/src/index.js @@ -19,12 +19,12 @@ const doNotSpyOn = { // METHODS -const propFunc = function(propToTest) { +const propFunc = function (propToTest) { this.propToTest = propToTest; return this; }; -const mapsTo = function(method) { +const mapsTo = function (method) { const symbolToTest = Symbol(method); this.props[this.propToTest](symbolToTest); @@ -36,7 +36,7 @@ const flavourComponentMethods = { mapsTo, }; -const flavourComponentInit = function(opts) { +const flavourComponentInit = function (opts) { if (opts.instance.props) { this.style = opts.instance.props.style; @@ -56,12 +56,12 @@ const flavourComponent = stampit() /* eslint-disable no-use-before-define */ const reduceChildren = - function(parentComponent, reactClass, parentIndx, childMap, child, indx) { + function (parentComponent, reactClass, parentIndx, childMap, child, indx) { const childIsElement = TestUtils.isElement(child); const id = parseInt(parentIndx, 10) >= 0 ? parentIndx + '.' + indx : indx; if (childIsElement) { - childMap[id] = flavourComponent(_.assign({}, child, {parentComponent, reactClass})); + childMap[id] = flavourComponent(_.assign({}, child, { parentComponent, reactClass })); _.assign( childMap, @@ -82,7 +82,7 @@ const reduceChildren = }; /* eslint-enable no-use-before-define */ -const convertAndReduce = function(parentComponent, reactClass, children, parentIndx) { +const convertAndReduce = function (parentComponent, reactClass, children, parentIndx) { return React .Children .toArray(children) @@ -92,7 +92,7 @@ const convertAndReduce = function(parentComponent, reactClass, children, parentI ); }; -const reduceTypes = function(childMap, typeMap, key) { +const reduceTypes = function (childMap, typeMap, key) { const components = (typeMap.get(childMap[key].type) || []).slice(0); components.push(childMap[key]); @@ -101,12 +101,12 @@ const reduceTypes = function(childMap, typeMap, key) { return typeMap; }; -const flavourInit = function(opts) { +const flavourInit = function (opts) { const output = opts.instance.shallowRenderer.getRenderOutput(); this.initialState = _.assign({}, opts.instance.shallowRenderer._instance._instance.state); this.state = _.assign({}, this.initialState); - this.component = flavourComponent(_.assign({}, output, {reactClass: opts.instance.reactClass})); + this.component = flavourComponent(_.assign({}, output, { reactClass: opts.instance.reactClass })); if (output) { if (!output.props) { @@ -132,23 +132,23 @@ const flavourInit = function(opts) { // console.log('typeMap', this.typeMap); }; -const resetState = function() { +const resetState = function () { this.shallowRenderer._instance._instance.state = _.assign({}, this.initialState); }; -const getState = function() { +const getState = function () { return this.shallowRenderer._instance._instance.state; }; -const findChild = function(path) { +const findChild = function (path) { return this.childMap[path]; }; -const findComponents = function(component) { +const findComponents = function (component) { return this.typeMap.get(component) || []; }; -const countComponents = function(component) { +const countComponents = function (component) { return this.findComponents(component).length; }; @@ -167,7 +167,7 @@ const flavour = stampit() // TESTER // INIT -const testerInit = function(opts) { +const testerInit = function (opts) { this.ComponentToUse = null; this.config = { @@ -177,14 +177,14 @@ const testerInit = function(opts) { }; // METHODS -const restoreSpy = function(method) { +const restoreSpy = function (method) { if (method.isSinonProxy) { method.restore(); } }; -const use = function(Component) { - const options = _.merge({}, defaultConfig, this.config, {spyOn: doNotSpyOn}); +const use = function (Component) { + const options = _.merge({}, defaultConfig, this.config, { spyOn: doNotSpyOn }); Object.getOwnPropertyNames(Component.prototype).forEach(method => { if (options.spyOn[method] === false) return; @@ -200,7 +200,7 @@ const use = function(Component) { return this; }; -const createFlavour = function(name, reactClass, shallowRenderer) { +const createFlavour = function (name, reactClass, shallowRenderer) { return flavour({ name, reactClass, @@ -208,7 +208,7 @@ const createFlavour = function(name, reactClass, shallowRenderer) { }); }; -const getShallowRenderer = function(component, props) { +const getShallowRenderer = function (component, props) { const shallowRenderer = TestUtils.createRenderer(); shallowRenderer @@ -220,7 +220,7 @@ const getShallowRenderer = function(component, props) { return shallowRenderer; }; -const addFlavour = function(name, props) { +const addFlavour = function (name, props) { return createFlavour( name, this.ComponentToUse, @@ -228,7 +228,7 @@ const addFlavour = function(name, props) { ); }; -const teardown = function() { +const teardown = function () { const proto = this.ComponentToUse.prototype; Object.getOwnPropertyNames(proto).forEach(method => { diff --git a/tests/components/address-line/address-line.js b/tests/components/address-line/address-line.js index 7c5d840..5b4ca9c 100644 --- a/tests/components/address-line/address-line.js +++ b/tests/components/address-line/address-line.js @@ -2,7 +2,7 @@ import React from 'react'; import radium from 'radium'; import styles from './address-line-styles'; -export default radium(({text}) => ( +export default radium(({ text }) => (