added isProfiling() to ReactDebugTool and isRunning() to PerfTools

This commit is contained in:
Nuno Campos
2016-05-12 19:27:05 +01:00
parent 92bebcad5f
commit a027d15aff
4 changed files with 28 additions and 0 deletions
+3
View File
@@ -115,6 +115,9 @@ var ReactDebugTool = {
}
}
},
isProfiling() {
return isProfiling;
},
beginProfiling() {
if (__DEV__) {
if (isProfiling) {
+5
View File
@@ -351,6 +351,10 @@ function stop() {
ReactDebugTool.endProfiling();
}
function isRunning() {
return ReactDebugTool.isProfiling();
}
var ReactPerfAnalysis = {
getLastMeasurements: getFlushHistory,
getExclusive,
@@ -363,6 +367,7 @@ var ReactPerfAnalysis = {
printOperations,
start,
stop,
isRunning,
// Deprecated:
printDOM,
getMeasurementsSummaryMap,
@@ -72,4 +72,14 @@ describe('ReactDebugTool', function() {
ReactDebugTool.onTestEvent();
expect(console.error.calls.length).toBe(1);
});
it('returns isProfiling state', () => {
expect(ReactDebugTool.isProfiling()).toBe(false);
ReactDebugTool.beginProfiling();
expect(ReactDebugTool.isProfiling()).toBe(true);
ReactDebugTool.endProfiling();
expect(ReactDebugTool.isProfiling()).toBe(false);
});
});
@@ -16,6 +16,7 @@ describe('ReactPerf', function() {
var ReactDOM;
var ReactPerf;
var ReactTestUtils;
var ReactDebugTool;
var App;
var Box;
@@ -36,6 +37,7 @@ describe('ReactPerf', function() {
ReactDOM = require('ReactDOM');
ReactPerf = require('ReactPerf');
ReactTestUtils = require('ReactTestUtils');
ReactDebugTool = require('ReactDebugTool');
App = React.createClass({
render: function() {
@@ -283,4 +285,12 @@ describe('ReactPerf', function() {
ReactPerf.printDOM(measurements);
expect(console.error.calls.length).toBe(1);
});
it('returns isRunning state', () => {
spyOn(ReactDebugTool, 'isProfiling');
ReactPerf.isRunning();
expect(ReactDebugTool.isProfiling.calls.length).toBe(1);
expect(ReactPerf.isRunning()).toBe(ReactDebugTool.isProfiling());
});
});