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 }) => (
{text}
diff --git a/tests/components/address/address.js b/tests/components/address/address.js index c1c37f4..35d64ae 100644 --- a/tests/components/address/address.js +++ b/tests/components/address/address.js @@ -1,7 +1,7 @@ import React from 'react'; import AddressLine from '../address-line/address-line'; -export default ({address = [], addressee = ''}) => ( +export default ({ address = [], addressee = '' }) => (
{ diff --git a/tests/components/app/app.js b/tests/components/app/app.js index 8d6191f..a0b9a3b 100644 --- a/tests/components/app/app.js +++ b/tests/components/app/app.js @@ -20,7 +20,7 @@ export default radium(({ signature={signature} addressee={addressee} address={address} - /> + />
diff --git a/tests/components/message/message.js b/tests/components/message/message.js index f424c18..ff741c2 100644 --- a/tests/components/message/message.js +++ b/tests/components/message/message.js @@ -2,7 +2,7 @@ import React from 'react'; import radium from 'radium'; import styles from './message-styles'; -export default radium(({text}) => ( +export default radium(({ text }) => (
{text}
diff --git a/tests/components/postcard/postcard.js b/tests/components/postcard/postcard.js index 1963881..3bc8849 100644 --- a/tests/components/postcard/postcard.js +++ b/tests/components/postcard/postcard.js @@ -7,20 +7,20 @@ import Signature from '../signature/signature'; import Stamp from '../stamp/stamp-smart'; import Address from '../address/address'; -export default radium(({comingFrom, message, signature, address, addressee}) => ( +export default radium(({ comingFrom, message, signature, address, addressee }) => (
+ /> + />
+ />
@@ -31,7 +31,7 @@ export default radium(({comingFrom, message, signature, address, addressee}) =>
+ />
diff --git a/tests/components/signature/signature.js b/tests/components/signature/signature.js index 598ca08..cfe1373 100644 --- a/tests/components/signature/signature.js +++ b/tests/components/signature/signature.js @@ -2,7 +2,7 @@ import React from 'react'; import radium from 'radium'; import styles from './signature-styles'; -export default radium(({text}) => ( +export default radium(({ text }) => (
{text}
diff --git a/tests/components/stamp/stamp-dumb.js b/tests/components/stamp/stamp-dumb.js index f1b4266..0386106 100644 --- a/tests/components/stamp/stamp-dumb.js +++ b/tests/components/stamp/stamp-dumb.js @@ -3,27 +3,27 @@ import React from 'react'; import styles from './stamp-styles'; -export default ({types, type, onClick}) => ( +export default ({ types, type, onClick }) => (
{ (() => { switch (type) { - case types.NONE: - return ( -
Place stamp here
- ); - case types.FIRST_CLASS: - return ( -
1st
- ); - case types.SECOND_CLASS: - return ( -
2nd
+ case types.NONE: + return ( +
Place stamp here
+ ); + case types.FIRST_CLASS: + return ( +
1st
+ ); + case types.SECOND_CLASS: + return ( +
2nd
+ ); + default: + return ( +
Unknown stamp
); - default: - return ( -
Unknown stamp
- ); } })() } diff --git a/tests/components/stamp/stamp-smart.js b/tests/components/stamp/stamp-smart.js index 22ac49c..3118b42 100644 --- a/tests/components/stamp/stamp-smart.js +++ b/tests/components/stamp/stamp-smart.js @@ -17,17 +17,17 @@ export default class StampSmartComponent extends Component { let nextType; switch (currentType) { - case types.NONE: - nextType = types.FIRST_CLASS; - break; - case types.FIRST_CLASS: - nextType = types.SECOND_CLASS; - break; - case types.SECOND_CLASS: - nextType = types.NONE; - break; - default: - nextType = types.NONE; + case types.NONE: + nextType = types.FIRST_CLASS; + break; + case types.FIRST_CLASS: + nextType = types.SECOND_CLASS; + break; + case types.SECOND_CLASS: + nextType = types.NONE; + break; + default: + nextType = types.NONE; } return nextType; @@ -45,7 +45,7 @@ export default class StampSmartComponent extends Component { types={stampTypes} type={this.state.type} onClick={this.handleOnClick.bind(this)} - /> + /> ); } } diff --git a/tests/components/welcome/welcome.js b/tests/components/welcome/welcome.js index 8ff2259..32c85ec 100644 --- a/tests/components/welcome/welcome.js +++ b/tests/components/welcome/welcome.js @@ -2,7 +2,7 @@ import React from 'react'; import radium from 'radium'; import styles from './welcome-styles'; -export default radium(({text}) => ( +export default radium(({ text }) => (
{text}
diff --git a/tests/index.js b/tests/index.js index 7ffb70b..00c677d 100644 --- a/tests/index.js +++ b/tests/index.js @@ -19,10 +19,9 @@ const address = [ ]; ReactDOM.render(, document.getElementById('root')); - + comingFrom={comingFrom} + message={message} + signature={signature} + addressee={addressee} + address={address} +/>, document.getElementById('root')); diff --git a/tests/stand-alone/unordered-list/unordered-list.js b/tests/stand-alone/unordered-list/unordered-list.js index 7857bba..1e55793 100644 --- a/tests/stand-alone/unordered-list/unordered-list.js +++ b/tests/stand-alone/unordered-list/unordered-list.js @@ -43,10 +43,10 @@ export default class UnorderedListComponent extends Component {