Last active
August 29, 2015 14:27
-
-
Save nkt/cea98d8d7ac143855e79 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Input = React.createClass({ | |
render() { | |
if (this.props.type === 'select') { | |
return ( | |
<select {...this.props}>{this.props.children}</select>; | |
); | |
} | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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