Skip to content

Instantly share code, notes, and snippets.

@sqrtofsaturn
Last active June 9, 2016 21:07
Show Gist options
  • Save sqrtofsaturn/8d2e64998877ef5a362f1e8f60bc31df to your computer and use it in GitHub Desktop.
Save sqrtofsaturn/8d2e64998877ef5a362f1e8f60bc31df to your computer and use it in GitHub Desktop.
React Component Sub Generator templates
import _ from 'lodash';
import chai, { expect } from 'chai';
import chaiEnzyme from 'chai-enzyme';
import React from 'react';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import { mount, shallow } from 'enzyme';
import ComponentName from './';
chai.use(chaiEnzyme());
chai.use(sinonChai);
describe('<ComponentName />', () => {
it('should render nothing', () => {
const sut = shallow(<ComponentName />)
expect(sut).to.be.empty
});
});
/ComponentName
- index.js
- index.spec.js
- styles.css
import React, { PropTypes } from 'react'
const propTypes = {}
const defaultProps = {}
class StatefulComponent extends React.Component {
constructor(props) {
super(props)
this.state = {}
}
render() {
return <div>StatefulComponent</div>
}
}
StatefulComponent.propTypes = propTypes
StatefulComponent.defaultProps = defaultProps
export default StatefulComponent
import React, { PropTypes } from 'react'
const propTypes = {}
const defaultProps = {}
const StatelessComponent = () => {
return <div>StatelessComponent</div>
}
StatelessComponent.propTypes = propTypes
StatelessComponent.defaultProps = defaultProps
export default StatelessComponent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment