Add test to ensure 'undefined' children is used (#6853)
Ben Alpert committed
May 23, 2016 at 17:22 UTC
fe2002c3d855904c8f272c402f7a321d5bac5c37
2 files changed
+24
src/isomorphic/classic/element/__tests__/ReactElement-test.js
+12
@@ -223,6 +223,18 @@ describe('ReactElement', function() {
223
expect(console.error.argsForCall.length).toBe(0);
224
});
225
226
+ it('overrides children if undefined is provided as an argument', function() {
227
+ var element = React.createElement(ComponentClass, {
228
+ children: 'text',
229
+ }, undefined);
230
+ expect(element.props.children).toBe(undefined);
231
+
232
+ var element2 = React.cloneElement(React.createElement(ComponentClass, {
233
+ children: 'text',
234
+ }), {}, undefined);
235
+ expect(element2.props.children).toBe(undefined);
236
+ });
237
+
238
it('merges rest arguments onto the children prop in an array', function() {
239
spyOn(console, 'error');
240
var a = 1;
src/isomorphic/modern/element/__tests__/ReactJSXElement-test.js
+12
@@ -117,6 +117,18 @@ describe('ReactJSXElement', function() {
117
expect(console.error.argsForCall.length).toBe(0);
118
});
119
120
+ it('overrides children if undefined is provided as an argument', function() {
121
+ var element = <Component children="text">{undefined}</Component>;
122
+ expect(element.props.children).toBe(undefined);
123
+
124
+ var element2 = React.cloneElement(
125
+ <Component children="text" />,
126
+ {},
127
+ undefined
128
+ );
129
+ expect(element2.props.children).toBe(undefined);
130
+ });
131
+
132
it('merges JSX children onto the children prop in an array', function() {
133
spyOn(console, 'error');
134
var a = 1;