Skip to content

Instantly share code, notes, and snippets.

@dtothefp
Created August 25, 2015 20:09
Show Gist options
  • Save dtothefp/8af801f826302631575c to your computer and use it in GitHub Desktop.
Save dtothefp/8af801f826302631575c to your computer and use it in GitHub Desktop.
let mockNuclearDec = mockNuclearComponent({formState, formValidation});
HigherOrderInput.__Rewire__('nuclearComponent', mockNuclearDec);
let HigherOrderComponent = HigherOrderInput(Input);
let hoc = TestUtils.renderIntoDocument(
<HigherOrderComponent {...mockProps} />
);
let hocElm = React.findDOMNode(hoc);
let inputObj = TestUtils.findRenderedDOMComponentWithClass(hoc, 'one');
let inputElm = inputObj.getDOMNode();
it('the higher order component should contain an input', () => {
let allInputs = hocElm.querySelectorAll('input');
expect(allInputs.length).to.eq(1);
});
it('should have an initial value from the store', () => {
expect(inputElm.value).to.eq('initial value');
});
it('should update it\'s value `onChange` ', () => {
//TODO: figure out how to re-render input
//currently must get props from React Object and value does not update on DOM node
inputElm.value = 'updated';
Simulate.change(inputElm);
expect(inputObj.props.value).to.eq('updated');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment