Skip to content

Commit

Permalink
Refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kouak committed Jan 7, 2017
1 parent df7b90e commit da8133c
Showing 1 changed file with 30 additions and 13 deletions.
43 changes: 30 additions & 13 deletions test/test.FormsyText.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ class TestForm extends Component {
}

render() {
const { value, defaultValue, ...extraProps } = { ...this.props, ...this.state };
const { value, defaultValue, children, ...extraProps } = { ...this.props, ...this.state };
return (
<Form { ...extraProps }>
<FormsyText ref="text" name="text"
value={value}
defaultValue={defaultValue}
/>
{this.props.children ? this.props.children : (
<FormsyText ref="text" name="text"
value={value}
defaultValue={defaultValue}
/>
)}
</Form>
);
}
Expand Down Expand Up @@ -148,17 +150,32 @@ describe('FormsyText', () => {
expect(formValues.text).to.eq('some text');
});

it('disabled', () => {
const { formsyTextWrapper, formWrapper } = makeTestParent({
disabled: true,
});

const formsyForm = formWrapper.find(Form).node;
expect(formsyForm.isFormDisabled()).to.eq(true);
it('propagates disabled status', () => {
const wrapper = mount(
<TestForm disabled={true} >
<FormsyText
name="text"
/>
</TestForm>
);

const inputDOM = formsyTextWrapper.find('input').node;
const inputDOM = wrapper.find('input').node;
expect(inputDOM.disabled).to.eq(true);
});

it('allows overriding disabled status locally', () => {
const wrapper = mount(
<TestForm disabled={true}>
<FormsyText
name="text"
disabled={false}
/>
</TestForm>
);

const inputDOM = wrapper.find('input').node;
expect(inputDOM.disabled).to.eq(false);
});
});

describe('updating', () => {
Expand Down

0 comments on commit da8133c

Please sign in to comment.