summaryrefslogtreecommitdiffstats
path: root/server/sonar-web/tests/apps/overview/components/complexity-distribution-test.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/tests/apps/overview/components/complexity-distribution-test.js')
-rw-r--r--server/sonar-web/tests/apps/overview/components/complexity-distribution-test.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/server/sonar-web/tests/apps/overview/components/complexity-distribution-test.js b/server/sonar-web/tests/apps/overview/components/complexity-distribution-test.js
new file mode 100644
index 00000000000..a79cdbf34bc
--- /dev/null
+++ b/server/sonar-web/tests/apps/overview/components/complexity-distribution-test.js
@@ -0,0 +1,41 @@
+import { expect } from 'chai';
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+
+import { ComplexityDistribution } from '../../../../src/main/js/apps/overview/components/complexity-distribution';
+
+
+const DISTRIBUTION = '1=11950;2=86;4=77;6=43;8=17;10=12;12=3';
+
+
+describe('ComplexityDistribution', function () {
+ let props;
+
+ beforeEach(function () {
+ let renderer = TestUtils.createRenderer();
+ renderer.render(<ComplexityDistribution distribution={DISTRIBUTION}/>);
+ let output = renderer.getRenderOutput();
+ let child = React.Children.only(output.props.children);
+ props = child.props;
+ });
+
+ it('should pass right data', function () {
+ expect(props.data).to.deep.equal([
+ { x: 0, y: 11950, value: 1 },
+ { x: 1, y: 86, value: 2 },
+ { x: 2, y: 77, value: 4 },
+ { x: 3, y: 43, value: 6 },
+ { x: 4, y: 17, value: 8 },
+ { x: 5, y: 12, value: 10 },
+ { x: 6, y: 3, value: 12 }
+ ]);
+ });
+
+ it('should pass right xTicks', function () {
+ expect(props.xTicks).to.deep.equal([1, 2, 4, 6, 8, 10, 12]);
+ });
+
+ it('should pass right xValues', function () {
+ expect(props.xValues).to.deep.equal(['11,950', '86', '77', '43', '17', '12', '3']);
+ });
+});