@samitouri / QOS-React / commits / f0a0999c3b

Add test for key warning at top level (#9473)

Ben Alpert committed May 21, 2017 at 15:39 UTC f0a0999c3b32e4c4374fba3b8c9fd394336470e3
2 files changed +14
scripts/fiber/tests-passing.txt
+1
@@ -82,6 +82,7 @@ src/isomorphic/children/__tests__/ReactChildren-test.js
82 * should throw on regex
83 * warns for keys for arrays of elements in a fragment
84 * does not warn when there are keys on elements in a fragment
85 +* warns for keys for arrays at the top level
86
87 src/isomorphic/children/__tests__/onlyChild-test.js
88 * should fail when passed two children
src/isomorphic/children/__tests__/ReactChildren-test.js
+13
@@ -900,6 +900,19 @@ describe('ReactChildren', () => {
900
901 expectDev(console.error.calls.count()).toBe(0);
902 });
903 +
904 + it('warns for keys for arrays at the top level', () => {
905 + spyOn(console, 'error');
906 +
907 + ReactTestUtils.renderIntoDocument([<div />, <div />]);
908 +
909 + expectDev(console.error.calls.count()).toBe(1);
910 + expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
911 + 'Warning: ' +
912 + 'Each child in an array or iterator should have a unique "key" prop.' +
913 + ' See https://fb.me/react-warning-keys for more information.',
914 + );
915 + });
916 });
917 }
918 });