76089888052f9fccb5080272512c5908edc31835
[tech-radar.git] / test / graphing / radar-spec.js
1 describe('tr.graphing.Radar', function () {
2 function buildSvg() {
3 return d3.select("body").append("svg");
4 }
5
6 it('sets the size', function () {
7 var svg = buildSvg();
8 spyOn(svg, 'attr').andReturn(svg);
9
10 var radarGraph = new tr.graphing.Radar(svg, 500);
11
12 expect(svg.attr).toHaveBeenCalledWith('width', 500);
13 expect(svg.attr).toHaveBeenCalledWith('height', 500);
14 });
15
16 describe('lines', function () {
17 it('plots a vertical line in the center', function () {
18 var svg = buildSvg();
19 spyOn(svg, 'append').andReturn(svg);
20 spyOn(svg, 'attr').andReturn(svg);
21
22 var radarGraph = new tr.graphing.Radar(svg, 500);
23
24 radarGraph.plot();
25
26 expect(svg.append).toHaveBeenCalledWith('line');
27 expect(svg.attr).toHaveBeenCalledWith('x1', 500 / 2);
28 expect(svg.attr).toHaveBeenCalledWith('y1', 0);
29 expect(svg.attr).toHaveBeenCalledWith('x2', 500 / 2);
30 expect(svg.attr).toHaveBeenCalledWith('y2', 500);
31 expect(svg.attr).toHaveBeenCalledWith('stroke-width', 5);
32 });
33
34 it('plots a horizontal line in the center', function () {
35 var svg = buildSvg();
36 spyOn(svg, 'append').andReturn(svg);
37 spyOn(svg, 'attr').andReturn(svg);
38
39 var radarGraph = new tr.graphing.Radar(svg, 500);
40
41 radarGraph.plot();
42
43 expect(svg.append).toHaveBeenCalledWith('line');
44 expect(svg.attr).toHaveBeenCalledWith('x1', 0);
45 expect(svg.attr).toHaveBeenCalledWith('y1', 500 / 2);
46 expect(svg.attr).toHaveBeenCalledWith('x2', 500);
47 expect(svg.attr).toHaveBeenCalledWith('y2', 500 / 2);
48 expect(svg.attr).toHaveBeenCalledWith('stroke-width', 5);
49 });
50 })
51 });