@samitouri / QOS-React-2 / commits / c8a7988bf9

Add a failing test case for #6742

getOperations() blows up when replacing null with a native because the null component has debugID of 0 that isn’t registered in the component tree.

Dan Abramov committed May 11, 2016 at 23:27 UTC c8a7988bf9e59df6db89192f87c22a550fc10d49
1 file changed +33
src/isomorphic/__tests__/ReactPerf-test.js
+33
@@ -67,6 +67,13 @@ describe('ReactPerf', function() {
67 ReactPerf.start();
68 fn();
69 ReactPerf.stop();
70 +
71 + // Make sure none of the methods crash.
72 + ReactPerf.getWasted();
73 + ReactPerf.getInclusive();
74 + ReactPerf.getExclusive();
75 + ReactPerf.getOperations();
76 +
77 return ReactPerf.getLastMeasurements();
78 }
79
@@ -208,6 +215,32 @@ describe('ReactPerf', function() {
215 });
216 });
217
218 + it('should not count replacing null with a native as waste', function() {
219 + var element = null;
220 + function Foo () {
221 + return element;
222 + }
223 + var container = document.createElement('div');
224 + ReactDOM.render(<Foo />, container);
225 + expectNoWaste(() => {
226 + element = <div />;
227 + ReactDOM.render(<Foo />, container);
228 + });
229 + });
230 +
231 + it('should not count replacing a native with null as waste', function() {
232 + var element = <div />;
233 + function Foo () {
234 + return element;
235 + }
236 + var container = document.createElement('div');
237 + ReactDOM.render(<Foo />, container);
238 + expectNoWaste(() => {
239 + element = null;
240 + ReactDOM.render(<Foo />, container);
241 + });
242 + });
243 +
244 it('warns once when using getMeasurementsSummaryMap', function() {
245 var measurements = measure(() => {});
246 spyOn(console, 'error');