Created
January 14, 2016 19:12
-
-
Save nackjicholson/a5e06579930cc1be03c8 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
// ... | |
import { spy } from 'sinon'; | |
// ... | |
it('should take an onSelection callback prop', () => { | |
// "Arrange" | |
const props = { | |
inputs: [{}], | |
onSelection: spy() | |
}; | |
const event = { target: { value: 'test.value' } }; | |
const component = createComponent(props); | |
// "Act" | |
$(component) | |
.render() | |
.find('input[name=test-baseId]') | |
.trigger('change', event); | |
// "Assert" | |
assert(props.onSelection.calledOnce, 'onSelection callback was called once'); | |
assert.equal( | |
props.onSelection.args[0].length, | |
1, | |
'onSelection callback called with 1 argument' | |
); | |
const actual = props.onSelection.args[0][0]; | |
const expected = 'test.value'; | |
assert.equal( | |
actual, | |
expected, | |
'onSelection callback called with value of the option which was the target of the change' | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment