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 () {
15 spyOn(svg
, 'attr').andReturn(svg
);
17 var radarGraph
= new tr
.graphing
.Radar(svg
, 500, radar
);
19 expect(svg
.attr
).toHaveBeenCalledWith('width', 500);
20 expect(svg
.attr
).toHaveBeenCalledWith('height', 500);
23 describe('lines', function () {
24 it('plots a vertical line in the center', function () {
26 spyOn(svg
, 'append').andReturn(svg
);
27 spyOn(svg
, 'attr').andReturn(svg
);
29 var radarGraph
= new tr
.graphing
.Radar(svg
, 500, radar
);
33 expect(svg
.append
).toHaveBeenCalledWith('line');
34 expect(svg
.attr
).toHaveBeenCalledWith('x1', 500 / 2);
35 expect(svg
.attr
).toHaveBeenCalledWith('y1', 0);
36 expect(svg
.attr
).toHaveBeenCalledWith('x2', 500 / 2);
37 expect(svg
.attr
).toHaveBeenCalledWith('y2', 500);
38 expect(svg
.attr
).toHaveBeenCalledWith('stroke-width', 5);
41 it('plots a horizontal line in the center', function () {
43 spyOn(svg
, 'append').andReturn(svg
);
44 spyOn(svg
, 'attr').andReturn(svg
);
46 var radarGraph
= new tr
.graphing
.Radar(svg
, 500, radar
);
50 expect(svg
.append
).toHaveBeenCalledWith('line');
51 expect(svg
.attr
).toHaveBeenCalledWith('x1', 0);
52 expect(svg
.attr
).toHaveBeenCalledWith('y1', 500 / 2);
53 expect(svg
.attr
).toHaveBeenCalledWith('x2', 500);
54 expect(svg
.attr
).toHaveBeenCalledWith('y2', 500 / 2);
55 expect(svg
.attr
).toHaveBeenCalledWith('stroke-width', 5);
59 describe('circles', function () {
62 beforeEach(function () {
66 spyOn(svg
, 'append').andReturn(svg
);
67 spyOn(svg
, 'attr').andReturn(svg
);
69 radar
= new tr
.models
.Radar();
70 spyOn(radar
, 'cycles').andReturn([
71 new tr
.models
.Cycle('Adopt'),
72 new tr
.models
.Cycle('Hold')
74 radarGraph
= new tr
.graphing
.Radar(svg
, 500, radar
);
77 it('plots the circles for the cicles', function () {
80 expect(svg
.append
).toHaveBeenCalledWith('circle');
81 expect(svg
.attr
).toHaveBeenCalledWith('cx', 500 / 2);
82 expect(svg
.attr
).toHaveBeenCalledWith('cy', 500 / 2);
83 expect(svg
.attr
).toHaveBeenCalledWith('r', Math
.round(250 / 2));
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', 250);