diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-12-16 15:23:40 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-12-16 15:23:40 +0100 |
commit | f7c1c7a08a7fecdfb339493830ecd122bfd481ab (patch) | |
tree | 19c67712ed1d17822bf8bb6d58e36e117c204599 /server/sonar-web/tests | |
parent | 5af187a6a0bda4f14de5d8ba5c6088c3a00d3e4e (diff) | |
download | sonarqube-f7c1c7a08a7fecdfb339493830ecd122bfd481ab.tar.gz sonarqube-f7c1c7a08a7fecdfb339493830ecd122bfd481ab.zip |
SONAR-7143 display different types of coverage
Diffstat (limited to 'server/sonar-web/tests')
-rw-r--r-- | server/sonar-web/tests/apps/code/components-test.js | 1 | ||||
-rw-r--r-- | server/sonar-web/tests/apps/code/store-test.js | 70 |
2 files changed, 70 insertions, 1 deletions
diff --git a/server/sonar-web/tests/apps/code/components-test.js b/server/sonar-web/tests/apps/code/components-test.js index 92ed3427f75..2469bf26870 100644 --- a/server/sonar-web/tests/apps/code/components-test.js +++ b/server/sonar-web/tests/apps/code/components-test.js @@ -93,6 +93,7 @@ describe('Code :: Components', () => { output = shallow( <Component component={exampleComponent} + coverageMetric="coverage" onBrowse={exampleOnBrowse}/>); }); diff --git a/server/sonar-web/tests/apps/code/store-test.js b/server/sonar-web/tests/apps/code/store-test.js index 039e199a19b..cf8532fe755 100644 --- a/server/sonar-web/tests/apps/code/store-test.js +++ b/server/sonar-web/tests/apps/code/store-test.js @@ -5,7 +5,8 @@ import { baseComponent, components, breadcrumbs, - sourceViewer + sourceViewer, + coverageMetric } from '../../../src/main/js/apps/code/reducers'; import { requestComponents, @@ -93,6 +94,73 @@ describe('Code :: Store', () => { expect(sourceViewer(exampleComponent, requestComponents({}))) .to.equal(null); }); + + describe('coverageMetric', () => { + it('should be initially null', () => { + expect(coverageMetric(undefined, {})) + .to.equal(null); + }); + + it('should be set to "coverage"', () => { + const componentWithCoverage = { + ...exampleComponent, + msr: [ + { key: 'coverage', val: 13 } + ] + }; + + expect(coverageMetric(null, requestComponents(componentWithCoverage))) + .to.equal('coverage'); + }); + + it('should be set to "it_coverage"', () => { + const componentWithCoverage = { + ...exampleComponent, + msr: [ + { key: 'it_coverage', val: 13 } + ] + }; + + expect(coverageMetric(null, requestComponents(componentWithCoverage))) + .to.equal('it_coverage'); + }); + + it('should be set to "overall_coverage"', () => { + const componentWithCoverage = { + ...exampleComponent, + msr: [ + { key: 'coverage', val: 11 }, + { key: 'it_coverage', val: 12 }, + { key: 'overall_coverage', val: 13 } + ] + }; + + expect(coverageMetric(null, requestComponents(componentWithCoverage))) + .to.equal('overall_coverage'); + }); + + it('should fallback to "it_coverage"', () => { + const componentWithCoverage = { + ...exampleComponent, + msr: [] + }; + + expect(coverageMetric(null, requestComponents(componentWithCoverage))) + .to.equal('it_coverage'); + }); + + it('should not be reset after set once', () => { + const componentWithCoverage = { + ...exampleComponent, + msr: [ + { key: 'coverage', val: 13 } + ] + }; + + expect(coverageMetric('overall_coverage', requestComponents(componentWithCoverage))) + .to.equal('overall_coverage'); + }); + }); }); }); }); |