1 describe('tr.graphing.Radar', function () {
5 return d3
.select("body").append("svg");
8 beforeEach(function () {
9 radar
= new tr
.models
.Radar();
10 spyOn(radar
, 'cycles').andReturn([]);
13 it('sets the size', function () {
16 spyOn(svg
, 'attr').andReturn(svg
);
18 radarGraph
= new tr
.graphing
.Radar(svg
, 500, radar
);
20 expect(svg
.attr
).toHaveBeenCalledWith('width', 500);
21 expect(svg
.attr
).toHaveBeenCalledWith('height', 500);
24 describe('lines', function () {
25 it('plots a vertical line in the center', function () {
29 spyOn(svg
, 'append').andReturn(svg
);
30 spyOn(svg
, 'attr').andReturn(svg
);
32 radarGraph
= new tr
.graphing
.Radar(svg
, 500, radar
);
36 expect(svg
.append
).toHaveBeenCalledWith('line');
37 expect(svg
.attr
).toHaveBeenCalledWith('x1', 500 / 2);
38 expect(svg
.attr
).toHaveBeenCalledWith('y1', 0);
39 expect(svg
.attr
).toHaveBeenCalledWith('x2', 500 / 2);
40 expect(svg
.attr
).toHaveBeenCalledWith('y2', 500);
41 expect(svg
.attr
).toHaveBeenCalledWith('stroke-width', 5);
44 it('plots a horizontal line in the center', function () {
48 spyOn(svg
, 'append').andReturn(svg
);
49 spyOn(svg
, 'attr').andReturn(svg
);
51 radarGraph
= new tr
.graphing
.Radar(svg
, 500, radar
);
55 expect(svg
.append
).toHaveBeenCalledWith('line');
56 expect(svg
.attr
).toHaveBeenCalledWith('x1', 0);
57 expect(svg
.attr
).toHaveBeenCalledWith('y1', 500 / 2);
58 expect(svg
.attr
).toHaveBeenCalledWith('x2', 500);
59 expect(svg
.attr
).toHaveBeenCalledWith('y2', 500 / 2);
60 expect(svg
.attr
).toHaveBeenCalledWith('stroke-width', 5);
64 describe('circles', function () {
67 beforeEach(function () {
71 spyOn(svg
, 'append').andReturn(svg
);
72 spyOn(svg
, 'attr').andReturn(svg
);
74 radar
= new tr
.models
.Radar();
75 spyOn(radar
, 'cycles').andReturn([
76 new tr
.models
.Cycle('Adopt'),
77 new tr
.models
.Cycle('Hold')
79 radarGraph
= new tr
.graphing
.Radar(svg
, 500, radar
);
82 it('plots the circles for the cicles', function () {
85 expect(svg
.append
).toHaveBeenCalledWith('circle');
86 expect(svg
.attr
).toHaveBeenCalledWith('cx', 500 / 2);
87 expect(svg
.attr
).toHaveBeenCalledWith('cy', 500 / 2);
88 expect(svg
.attr
).toHaveBeenCalledWith('r', Math
.round(250 / 2));
90 expect(svg
.append
).toHaveBeenCalledWith('circle');
91 expect(svg
.attr
).toHaveBeenCalledWith('cx', 500 / 2);
92 expect(svg
.attr
).toHaveBeenCalledWith('cy', 500 / 2);
93 expect(svg
.attr
).toHaveBeenCalledWith('r', 250);