Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit d88dcc9

Browse files
committed
Adding control component spec tests (WIP)
1 parent e4c7e64 commit d88dcc9

File tree

3 files changed

+40
-40
lines changed

3 files changed

+40
-40
lines changed

src/components/control-component.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,16 @@ class Control extends Component {
9696
}
9797

9898
render() {
99-
const { controlProps, component } = this.props;
99+
const { controlProps = {}, component } = this.props;
100100

101101
return createElement(
102102
component,
103103
{
104104
...controlProps,
105105
...this.props,
106106
onKeyPress: this.handleKeyPress,
107-
});
107+
},
108+
controlProps.children);
108109
}
109110
}
110111

src/utils/sequence.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function sequenceEventActions(props) {
6464
dispatch,
6565
model,
6666
updateOn = 'change',
67-
parser,
67+
parser = identity,
6868
changeAction = identity,
6969
controlProps = {},
7070
} = props;

test/control-component-spec.js

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
1-
// /* eslint react/no-multi-comp:0 react/jsx-no-bind:0 */
2-
// import { assert } from 'chai';
3-
// import React, { Component, PropTypes } from 'react';
4-
// import TestUtils from 'react-addons-test-utils';
5-
// import { applyMiddleware, combineReducers, createStore } from 'redux';
6-
// import { Provider } from 'react-redux';
7-
// import thunk from 'redux-thunk';
8-
9-
// import { controls, createFieldClass, formReducer, modelReducer, Control } from '../src';
10-
11-
// function createTestStore(reducers) {
12-
// return applyMiddleware(thunk)(createStore)(combineReducers(reducers));
13-
// }
14-
15-
// describe('<Control> component', () => {
16-
// it('should exist as a function', () => {
17-
// assert.ok(Control);
18-
// });
19-
20-
// it.only('should work as expected with a model (happy path)', () => {
21-
// const store = createTestStore({
22-
// test: modelReducer('test', { foo: 'bar' }),
23-
// testForm: formReducer('test', { foo: 'bar' }),
24-
// });
25-
26-
// const form = TestUtils.renderIntoDocument(
27-
// <Provider store={store}>
28-
// <Control model="test.foo" mapProps={controls.text} component={React.DOM.input} />
29-
// </Provider>
30-
// );
31-
32-
// const input = TestUtils.findRenderedDOMComponentWithTag(form, 'input');
33-
34-
// console.log(input);
35-
36-
// })
37-
// });
1+
/* eslint react/no-multi-comp:0 react/jsx-no-bind:0 */
2+
import { assert } from 'chai';
3+
import React from 'react';
4+
import TestUtils from 'react-addons-test-utils';
5+
import { applyMiddleware, combineReducers, createStore } from 'redux';
6+
import { Provider } from 'react-redux';
7+
import thunk from 'redux-thunk';
8+
9+
import { controls, formReducer, modelReducer, Control } from '../src';
10+
11+
function createTestStore(reducers) {
12+
return applyMiddleware(thunk)(createStore)(combineReducers(reducers));
13+
}
14+
15+
describe('<Control> component', () => {
16+
it('should exist', () => {
17+
assert.ok(Control);
18+
});
19+
20+
it('should work as expected with a model (happy path)', () => {
21+
const store = createTestStore({
22+
test: modelReducer('test', { foo: 'bar' }),
23+
testForm: formReducer('test', { foo: 'bar' }),
24+
});
25+
26+
const form = TestUtils.renderIntoDocument(
27+
<Provider store={store}>
28+
<Control model="test.foo" mapProps={controls.text} component="input" />
29+
</Provider>
30+
);
31+
32+
const input = TestUtils.findRenderedDOMComponentWithTag(form, 'input');
33+
34+
assert.ok(input);
35+
});
36+
});

0 commit comments

Comments
 (0)