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.
This commit is contained in:
Dan Abramov
2016-05-11 23:27:45 +01:00
parent b11540ccb2
commit c8a7988bf9
@@ -67,6 +67,13 @@ describe('ReactPerf', function() {
ReactPerf.start();
fn();
ReactPerf.stop();
// Make sure none of the methods crash.
ReactPerf.getWasted();
ReactPerf.getInclusive();
ReactPerf.getExclusive();
ReactPerf.getOperations();
return ReactPerf.getLastMeasurements();
}
@@ -208,6 +215,32 @@ describe('ReactPerf', function() {
});
});
it('should not count replacing null with a native as waste', function() {
var element = null;
function Foo () {
return element;
}
var container = document.createElement('div');
ReactDOM.render(<Foo />, container);
expectNoWaste(() => {
element = <div />;
ReactDOM.render(<Foo />, container);
});
});
it('should not count replacing a native with null as waste', function() {
var element = <div />;
function Foo () {
return element;
}
var container = document.createElement('div');
ReactDOM.render(<Foo />, container);
expectNoWaste(() => {
element = null;
ReactDOM.render(<Foo />, container);
});
});
it('warns once when using getMeasurementsSummaryMap', function() {
var measurements = measure(() => {});
spyOn(console, 'error');