Skip to content

Instantly share code, notes, and snippets.

@nkt
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nkt/cea98d8d7ac143855e79 to your computer and use it in GitHub Desktop.
Save nkt/cea98d8d7ac143855e79 to your computer and use it in GitHub Desktop.
jest.dontMock('../LocaleInput');
describe('LocaleInput', () => {
it('should render all locales without locales prop', () => {
const React = require('react/addons');
const LocaleInput = require('../LocaleInput');
const input = TestUtils.renderIntoDocument(<LocaleInput />);
const select = TestUtils.findRenderedDOMComponentWithTag(input, 'select');
});
});
const Input = React.createClass({
render() {
if (this.props.type === 'select') {
return (
<select {...this.props}>{this.props.children}</select>;
);
}
}
})
const locales = {
ru: 'Русский',
en: 'English'
};
const LocaleInput = React.createClass({
renderOptions() {
return this.props.locales.map((locale) => {
return (
<option value={locale} key={locale}>
{locales[locale]}
</option>
);
});
},
render() {
return (
<Input type="select">
{this.renderOptions()}
</Input>
);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment