diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-11-13 16:00:34 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-11-13 16:00:34 +0100 |
commit | f2265bb40755e31f983199204b6b24f88360f3ed (patch) | |
tree | 7821063f1eb70f6c0e8bdcbe1d95b3cb3709254c /server/sonar-web/tests | |
parent | 32f0628b5399d2c2060f8b5c26e9534820185cee (diff) | |
download | sonarqube-f2265bb40755e31f983199204b6b24f88360f3ed.tar.gz sonarqube-f2265bb40755e31f983199204b6b24f88360f3ed.zip |
SONAR-6331 fall back to UT or IT coverage
Diffstat (limited to 'server/sonar-web/tests')
-rw-r--r-- | server/sonar-web/tests/apps/overview/main/coverage-test.js | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/server/sonar-web/tests/apps/overview/main/coverage-test.js b/server/sonar-web/tests/apps/overview/main/coverage-test.js new file mode 100644 index 00000000000..3883c69a8e6 --- /dev/null +++ b/server/sonar-web/tests/apps/overview/main/coverage-test.js @@ -0,0 +1,66 @@ +import _ from 'underscore'; +import { expect } from 'chai'; +import React from 'react'; +import TestUtils from 'react-addons-test-utils'; + +import { GeneralCoverage } from '../../../../src/main/js/apps/overview/main/coverage'; + + +const COMPONENT = { key: 'component-key' }; + +const DATE = new Date(2015, 0, 1); + +const MEASURES = { + 'overall_coverage': 73.5, + 'coverage': 69.7, + 'it_coverage': 54.0, + 'tests': 137 +}; +const LEAK = { + 'new_overall_coverage': 72.5, + 'new_coverage': 68.7, + 'new_it_coverage': 53.0 +}; +const MEASURES_FOR_UT = _.omit(MEASURES, 'overall_coverage'); +const LEAK_FOR_UT = _.omit(LEAK, 'new_overall_coverage'); +const MEASURES_FOR_IT = _.omit(MEASURES_FOR_UT, 'coverage'); +const LEAK_FOR_IT = _.omit(LEAK_FOR_UT, 'new_coverage'); + + +describe('Overview :: GeneralCoverage', function () { + it('should display overall coverage', function () { + let component = <GeneralCoverage measures={MEASURES} leak={LEAK} component={COMPONENT} + leakPeriodDate={DATE}/>; + let output = TestUtils.renderIntoDocument(component); + + let coverageElement = TestUtils.findRenderedDOMComponentWithClass(output, 'js-overview-main-coverage'); + expect(coverageElement.textContent).to.equal('73.5%'); + + let newCoverageElement = TestUtils.findRenderedDOMComponentWithClass(output, 'js-overview-main-new-coverage'); + expect(newCoverageElement.textContent).to.equal('72.5%'); + }); + + it('should fall back to UT coverage', function () { + let component = <GeneralCoverage measures={MEASURES_FOR_UT} leak={LEAK_FOR_UT} component={COMPONENT} + leakPeriodDate={DATE}/>; + let output = TestUtils.renderIntoDocument(component); + + let coverageElement = TestUtils.findRenderedDOMComponentWithClass(output, 'js-overview-main-coverage'); + expect(coverageElement.textContent).to.equal('69.7%'); + + let newCoverageElement = TestUtils.findRenderedDOMComponentWithClass(output, 'js-overview-main-new-coverage'); + expect(newCoverageElement.textContent).to.equal('68.7%'); + }); + + it('should fall back to IT coverage', function () { + let component = <GeneralCoverage measures={MEASURES_FOR_IT} leak={LEAK_FOR_IT} component={COMPONENT} + leakPeriodDate={DATE}/>; + let output = TestUtils.renderIntoDocument(component); + + let coverageElement = TestUtils.findRenderedDOMComponentWithClass(output, 'js-overview-main-coverage'); + expect(coverageElement.textContent).to.equal('54.0%'); + + let newCoverageElement = TestUtils.findRenderedDOMComponentWithClass(output, 'js-overview-main-new-coverage'); + expect(newCoverageElement.textContent).to.equal('53.0%'); + }); +}); |