test: add test for fragement props (#13565)
laoxiong committed
Sep 5, 2018 at 23:28 UTC
bb627228ea97514acb60901c390f420cdd26d21e
1 file changed
+15
packages/react/src/__tests__/ReactElementValidator-test.internal.js
+15
@@ -420,6 +420,21 @@ describe('ReactElementValidator', () => {
420
);
421
});
422
423
+ it('warns for fragments with illegal attributes', () => {
424
+ class Foo extends React.Component {
425
+ render() {
426
+ return React.createElement(React.Fragment, {a: 1}, '123');
427
+ }
428
+ }
429
+
430
+ expect(() => {
431
+ ReactTestUtils.renderIntoDocument(React.createElement(Foo));
432
+ }).toWarnDev(
433
+ 'Invalid prop `a` supplied to `React.Fragment`. React.Fragment ' +
434
+ 'can only have `key` and `children` props.',
435
+ );
436
+ });
437
+
438
it('should warn when accessing .type on an element factory', () => {
439
function TestComponent() {
440
return <div />;