Skip to content

Instantly share code, notes, and snippets.

@nackjicholson
Created January 14, 2016 19:12
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 nackjicholson/a5e06579930cc1be03c8 to your computer and use it in GitHub Desktop.
Save nackjicholson/a5e06579930cc1be03c8 to your computer and use it in GitHub Desktop.
// ...
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