-tr.models.Cycle = function (name) {
+tr.models.Cycle = function (name, order) {
var self = {};
self.name = function () {
return name;
};
+ self.order = function () {
+ return order;
+ };
+
return self;
};
}
}
- return cycleArray.slice(0);
+ return cycleArray.slice(0).sort(function (a, b) { return a.order() - b.order(); });
};
self.quadrants = function () {
expect(cycle.name()).toEqual('My Cycle');
});
+
+ it('has a order', function () {
+ var cycle = new tr.models.Cycle('My Cycle', 0);
+
+ expect(cycle.order()).toEqual(0);
+ });
});
var quadrant, radar, firstCycle, secondCycle;
beforeEach(function () {
- firstCycle = new tr.models.Cycle('Adopt');
- secondCycle = new tr.models.Cycle('Hold');
+ firstCycle = new tr.models.Cycle('Adopt', 0);
+ secondCycle = new tr.models.Cycle('Hold', 1);
quadrant = new tr.models.Quadrant('Fourth');
radar = new tr.models.Radar();
});
expect(radar.cycles()).toEqual([firstCycle, secondCycle]);
});
+
+ it('has sorts by the cycle order', function () {
+ quadrant.add([
+ new tr.models.Blip('C', secondCycle),
+ new tr.models.Blip('A', firstCycle),
+ new tr.models.Blip('B', firstCycle)
+ ]);
+
+ radar.setFirstQuadrant(quadrant);
+
+ expect(radar.cycles()).toEqual([firstCycle, secondCycle]);
+ });
});
});