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 () {
15 quadrant
= new tr
.models
.Quadrant('First');
16 radar
= new tr
.models
.Radar();
18 radar
.setFirstQuadrant(quadrant
);
20 expect(radar
.quadrants().I
).toEqual(quadrant
);
23 it('sets the second quadrant', function () {
26 quadrant
= new tr
.models
.Quadrant('Second');
27 radar
= new tr
.models
.Radar();
29 radar
.setSecondQuadrant(quadrant
);
31 expect(radar
.quadrants().II
).toEqual(quadrant
);
34 it('sets the third quadrant', function () {
37 quadrant
= new tr
.models
.Quadrant('Third');
38 radar
= new tr
.models
.Radar();
40 radar
.setThirdQuadrant(quadrant
);
42 expect(radar
.quadrants().III
).toEqual(quadrant
);
45 it('sets the fourth quadrant', function () {
48 quadrant
= new tr
.models
.Quadrant('Fourth');
49 radar
= new tr
.models
.Radar();
51 radar
.setFourthQuadrant(quadrant
);
53 expect(radar
.quadrants().IV
).toEqual(quadrant
);
56 describe('blip numbers', function () {
57 var firstQuadrant
, secondQuadrant
, radar
, firstCycle
;
59 beforeEach(function () {
60 firstCycle
= new tr
.models
.Cycle('Adopt', 0);
61 firstQuadrant
= new tr
.models
.Quadrant('First');
62 secondQuadrant
= new tr
.models
.Quadrant('Second');
64 new tr
.models
.Blip('A', firstCycle
),
65 new tr
.models
.Blip('B', firstCycle
)
68 new tr
.models
.Blip('C', firstCycle
),
69 new tr
.models
.Blip('D', firstCycle
)
71 radar
= new tr
.models
.Radar();
74 it('sets blip numbers starting on the first quadrant', function () {
75 radar
.setFirstQuadrant(firstQuadrant
);
77 expect(radar
.quadrants().I
.blips()[0].number()).toEqual(1);
78 expect(radar
.quadrants().I
.blips()[1].number()).toEqual(2);
81 it('continues the number from the previous quadrant set', function () {
82 radar
.setFirstQuadrant(firstQuadrant
);
83 radar
.setSecondQuadrant(secondQuadrant
);
85 expect(radar
.quadrants().II
.blips()[0].number()).toEqual(3);
86 expect(radar
.quadrants().II
.blips()[1].number()).toEqual(4);
90 describe('cycles', function () {
91 var quadrant
, radar
, firstCycle
, secondCycle
;
93 beforeEach(function () {
94 firstCycle
= new tr
.models
.Cycle('Adopt', 0);
95 secondCycle
= new tr
.models
.Cycle('Hold', 1);
96 quadrant
= new tr
.models
.Quadrant('Fourth');
97 radar
= new tr
.models
.Radar();
100 it('returns an array for a given set of blips', function () {
102 new tr
.models
.Blip('A', firstCycle
),
103 new tr
.models
.Blip('B', secondCycle
)
106 radar
.setFirstQuadrant(quadrant
);
108 expect(radar
.cycles()).toEqual([firstCycle
, secondCycle
]);
111 it('has unique cycles', function () {
113 new tr
.models
.Blip('A', firstCycle
),
114 new tr
.models
.Blip('B', firstCycle
),
115 new tr
.models
.Blip('C', secondCycle
)
118 radar
.setFirstQuadrant(quadrant
);
120 expect(radar
.cycles()).toEqual([firstCycle
, secondCycle
]);
123 it('has sorts by the cycle order', function () {
125 new tr
.models
.Blip('C', secondCycle
),
126 new tr
.models
.Blip('A', firstCycle
),
127 new tr
.models
.Blip('B', firstCycle
)
130 radar
.setFirstQuadrant(quadrant
);
132 expect(radar
.cycles()).toEqual([firstCycle
, secondCycle
]);