1 describe('tr.models.Radar', function () {
3 it('has no quadrants by default', function () {
4 radar
= new tr
.models
.Radar();
6 expect(radar
.quadrants().I
).toBe(null);
7 expect(radar
.quadrants().II
).toBe(null);
8 expect(radar
.quadrants().III
).toBe(null);
9 expect(radar
.quadrants().IV
).toBe(null);
12 it('sets the first quadrant', function () {
13 var quadrant
, radar
, blip
;
15 blip
= new tr
.models
.Blip('A', new tr
.models
.Cycle('First'));
16 quadrant
= new tr
.models
.Quadrant('First');
18 radar
= new tr
.models
.Radar();
20 radar
.setFirstQuadrant(quadrant
);
22 expect(radar
.quadrants().I
).toEqual(quadrant
);
23 expect(radar
.quadrants().I
.blips()[0].number()).toEqual(1);
26 it('sets the second quadrant', function () {
27 var quadrant
, radar
, blip
;
29 blip
= new tr
.models
.Blip('A', new tr
.models
.Cycle('First'));
30 quadrant
= new tr
.models
.Quadrant('Second');
32 radar
= new tr
.models
.Radar();
34 radar
.setSecondQuadrant(quadrant
);
36 expect(radar
.quadrants().II
).toEqual(quadrant
);
37 expect(radar
.quadrants().II
.blips()[0].number()).toEqual(1);
40 it('sets the third quadrant', function () {
41 var quadrant
, radar
, blip
;
43 blip
= new tr
.models
.Blip('A', new tr
.models
.Cycle('First'));
44 quadrant
= new tr
.models
.Quadrant('Third');
46 radar
= new tr
.models
.Radar();
48 radar
.setThirdQuadrant(quadrant
);
50 expect(radar
.quadrants().III
).toEqual(quadrant
);
51 expect(radar
.quadrants().III
.blips()[0].number()).toEqual(1);
54 it('sets the fourth quadrant', function () {
55 var quadrant
, radar
, blip
;
57 blip
= new tr
.models
.Blip('A', new tr
.models
.Cycle('First'));
58 quadrant
= new tr
.models
.Quadrant('Fourth');
60 radar
= new tr
.models
.Radar();
62 radar
.setFourthQuadrant(quadrant
);
64 expect(radar
.quadrants().IV
).toEqual(quadrant
);
65 expect(radar
.quadrants().IV
.blips()[0].number()).toEqual(1);
68 describe('blip numbers', function () {
69 var firstQuadrant
, secondQuadrant
, radar
, firstCycle
;
71 beforeEach(function () {
72 firstCycle
= new tr
.models
.Cycle('Adopt', 0);
73 firstQuadrant
= new tr
.models
.Quadrant('First');
74 secondQuadrant
= new tr
.models
.Quadrant('Second');
76 new tr
.models
.Blip('A', firstCycle
),
77 new tr
.models
.Blip('B', firstCycle
)
80 new tr
.models
.Blip('C', firstCycle
),
81 new tr
.models
.Blip('D', firstCycle
)
83 radar
= new tr
.models
.Radar();
86 it('sets blip numbers starting on the first quadrant', function () {
87 radar
.setFirstQuadrant(firstQuadrant
);
89 expect(radar
.quadrants().I
.blips()[0].number()).toEqual(1);
90 expect(radar
.quadrants().I
.blips()[1].number()).toEqual(2);
93 it('continues the number from the previous quadrant set', function () {
94 radar
.setFirstQuadrant(firstQuadrant
);
95 radar
.setSecondQuadrant(secondQuadrant
);
97 expect(radar
.quadrants().II
.blips()[0].number()).toEqual(3);
98 expect(radar
.quadrants().II
.blips()[1].number()).toEqual(4);
102 describe('cycles', function () {
103 var quadrant
, radar
, firstCycle
, secondCycle
;
105 beforeEach(function () {
106 firstCycle
= new tr
.models
.Cycle('Adopt', 0);
107 secondCycle
= new tr
.models
.Cycle('Hold', 1);
108 quadrant
= new tr
.models
.Quadrant('Fourth');
109 radar
= new tr
.models
.Radar();
112 it('returns an array for a given set of blips', function () {
114 new tr
.models
.Blip('A', firstCycle
),
115 new tr
.models
.Blip('B', secondCycle
)
118 radar
.setFirstQuadrant(quadrant
);
120 expect(radar
.cycles()).toEqual([firstCycle
, secondCycle
]);
123 it('has unique cycles', function () {
125 new tr
.models
.Blip('A', firstCycle
),
126 new tr
.models
.Blip('B', firstCycle
),
127 new tr
.models
.Blip('C', secondCycle
)
130 radar
.setFirstQuadrant(quadrant
);
132 expect(radar
.cycles()).toEqual([firstCycle
, secondCycle
]);
135 it('has sorts by the cycle order', function () {
137 new tr
.models
.Blip('C', secondCycle
),
138 new tr
.models
.Blip('A', firstCycle
),
139 new tr
.models
.Blip('B', firstCycle
)
142 radar
.setFirstQuadrant(quadrant
);
144 expect(radar
.cycles()).toEqual([firstCycle
, secondCycle
]);