f5747c66a5f589a88372571a74c2ae6e34b3a8c1
[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 });