1 describe('tr.graphing.Radar', function () {
4 beforeEach(function () {
5 radar
= new tr
.models
.Radar();
6 spyOn(radar
, 'cycles').andReturn([]);
9 it('sets the size', function () {
12 radarGraph
= new tr
.graphing
.Radar(500, radar
);
14 spyOn(svg
, 'attr').andReturn(svg
);
18 expect(svg
.attr
).toHaveBeenCalledWith('width', 500);
19 expect(svg
.attr
).toHaveBeenCalledWith('height', 500);
22 describe('lines', function () {
23 it('plots a vertical line in the center', function () {
26 radarGraph
= new tr
.graphing
.Radar(500, radar
);
29 spyOn(svg
, 'append').andReturn(svg
);
30 spyOn(svg
, 'attr').andReturn(svg
);
34 expect(svg
.append
).toHaveBeenCalledWith('line');
35 expect(svg
.attr
).toHaveBeenCalledWith('x1', 500 / 2);
36 expect(svg
.attr
).toHaveBeenCalledWith('y1', 0);
37 expect(svg
.attr
).toHaveBeenCalledWith('x2', 500 / 2);
38 expect(svg
.attr
).toHaveBeenCalledWith('y2', 500);
39 expect(svg
.attr
).toHaveBeenCalledWith('stroke-width', 14);
42 it('plots a horizontal line in the center', function () {
45 radarGraph
= new tr
.graphing
.Radar(500, radar
);
47 spyOn(svg
, 'append').andReturn(svg
);
48 spyOn(svg
, 'attr').andReturn(svg
);
52 expect(svg
.append
).toHaveBeenCalledWith('line');
53 expect(svg
.attr
).toHaveBeenCalledWith('x1', 0);
54 expect(svg
.attr
).toHaveBeenCalledWith('y1', 500 / 2);
55 expect(svg
.attr
).toHaveBeenCalledWith('x2', 500);
56 expect(svg
.attr
).toHaveBeenCalledWith('y2', 500 / 2);
57 expect(svg
.attr
).toHaveBeenCalledWith('stroke-width', 14);
61 describe('circles', function () {
64 beforeEach(function () {
67 radar
= new tr
.models
.Radar();
68 spyOn(radar
, 'cycles').andReturn([
69 new tr
.models
.Cycle('Adopt'),
70 new tr
.models
.Cycle('Hold')
72 radarGraph
= new tr
.graphing
.Radar(500, radar
);
74 spyOn(svg
, 'append').andReturn(svg
);
75 spyOn(svg
, 'attr').andReturn(svg
);
78 it('plots the circles for the cycles', function () {
81 expect(svg
.append
).toHaveBeenCalledWith('circle');
82 expect(svg
.attr
).toHaveBeenCalledWith('cx', 500 / 2);
83 expect(svg
.attr
).toHaveBeenCalledWith('cy', 500 / 2);
84 expect(svg
.attr
).toHaveBeenCalledWith('r', Math
.round(250 / 2));
86 expect(svg
.append
).toHaveBeenCalledWith('circle');
87 expect(svg
.attr
).toHaveBeenCalledWith('cx', 500 / 2);
88 expect(svg
.attr
).toHaveBeenCalledWith('cy', 500 / 2);
89 expect(svg
.attr
).toHaveBeenCalledWith('r', 250);
92 it('adds the name of each cycle for the right side', function () {
94 spyOn(svg
, 'text').andReturn(svg
);
97 expect(svg
.append
).toHaveBeenCalledWith('text');
98 expect(svg
.attr
).toHaveBeenCalledWith('y', center
+ 4);
99 expect(svg
.attr
).toHaveBeenCalledWith('x', 0 + 10);
100 expect(svg
.text
).toHaveBeenCalledWith('Adopt');
102 expect(svg
.append
).toHaveBeenCalledWith('text');
103 expect(svg
.attr
).toHaveBeenCalledWith('y', center
+ 4);
104 expect(svg
.attr
).toHaveBeenCalledWith('x', 0 + (center
/ 2) + 10);
105 expect(svg
.text
).toHaveBeenCalledWith('Hold');
108 it('adds the name of each cycle for the right side', function () {
109 var center
= 500 / 2;
110 spyOn(svg
, 'text').andReturn(svg
);
113 expect(svg
.append
).toHaveBeenCalledWith('text');
114 expect(svg
.attr
).toHaveBeenCalledWith('y', center
+ 4);
115 expect(svg
.attr
).toHaveBeenCalledWith('x', 500 - 10);
116 expect(svg
.attr
).toHaveBeenCalledWith('text-anchor', 'end');
117 expect(svg
.text
).toHaveBeenCalledWith('Adopt');
119 expect(svg
.append
).toHaveBeenCalledWith('text');
120 expect(svg
.attr
).toHaveBeenCalledWith('y', center
+ 4);
121 expect(svg
.attr
).toHaveBeenCalledWith('x', 500 - (center
/ 2) - 10);
122 expect(svg
.attr
).toHaveBeenCalledWith('text-anchor', 'end');
123 expect(svg
.text
).toHaveBeenCalledWith('Hold');