09043d68d1a216f5d4cebc5b4ee059d2dc8ee96e
[tech-radar.git] / test / models / radar-spec.js
1 describe('tr.models.Radar', function () {
2
3 it('has no quadrants by default', function () {
4 radar = new tr.models.Radar();
5
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);
10 });
11
12 it('sets the first quadrant', function () {
13 var quadrant, radar;
14
15 quadrant = new tr.models.Quadrant('First');
16 radar = new tr.models.Radar();
17
18 radar.setFirstQuadrant(quadrant);
19
20 expect(radar.quadrants().I).toEqual(quadrant);
21 });
22
23 it('sets the second quadrant', function () {
24 var quadrant, radar;
25
26 quadrant = new tr.models.Quadrant('Second');
27 radar = new tr.models.Radar();
28
29 radar.setSecondQuadrant(quadrant);
30
31 expect(radar.quadrants().II).toEqual(quadrant);
32 });
33
34 it('sets the third quadrant', function () {
35 var quadrant, radar;
36
37 quadrant = new tr.models.Quadrant('Third');
38 radar = new tr.models.Radar();
39
40 radar.setThirdQuadrant(quadrant);
41
42 expect(radar.quadrants().III).toEqual(quadrant);
43 });
44
45 it('sets the fourth quadrant', function () {
46 var quadrant, radar;
47
48 quadrant = new tr.models.Quadrant('Fourth');
49 radar = new tr.models.Radar();
50
51 radar.setFourthQuadrant(quadrant);
52
53 expect(radar.quadrants().IV).toEqual(quadrant);
54 });
55
56 describe('cycles', function () {
57 var quadrant, radar, firstCycle, secondCycle;
58
59 beforeEach(function () {
60 firstCycle = new tr.models.Cycle('Adopt', 0);
61 secondCycle = new tr.models.Cycle('Hold', 1);
62 quadrant = new tr.models.Quadrant('Fourth');
63 radar = new tr.models.Radar();
64 });
65
66 it('returns an array for a given set of blips', function () {
67 quadrant.add([
68 new tr.models.Blip('A', firstCycle),
69 new tr.models.Blip('B', secondCycle)
70 ]);
71
72 radar.setFirstQuadrant(quadrant);
73
74 expect(radar.cycles()).toEqual([firstCycle, secondCycle]);
75 });
76
77 it('has unique cycles', function () {
78 quadrant.add([
79 new tr.models.Blip('A', firstCycle),
80 new tr.models.Blip('B', firstCycle),
81 new tr.models.Blip('C', secondCycle)
82 ]);
83
84 radar.setFirstQuadrant(quadrant);
85
86 expect(radar.cycles()).toEqual([firstCycle, secondCycle]);
87 });
88
89 it('has sorts by the cycle order', function () {
90 quadrant.add([
91 new tr.models.Blip('C', secondCycle),
92 new tr.models.Blip('A', firstCycle),
93 new tr.models.Blip('B', firstCycle)
94 ]);
95
96 radar.setFirstQuadrant(quadrant);
97
98 expect(radar.cycles()).toEqual([firstCycle, secondCycle]);
99 });
100 });
101 });