</DomainLeak>;
},
+ renderTests() {
+ let tests = this.props.measures['tests'];
+ if (tests == null) {
+ return null;
+ }
+ return <Measure label={getMetricName('tests')}>
+ <DrilldownLink component={this.props.component.key} metric="tests">
+ <span className="js-overview-main-tests">{formatMeasure(tests, 'SHORT_INT')}</span>
+ </DrilldownLink>
+ </Measure>;
+ },
+
render () {
let coverageMetric = this.getCoverageMetric();
if (this.props.measures[coverageMetric] == null) {
</span>
</DrilldownLink>
</Measure>
- <Measure label={getMetricName('tests')}>
- <DrilldownLink component={this.props.component.key} metric="tests">
- <span className="js-overview-main-tests">
- {formatMeasure(this.props.measures['tests'], 'SHORT_INT')}
- </span>
- </DrilldownLink>
- </Measure>
+ {this.renderTests()}
</MeasuresList>
{this.renderTimeline('before')}
</DomainNutshell>
expect(newCoverageElement.textContent).to.equal('72.5%');
});
+ it('should display tests', function () {
+ let component = <GeneralCoverage measures={MEASURES} component={COMPONENT}/>;
+ let output = TestUtils.renderIntoDocument(component);
+ let coverageElement = TestUtils.findRenderedDOMComponentWithClass(output, 'js-overview-main-tests');
+ expect(coverageElement.textContent).to.equal('137');
+ });
+
+ it('should not display tests', function () {
+ let measuresWithoutTests = _.omit(MEASURES, 'tests');
+ let component = <GeneralCoverage measures={measuresWithoutTests} component={COMPONENT}/>;
+ let output = TestUtils.renderIntoDocument(component);
+ let coverageElements = TestUtils.scryRenderedDOMComponentsWithClass(output, 'js-overview-main-tests');
+ expect(coverageElements).to.be.empty;
+ });
+
it('should fall back to UT coverage', function () {
let component = <GeneralCoverage measures={MEASURES_FOR_UT} leak={LEAK_FOR_UT} component={COMPONENT}
leakPeriodDate={DATE}/>;