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

Commit f4ce0aa

Browse files
committed
Add support for custom props on <Errors> component + unit tests
1 parent 5e7a8bb commit f4ce0aa

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

test/errors-component-spec.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ describe('<Errors />', () => {
281281
});
282282

283283
describe('the "wrapper" prop', () => {
284-
function renderErrorsWithWrapper(wrapper) {
284+
function renderErrorsWithWrapper(wrapper, props) {
285285
const store = applyMiddleware(thunk)(createStore)(combineReducers({
286286
testForm: formReducer('test', {}),
287287
test: modelReducer('test'),
@@ -296,6 +296,7 @@ describe('<Errors />', () => {
296296
foo: 'foo error',
297297
bar: 'bar error',
298298
}}
299+
{...props}
299300
/>
300301
<Field model="test.foo"
301302
validators={{
@@ -368,6 +369,24 @@ describe('<Errors />', () => {
368369

369370
assert.equal(wrapper[0].childNodes.length, 2);
370371
});
372+
373+
it('should render a specified React component with non-proprietary props', () => {
374+
function Wrapper(props) {
375+
assert.property(props, 'className');
376+
377+
return <div {...props}>{props.children}</div>;
378+
}
379+
380+
const props = { className: 'custom-class' };
381+
382+
const form = renderErrorsWithWrapper(Wrapper, props);
383+
384+
const wrapper = TestUtils.scryRenderedDOMComponentsWithClass(form, 'custom-class');
385+
386+
assert.lengthOf(wrapper, 1);
387+
388+
assert.equal(wrapper[0].childNodes.length, 2);
389+
});
371390
});
372391

373392
describe('the "component" prop', () => {

0 commit comments

Comments
 (0)