Skip to content

Commit

Permalink
allow custom form layouts [#159317578]
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Berney <jberney@pivotal.io>
  • Loading branch information
reidmit authored and Jonathan Berney committed Jul 30, 2018
1 parent 07fed7d commit 6c621a2
Show file tree
Hide file tree
Showing 10 changed files with 1,421 additions and 976 deletions.
389 changes: 44 additions & 345 deletions spec/pivotal-ui-react/form/form-col_spec.js

Large diffs are not rendered by default.

64 changes: 0 additions & 64 deletions spec/pivotal-ui-react/form/form-row_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,42 +23,6 @@ describe('FormRow', () => {
expect('#root > .grid .col:eq(1)').toHaveText('test');
});

describe('when given form props', () => {
let formProps;

beforeEach(() => {
formProps = {
state: {key: 'value'},
setState: () => 'set state',
canSubmit: () => 'can submit',
onSubmit: () => 'on submit',
canReset: () => 'can reset',
reset: () => 'reset',
onChange: () => () => 'on change',
onBlur: () => 'on blur'
};

ReactDOM.render(<FormRow {...formProps}>
<FormCol id="col1">{field1}</FormCol>
<FormCol id="col2">{field2}</FormCol>
</FormRow>, root);
});

it('passes the props down to each child', () => {
expect(FormCol).toHaveBeenRenderedWithProps({
id: 'col1',
children: field1,
...formProps
});

expect(FormCol).toHaveBeenRenderedWithProps({
id: 'col2',
children: field2,
...formProps
});
});
});

describe('when given a wrapper', () => {
beforeEach(() => {
subject::setProps({wrapper: () => <div className="wrapper"/>});
Expand All @@ -72,34 +36,6 @@ describe('FormRow', () => {
});
});

describe('when given invalid children', () => {
beforeEach(() => {
spyOn(console, 'warn');
class FakeFormCol extends FormCol {
render() {
return <div className="fake-col">fake col</div>;
}
}

ReactDOM.render(<FormRow>
<div className="invalid-element">Invalid element</div>
<FakeFormCol />
</FormRow>, root);
});

it('renders the fake form col', () => {
expect('.fake-col').toExist();
});

it('does not render the invalid-element', () => {
expect('.invalid-element').not.toExist();
});

it('shows a warning', () => {
expect(console.warn).toHaveBeenCalledWith('Child of type "div" will not be rendered. A FormRow\'s children should be of type FormCol.');
});
});

describe('when given a class name and an ID', () => {
beforeEach(() => {
spyOnRender(Grid).and.callThrough();
Expand Down
Loading

0 comments on commit 6c621a2

Please sign in to comment.