Bri Prebilic Cole

GUI -- Topology View all, packet, and optical layer radio buttons are now part o…

…f the topology view toolbar, instead of being in the masthead. Keystroke 'N' for cycle node layers added. Button glyph added. Fixed previously unseen broken unit tests for table.js.

Change-Id: I6e53bdc6cacbf41b990abd07d30fc99ef4c3b8c0
...@@ -207,6 +207,15 @@ ...@@ -207,6 +207,15 @@
207 "91.4,54.9,91.4z M84,87.1c0,2.4-1.9,4.3-4.3,4.3c-2.4,0-4.3-1.9" + 207 "91.4,54.9,91.4z M84,87.1c0,2.4-1.9,4.3-4.3,4.3c-2.4,0-4.3-1.9" +
208 "-4.3-4.3c0-2.4,1.9-4.3,4.3-4.3C82.1,82.8,84,84.7,84,87.1z", 208 "-4.3-4.3c0-2.4,1.9-4.3,4.3-4.3C82.1,82.8,84,84.7,84,87.1z",
209 209
210 + filters: "M24.8,13.3L9.8,40.5h75.3l15.0-27.2H24.8z M72.8,32.1l-" +
211 + "9.7-8.9l-19.3,8.9l-6.0-7.4L24.1,30.9l-1.2-2.7l15.7-7.1l6.0,7.4" +
212 + "l19.0-8.8l9.7,8.8l11.5-5.6l1.3,2.7L72.8,32.1zM24.3,68.3L9.3," +
213 + "95.5h75.3l15.0-27.2H24.3z M84.3,85.9L70.7,79.8l-6.0,7.4l-19.3" +
214 + "-8.9l-9.7,8.9l-13.3-6.5l1.3-2.7l11.5,5.6l9.7-8.8l19.0,8.8l6.0" +
215 + "-7.4l15.7,7.1L84.3,85.9z M15.3,57h-6v-4h6V57zM88.1,57H76.0v-4h" +
216 + "12.1V57z M69.9,57H57.8v-4h12.1V57z M51.7,57H39.6v-4H51.7V57z " +
217 + "M33.5,57H21.4v-4h12.1V57zM100.2,57h-6v-4h6V57z",
218 +
210 resetZoom: "M86,79.8L61.7,54.3c1.8-2.9,2.8-6.3,2.9-10c0.3-11.2" + 219 resetZoom: "M86,79.8L61.7,54.3c1.8-2.9,2.8-6.3,2.9-10c0.3-11.2" +
211 "-8.6-20.5-19.8-20.8C33.7,23.2,24.3,32,24.1,43.2c-0.3,11.2,8.6," + 220 "-8.6-20.5-19.8-20.8C33.7,23.2,24.3,32,24.1,43.2c-0.3,11.2,8.6," +
212 "20.5,19.8,20.8c4,0.1,8.9-0.8,11.9-3.6l23.7,25c1.5,1.6,4,2.3," + 221 "20.5,19.8,20.8c4,0.1,8.9-0.8,11.9-3.6l23.7,25c1.5,1.6,4,2.3," +
......
...@@ -100,8 +100,8 @@ ...@@ -100,8 +100,8 @@
100 // to get the height of the table 100 // to get the height of the table
101 function setTableHeight(thead, tbody) { 101 function setTableHeight(thead, tbody) {
102 var titleHeight = h2Pdg + fs.noPxStyle(d3.select('h2'), 'height'), 102 var titleHeight = h2Pdg + fs.noPxStyle(d3.select('h2'), 'height'),
103 - thHeight = thPdg + fs.noPxStyle(d3.select('th'), 'height'), 103 + thHeight = thPdg + fs.noPxStyle(thead, 'height'),
104 - totalHeight = titleHeight + thHeight + tbodyPdg + mastPdg, 104 + totalHeight = titleHeight + thHeight + mastPdg - tbodyPdg,
105 tableHeight = fs.windowSize(mast.mastHeight() + totalHeight).height; 105 tableHeight = fs.windowSize(mast.mastHeight() + totalHeight).height;
106 106
107 thead.style('display', 'block'); 107 thead.style('display', 'block');
......
...@@ -542,41 +542,3 @@ ...@@ -542,41 +542,3 @@
542 fill: #eee; 542 fill: #eee;
543 } 543 }
544 544
545 -
546 -
547 -
548 -/* radio buttons injected into masthead */
549 -
550 -#topo-radio-group span.radio {
551 - font-size: 10pt;
552 - margin: 4px 2px;
553 - padding: 1px 6px;
554 - -moz-border-radius: 3px;
555 - border-radius: 3px;
556 - cursor: pointer;
557 -}
558 -
559 -.light #topo-radio-group span.radio {
560 - border: 1px dotted #222;
561 - color: #eee;
562 -}
563 -.dark #topo-radio-group span.radio {
564 - border: 1px dotted #bbb;
565 - color: #888;
566 -}
567 -
568 -#topo-radio-group span.radio.active {
569 - padding: 1px 6px;
570 -}
571 -
572 -.light #topo-radio-group span.radio.active {
573 - background-color: #bbb;
574 - border: 1px solid #eee;
575 - color: #666;
576 -
577 -}
578 -.dark #topo-radio-group span.radio.active {
579 - background-color: #222;
580 - border: 1px solid #eee;
581 - color: #78a;
582 -}
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
29 29
30 // references to injected services etc. 30 // references to injected services etc.
31 var $log, fs, ks, zs, gs, ms, sus, flash, wss, 31 var $log, fs, ks, zs, gs, ms, sus, flash, wss,
32 - tes, tfs, tps, tis, tss, tls, tts, tos, ttbs; 32 + tes, tfs, tps, tis, tss, tls, tts, tos, fltr, ttbs;
33 33
34 // DOM elements 34 // DOM elements
35 var ovtopo, svg, defs, zoomLayer, mapG, forceG, noDevsLayer; 35 var ovtopo, svg, defs, zoomLayer, mapG, forceG, noDevsLayer;
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
55 55
56 //X: [toggleNodeLock, 'Lock / unlock node positions'], 56 //X: [toggleNodeLock, 'Lock / unlock node positions'],
57 Z: [tos.toggleOblique, 'Toggle oblique view (Experimental)'], 57 Z: [tos.toggleOblique, 'Toggle oblique view (Experimental)'],
58 + N: [fltr.clickAction, 'Cycle node layers'],
58 L: [tfs.cycleDeviceLabels, 'Cycle device labels'], 59 L: [tfs.cycleDeviceLabels, 'Cycle device labels'],
59 U: [tfs.unpin, 'Unpin node (hover mouse over)'], 60 U: [tfs.unpin, 'Unpin node (hover mouse over)'],
60 R: [resetZoom, 'Reset pan / zoom'], 61 R: [resetZoom, 'Reset pan / zoom'],
...@@ -75,7 +76,7 @@ ...@@ -75,7 +76,7 @@
75 76
76 _helpFormat: [ 77 _helpFormat: [
77 ['I', 'O', 'D', '-', 'H', 'M', 'P', 'dash', 'B' ], 78 ['I', 'O', 'D', '-', 'H', 'M', 'P', 'dash', 'B' ],
78 - ['X', 'Z', 'L', 'U', 'R', '-', 'dot'], 79 + ['X', 'Z', 'N', 'L', 'U', 'R', '-', 'dot'],
79 ['V', 'rightArrow', 'leftArrow', 'W', 'A', 'F', '-', 'E' ] 80 ['V', 'rightArrow', 'leftArrow', 'W', 'A', 'F', '-', 'E' ]
80 ] 81 ]
81 }; 82 };
...@@ -244,11 +245,12 @@ ...@@ -244,11 +245,12 @@
244 'WebSocketService', 245 'WebSocketService',
245 'TopoEventService', 'TopoForceService', 'TopoPanelService', 246 'TopoEventService', 'TopoForceService', 'TopoPanelService',
246 'TopoInstService', 'TopoSelectService', 'TopoLinkService', 247 'TopoInstService', 'TopoSelectService', 'TopoLinkService',
247 - 'TopoTrafficService', 'TopoObliqueService', 'TopoToolbarService', 248 + 'TopoTrafficService', 'TopoObliqueService', 'TopoFilterService',
249 + 'TopoToolbarService',
248 250
249 function ($scope, _$log_, $loc, $timeout, _fs_, mast, _ks_, _zs_, 251 function ($scope, _$log_, $loc, $timeout, _fs_, mast, _ks_, _zs_,
250 _gs_, _ms_, _sus_, _flash_, _wss_, _tes_, _tfs_, _tps_, 252 _gs_, _ms_, _sus_, _flash_, _wss_, _tes_, _tfs_, _tps_,
251 - _tis_, _tss_, _tls_, _tts_, _tos_, _ttbs_) { 253 + _tis_, _tss_, _tls_, _tts_, _tos_, _fltr_, _ttbs_) {
252 var self = this, 254 var self = this,
253 projection, 255 projection,
254 dim, 256 dim,
...@@ -281,6 +283,7 @@ ...@@ -281,6 +283,7 @@
281 tls = _tls_; 283 tls = _tls_;
282 tts = _tts_; 284 tts = _tts_;
283 tos = _tos_; 285 tos = _tos_;
286 + fltr = _fltr_;
284 ttbs = _ttbs_; 287 ttbs = _ttbs_;
285 288
286 self.notifyResize = function () { 289 self.notifyResize = function () {
......
...@@ -35,86 +35,51 @@ ...@@ -35,86 +35,51 @@
35 35
36 // which "layer" a particular item "belongs to" 36 // which "layer" a particular item "belongs to"
37 var layerLookup = { 37 var layerLookup = {
38 - host: { 38 + host: {
39 - endstation: 'pkt', // default, if host event does not define type 39 + endstation: 'pkt', // default, if host event does not define type
40 - router: 'pkt', 40 + router: 'pkt',
41 - bgpSpeaker: 'pkt' 41 + bgpSpeaker: 'pkt'
42 - }, 42 + },
43 - device: { 43 + device: {
44 - switch: 'pkt', 44 + switch: 'pkt',
45 - roadm: 'opt' 45 + roadm: 'opt'
46 - }, 46 + },
47 - link: { 47 + link: {
48 - hostLink: 'pkt', 48 + hostLink: 'pkt',
49 - direct: 'pkt', 49 + direct: 'pkt',
50 - indirect: '', 50 + indirect: '',
51 - tunnel: '', 51 + tunnel: '',
52 - optical: 'opt' 52 + optical: 'opt'
53 - } 53 + }
54 - };
55 -
56 - var idPrefix = 'topo-rb-';
57 -
58 - var dispatch = {
59 - all: function () { suppressLayers(false); },
60 - pkt: function () { showLayer('pkt'); },
61 - opt: function () { showLayer('opt'); }
62 }, 54 },
63 - filterButtons = [ 55 + // order of layer cycling in button
64 - { text: 'All Layers', id: 'all' }, 56 + dispatch = [
65 - { text: 'Packet Only', id: 'pkt' }, 57 + {
66 - { text: 'Optical Only', id: 'opt' } 58 + type: 'all',
67 - ], 59 + action: function () { suppressLayers(false); },
68 - btnG, 60 + msg: 'All Layers Shown'
69 - btnDef = {}, 61 + },
70 - targetDiv; 62 + {
71 - 63 + type: 'pkt',
72 - 64 + action: function () { showLayer('pkt'); },
73 - function injectButtons(div) { 65 + msg: 'Packet Layer Shown'
74 - targetDiv = div; 66 + },
75 - 67 + {
76 - btnG = div.append('div').attr('id', 'topo-radio-group'); 68 + type: 'opt',
77 - 69 + action: function () { showLayer('opt'); },
78 - filterButtons.forEach(function (btn, i) { 70 + msg: 'Optical Layer Shown'
79 - var bid = btn.id,
80 - txt = btn.text,
81 - uid = idPrefix + bid,
82 - button = btnG.append('span')
83 - .attr({
84 - id: uid,
85 - 'class': 'radio'
86 - })
87 - .text(txt);
88 - btnDef[uid] = btn;
89 -
90 - if (i === 0) {
91 - button.classed('active', true);
92 - btnG.selected = bid;
93 } 71 }
94 - }); 72 + ],
95 - 73 + layer = 0;
96 - btnG.selectAll('span')
97 - .on('click', function () {
98 - var button = d3.select(this),
99 - uid = button.attr('id'),
100 - btn = btnDef[uid],
101 - act = button.classed('active');
102 -
103 - if (!act) {
104 - btnG.selectAll('span').classed('active', false);
105 - button.classed('active', true);
106 - btnG.selected = btn.id;
107 - clickAction(btn.id);
108 - }
109 - });
110 - }
111 74
112 - function clickAction(which) { 75 + function clickAction() {
113 - dispatch[which](); 76 + layer = (layer + 1) % dispatch.length;
77 + dispatch[layer].action();
78 + flash.flash(dispatch[layer].msg);
114 } 79 }
115 80
116 function selected() { 81 function selected() {
117 - return btnG ? btnG.selected : ''; 82 + return dispatch[layer].type;
118 } 83 }
119 84
120 function inLayer(d, layer) { 85 function inLayer(d, layer) {
...@@ -169,20 +134,12 @@ ...@@ -169,20 +134,12 @@
169 tps = _tps_; 134 tps = _tps_;
170 tts = _tts_; 135 tts = _tts_;
171 136
172 - function initFilter(_api_, div) { 137 + function initFilter(_api_) {
173 api = _api_; 138 api = _api_;
174 - injectButtons(div);
175 - }
176 -
177 - function destroyFilter() {
178 - targetDiv.select('#topo-radio-group').remove();
179 - btnG = null;
180 - btnDef = {};
181 } 139 }
182 140
183 return { 141 return {
184 initFilter: initFilter, 142 initFilter: initFilter,
185 - destroyFilter: destroyFilter,
186 143
187 clickAction: clickAction, 144 clickAction: clickAction,
188 selected: selected, 145 selected: selected,
......
...@@ -816,7 +816,7 @@ ...@@ -816,7 +816,7 @@
816 tss.initSelect(mkSelectApi(uplink)); 816 tss.initSelect(mkSelectApi(uplink));
817 tts.initTraffic(mkTrafficApi(uplink)); 817 tts.initTraffic(mkTrafficApi(uplink));
818 tos.initOblique(mkObliqueApi(uplink, fltr)); 818 tos.initOblique(mkObliqueApi(uplink, fltr));
819 - fltr.initFilter(mkFilterApi(uplink), d3.select('#mast-right')); 819 + fltr.initFilter(mkFilterApi(uplink));
820 tls.initLink(mkLinkApi(svg, uplink), td3); 820 tls.initLink(mkLinkApi(svg, uplink), td3);
821 821
822 settings = angular.extend({}, defaultSettings, opts); 822 settings = angular.extend({}, defaultSettings, opts);
...@@ -855,7 +855,6 @@ ...@@ -855,7 +855,6 @@
855 force.stop(); 855 force.stop();
856 856
857 tls.destroyLink(); 857 tls.destroyLink();
858 - fltr.destroyFilter();
859 tos.destroyOblique(); 858 tos.destroyOblique();
860 tts.destroyTraffic(); 859 tts.destroyTraffic();
861 tss.destroySelect(); 860 tss.destroySelect();
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
44 44
45 //X: { id: 'nodelock-tog', gid: 'lock', isel: false }, 45 //X: { id: 'nodelock-tog', gid: 'lock', isel: false },
46 Z: { id: 'oblique-tog', gid: 'oblique', isel: false }, 46 Z: { id: 'oblique-tog', gid: 'oblique', isel: false },
47 + N: { id: 'filters-btn', gid: 'filters' },
47 L: { id: 'cycleLabels-btn', gid: 'cycleLabels' }, 48 L: { id: 'cycleLabels-btn', gid: 'cycleLabels' },
48 R: { id: 'resetZoom-btn', gid: 'resetZoom' }, 49 R: { id: 'resetZoom-btn', gid: 'resetZoom' },
49 50
...@@ -93,6 +94,7 @@ ...@@ -93,6 +94,7 @@
93 function addSecondRow() { 94 function addSecondRow() {
94 //addToggle('X'); 95 //addToggle('X');
95 addToggle('Z'); 96 addToggle('Z');
97 + addButton('N');
96 addButton('L'); 98 addButton('L');
97 addButton('R'); 99 addButton('R');
98 } 100 }
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
20 describe('factory: fw/svg/glyph.js', function() { 20 describe('factory: fw/svg/glyph.js', function() {
21 var $log, fs, gs, d3Elem, svg; 21 var $log, fs, gs, d3Elem, svg;
22 22
23 - var numBaseGlyphs = 34, 23 + var numBaseGlyphs = 35,
24 vbBird = '352 224 113 112', 24 vbBird = '352 224 113 112',
25 vbGlyph = '0 0 110 110', 25 vbGlyph = '0 0 110 110',
26 vbBadge = '0 0 10 10', 26 vbBadge = '0 0 10 10',
...@@ -46,6 +46,7 @@ describe('factory: fw/svg/glyph.js', function() { ...@@ -46,6 +46,7 @@ describe('factory: fw/svg/glyph.js', function() {
46 map: 'M95.8,9.2H14.2c-2.8,0-5,2.2-5,5v66', 46 map: 'M95.8,9.2H14.2c-2.8,0-5,2.2-5,5v66',
47 cycleLabels: 'M72.5,33.9c', 47 cycleLabels: 'M72.5,33.9c',
48 oblique: 'M80.9,30.2h', 48 oblique: 'M80.9,30.2h',
49 + filters: 'M24.8,13.3L',
49 resetZoom: 'M86,79.8L', 50 resetZoom: 'M86,79.8L',
50 relatedIntents: 'M99.9,43.7', 51 relatedIntents: 'M99.9,43.7',
51 nextIntent: 'M88.1,55.7', 52 nextIntent: 'M88.1,55.7',
...@@ -74,8 +75,8 @@ describe('factory: fw/svg/glyph.js', function() { ...@@ -74,8 +75,8 @@ describe('factory: fw/svg/glyph.js', function() {
74 'unknown', 'node', 'switch', 'roadm', 'endstation', 'router', 75 'unknown', 'node', 'switch', 'roadm', 'endstation', 'router',
75 'bgpSpeaker', 'chain', 'crown', 'lock', 76 'bgpSpeaker', 'chain', 'crown', 'lock',
76 'summary', 'details', 'ports', 'map', 'cycleLabels', 'oblique', 77 'summary', 'details', 'ports', 'map', 'cycleLabels', 'oblique',
77 - 'resetZoom', 'relatedIntents', 'nextIntent', 'prevIntent', 78 + 'filters', 'resetZoom', 'relatedIntents', 'nextIntent',
78 - 'intentTraffic', 'allTraffic', 'flows', 'eqMaster' 79 + 'prevIntent', 'intentTraffic', 'allTraffic', 'flows', 'eqMaster'
79 ], 80 ],
80 badgeIds = [ 81 badgeIds = [
81 'uiAttached', 'checkMark', 'xMark', 'triangleUp', 'triangleDown', 82 'uiAttached', 'checkMark', 'xMark', 'triangleUp', 'triangleDown',
......
...@@ -19,11 +19,12 @@ ...@@ -19,11 +19,12 @@
19 */ 19 */
20 describe('factory: fw/widget/table.js', function () { 20 describe('factory: fw/widget/table.js', function () {
21 var $log, $compile, $rootScope, 21 var $log, $compile, $rootScope,
22 - fs, is, 22 + fs, mast, is,
23 scope, compiled, 23 scope, compiled,
24 - table, thead, tbody, 24 + table, thead, tbody, mockHeader,
25 + mockh2Height = '10px',
25 tableIconTdSize = 100, 26 tableIconTdSize = 100,
26 - bottomMargin = 200, 27 + pdgTop = 101,
27 numTestElems = 4; 28 numTestElems = 4;
28 29
29 var onosFixedHeaderTags = '<table ' + 30 var onosFixedHeaderTags = '<table ' +
...@@ -73,7 +74,7 @@ describe('factory: fw/widget/table.js', function () { ...@@ -73,7 +74,7 @@ describe('factory: fw/widget/table.js', function () {
73 '</tbody>' + 74 '</tbody>' +
74 '</table>'; 75 '</table>';
75 76
76 - beforeEach(module('onosWidget', 'onosUtil', 'onosSvg')); 77 + beforeEach(module('onosWidget', 'onosUtil', 'onosMast', 'onosSvg'));
77 78
78 var mockWindow = { 79 var mockWindow = {
79 innerWidth: 400, 80 innerWidth: 400,
...@@ -92,11 +93,12 @@ describe('factory: fw/widget/table.js', function () { ...@@ -92,11 +93,12 @@ describe('factory: fw/widget/table.js', function () {
92 }); 93 });
93 94
94 beforeEach(inject(function (_$log_, _$compile_, _$rootScope_, 95 beforeEach(inject(function (_$log_, _$compile_, _$rootScope_,
95 - FnService, IconService) { 96 + FnService, MastService, IconService) {
96 $log = _$log_; 97 $log = _$log_;
97 $compile = _$compile_; 98 $compile = _$compile_;
98 $rootScope = _$rootScope_; 99 $rootScope = _$rootScope_;
99 fs = FnService; 100 fs = FnService;
101 + mast = MastService;
100 is = IconService; 102 is = IconService;
101 })); 103 }));
102 104
...@@ -104,10 +106,18 @@ describe('factory: fw/widget/table.js', function () { ...@@ -104,10 +106,18 @@ describe('factory: fw/widget/table.js', function () {
104 scope = $rootScope.$new(); 106 scope = $rootScope.$new();
105 }); 107 });
106 108
109 + beforeEach(function () {
110 + mockHeader = d3.select('body')
111 + .append('h2')
112 + .style('height', mockh2Height)
113 + .html('Some Header');
114 + });
115 +
107 afterEach(function () { 116 afterEach(function () {
108 table = null; 117 table = null;
109 thead = null; 118 thead = null;
110 tbody = null; 119 tbody = null;
120 + mockHeader.remove();
111 }); 121 });
112 122
113 function compileTable() { 123 function compileTable() {
...@@ -127,11 +137,11 @@ describe('factory: fw/widget/table.js', function () { ...@@ -127,11 +137,11 @@ describe('factory: fw/widget/table.js', function () {
127 } 137 }
128 138
129 function verifyCssDisplay() { 139 function verifyCssDisplay() {
130 - var winHeight = fs.windowSize().height; 140 + var tableHeight = fs.windowSize(pdgTop).height;
131 141
132 expect(thead.css('display')).toBe('block'); 142 expect(thead.css('display')).toBe('block');
133 expect(tbody.css('display')).toBe('block'); 143 expect(tbody.css('display')).toBe('block');
134 - expect(tbody.css('height')).toBe((winHeight - bottomMargin) + 'px'); 144 + expect(tbody.css('height')).toBe(tableHeight + 'px');
135 expect(tbody.css('overflow')).toBe('auto'); 145 expect(tbody.css('overflow')).toBe('auto');
136 } 146 }
137 147
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
18 ONOS GUI -- Topo View -- Topo Filter Service - Unit Tests 18 ONOS GUI -- Topo View -- Topo Filter Service - Unit Tests
19 */ 19 */
20 describe('factory: view/topo/topoFilter.js', function() { 20 describe('factory: view/topo/topoFilter.js', function() {
21 - var $log, fs, fltr, d3Elem, api; 21 + var $log, fs, fltr, api;
22 22
23 var mockNodes = { 23 var mockNodes = {
24 each: function () {}, 24 each: function () {},
...@@ -35,7 +35,6 @@ describe('factory: view/topo/topoFilter.js', function() { ...@@ -35,7 +35,6 @@ describe('factory: view/topo/topoFilter.js', function() {
35 $log = _$log_; 35 $log = _$log_;
36 fs = FnService; 36 fs = FnService;
37 fltr = TopoFilterService; 37 fltr = TopoFilterService;
38 - d3Elem = d3.select('body').append('div').attr('id', 'myMastDiv');
39 38
40 api = { 39 api = {
41 node: function () { return mockNodes; }, 40 node: function () { return mockNodes; },
...@@ -44,7 +43,7 @@ describe('factory: view/topo/topoFilter.js', function() { ...@@ -44,7 +43,7 @@ describe('factory: view/topo/topoFilter.js', function() {
44 })); 43 }));
45 44
46 afterEach(function () { 45 afterEach(function () {
47 - d3.select('#myMastDiv').remove(); 46 +
48 }); 47 });
49 48
50 it('should define TopoFilterService', function () { 49 it('should define TopoFilterService', function () {
...@@ -53,45 +52,16 @@ describe('factory: view/topo/topoFilter.js', function() { ...@@ -53,45 +52,16 @@ describe('factory: view/topo/topoFilter.js', function() {
53 52
54 it('should define api functions', function () { 53 it('should define api functions', function () {
55 expect(fs.areFunctions(fltr, [ 54 expect(fs.areFunctions(fltr, [
56 - 'initFilter', 'destroyFilter', 55 + 'initFilter',
57 - 'clickAction', 'selected', 'inLayer', 56 + 'clickAction', 'selected', 'inLayer'
58 ])).toBeTruthy(); 57 ])).toBeTruthy();
59 }); 58 });
60 59
61 - it('should inject the buttons into the given div', function () {
62 - fltr.initFilter(api, d3Elem);
63 - var grpdiv = d3Elem.select('#topo-radio-group');
64 - expect(grpdiv.size()).toBe(1);
65 -
66 - var btns = grpdiv.selectAll('span');
67 - expect(btns.size()).toBe(3);
68 -
69 - var prefix = 'topo-rb-',
70 - expIds = [ 'all', 'pkt', 'opt' ];
71 -
72 - btns.each(function (d, i) {
73 - var b = d3.select(this);
74 - expect(b.attr('id')).toEqual(prefix + expIds[i]);
75 - // 0th button is active - others are not
76 - expect(b.classed('active')).toEqual(i === 0);
77 - });
78 - });
79 -
80 - it('should remove the buttons from the given div', function () {
81 - fltr.initFilter(api, d3Elem);
82 - var grpdiv = d3Elem.select('#topo-radio-group');
83 - expect(grpdiv.size()).toBe(1);
84 -
85 - fltr.destroyFilter();
86 - grpdiv = d3Elem.select('#topo-radio-group');
87 - expect(grpdiv.size()).toBe(0);
88 - });
89 -
90 it('should report the selected button', function () { 60 it('should report the selected button', function () {
91 - fltr.initFilter(api, d3Elem); 61 + fltr.initFilter(api);
92 expect(fltr.selected()).toEqual('all'); 62 expect(fltr.selected()).toEqual('all');
93 }); 63 });
94 64
95 - // TODO: figure out how to trigger the click function on the spans.. 65 + // TODO: test the on click functions
96 66
97 }); 67 });
......