bump to v0.2.0
[tech-radar.git] / test / graphing / ref-table-spec.js
1 describe('tr.graphing.RefTable', function () {
2 var radar, toolsQuadrant, techniquesQuadrant, platformsQuadrant, languageFramework, element;
3
4 beforeEach(function () {
5 toolsQuadrant = new tr.models.Quadrant('Tools');
6 techniquesQuadrant = new tr.models.Quadrant('Techniques');
7 platformsQuadrant = new tr.models.Quadrant('Platforms');
8 languageFramework = new tr.models.Quadrant('Languages');
9
10 radar = new tr.models.Radar();
11 radar.setFirstQuadrant(toolsQuadrant);
12 radar.setSecondQuadrant(techniquesQuadrant);
13 radar.setThirdQuadrant(platformsQuadrant);
14 radar.setFourthQuadrant(languageFramework);
15
16 element = { innerHTML: '' };
17 spyOn(document, 'querySelector').andReturn(element);
18 });
19
20 describe('render', function () {
21 it("groups blips by cycle", function () {
22 var adopt = new tr.models.Cycle('Adopt');
23 var assess = new tr.models.Cycle('Assess');
24
25 toolsQuadrant.add([
26 new tr.models.Blip('foo', adopt, true, 'this is foo'),
27 new tr.models.Blip('bar', assess, true, 'this is bar'),
28 new tr.models.Blip('baz', adopt, true, 'this is baz')
29 ]);
30
31 var table = new tr.graphing.RefTable(radar);
32 table.init('#some-id').render();
33
34 expect(element.innerHTML).toEqual(
35 '<table class="radar-ref-table">' +
36 '<tr class="radar-ref-status-group"><td colspan="3">Adopt</td></tr>' +
37 '<tr><td>-1</td><td>foo</td><td>this is foo</td></tr>' +
38 '<tr><td>-1</td><td>baz</td><td>this is baz</td></tr>' +
39 '<tr class="radar-ref-status-group"><td colspan="3">Assess</td></tr>' +
40 '<tr><td>-1</td><td>bar</td><td>this is bar</td></tr>' +
41 '</table>');
42 });
43
44 it("respects the assigned order of cycles", function () {
45 var adopt = new tr.models.Cycle('Adopt', 1);
46 var assess = new tr.models.Cycle('Assess', 3);
47 var hold = new tr.models.Cycle('Hold', 2);
48
49 toolsQuadrant.add([
50 new tr.models.Blip('foo', adopt, true, 'this is foo'),
51 new tr.models.Blip('bar', assess, true, 'this is bar'),
52 new tr.models.Blip('baz', hold, true, 'this is baz')
53 ]);
54
55 var table = new tr.graphing.RefTable(radar);
56 table.init('#some-id').render();
57
58 expect(element.innerHTML).toEqual(
59 '<table class="radar-ref-table">' +
60 '<tr class="radar-ref-status-group"><td colspan="3">Adopt</td></tr>' +
61 '<tr><td>-1</td><td>foo</td><td>this is foo</td></tr>' +
62 '<tr class="radar-ref-status-group"><td colspan="3">Hold</td></tr>' +
63 '<tr><td>-1</td><td>baz</td><td>this is baz</td></tr>' +
64 '<tr class="radar-ref-status-group"><td colspan="3">Assess</td></tr>' +
65 '<tr><td>-1</td><td>bar</td><td>this is bar</td></tr>' +
66 '</table>');
67 });
68 });
69 });