1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
import { expect } from 'chai';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import { LanguageDistribution } from '../../../../src/main/js/apps/overview/components/language-distribution';
const DISTRIBUTION = '<null>=17345;java=194342;js=20984';
const LINES = 1000000;
describe('LanguageDistribution', function () {
let props;
beforeEach(function () {
let renderer = TestUtils.createRenderer();
renderer.render(<LanguageDistribution distribution={DISTRIBUTION} lines={LINES}/>);
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: 194342, y: 1, value: 'java' },
{ x: 20984, y: 2, value: 'js' },
{ x: 17345, y: 0, value: '<null>' }
]);
});
it('should pass right yTicks', function () {
expect(props.yTicks).to.deep.equal(['java', 'js', '<null>']);
});
it('should pass right yValues', function () {
expect(props.yValues).to.deep.equal(['19.4%', '2.1%', '1.7%']);
});
it('should correctly render very small values', function () {
const DISTRIBUTION_SMALL = 'java=194342;js=999';
let renderer = TestUtils.createRenderer();
renderer.render(<LanguageDistribution distribution={DISTRIBUTION_SMALL} lines={LINES}/>);
let output = renderer.getRenderOutput();
let child = React.Children.only(output.props.children);
expect(child.props.yValues).to.deep.equal(['19.4%', '<0.1%']);
});
});
|