Created
January 14, 2016 19:10
-
-
Save nackjicholson/dc6d67929a7c7130423a to your computer and use it in GitHub Desktop.
This file contains 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
it('should check a default input by using the defaultValue prop', () => { | |
const props = { | |
defaultValue: 'bravo.value', | |
inputs: [ | |
{ value: 'alpha.value', label: 'alpha.label' }, | |
{ value: 'bravo.value', label: 'bravo.label' }, | |
{ value: 'charlie.value', label: 'charlie.label' } | |
] | |
}; | |
const component = createComponent(props); | |
const $component = $(component).render(); | |
const $inputs = $component.find('input'); | |
// Turning $inputs into an array of elements and then using `Array.prototype.filter` | |
// and `Array.prototype.map` to figure out which one on the DOM is "checked". | |
const actual = $inputs | |
.get() | |
.filter(inputNode => inputNode.checked) | |
.map(inputNode => inputNode.value); | |
const expected = ['bravo.value']; | |
// Then we assert that the "checked" input, is the bravo input, which is the | |
// the one indicated by the defaultValue prop. | |
assert.deepEqual( | |
actual, | |
expected, | |
'checked the input with the value equal to defaultValue prop' | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment