blob: 0a3fcb669038a8c4554b2a1350ea1dbc1f915e7b [file] [log] [blame]
Bri Prebilic Cole093739a2015-01-23 10:22:50 -08001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 ONOS GUI -- Widget -- Table Service - Unit Tests
19 */
Bri Prebilic Colee1bda3f2015-02-13 17:01:49 -080020describe('factory: fw/widget/table.js', function () {
21 var $log, $compile, $rootScope,
22 fs, is,
23 table;
Bri Prebilic Coleaa8d2ed2015-01-23 16:53:29 -080024
Bri Prebilic Colee1bda3f2015-02-13 17:01:49 -080025 var onosFixedHeaderTags = '<table ' +
26 'onos-fixed-header ' +
27 'ng-style="setTableHW()">' +
28 '<thead>' +
29 '<tr>' +
30 '<th></th>' +
31 '<th>Device ID </th>' +
32 '<th>H/W Version </th>' +
33 '<th>S/W Version </th>' +
34 '</tr>' +
35 '</thead>' +
36 '<tbody>' +
37 '<tr>' +
38 '<td>' +
39 '<div icon icon-id="{{dev._iconid_available}}">' +
40 '</div>' +
41 '</td>' +
42 '<td>Some ID</td>' +
43 '<td>Some HW</td>' +
44 '<td>Some Software</td>' +
45 '</tr>' +
46 '</tbody>' +
47 '</table>',
Bri Prebilic Cole093739a2015-01-23 10:22:50 -080048
Bri Prebilic Colee1bda3f2015-02-13 17:01:49 -080049 onosSortableHeaderTags = '<table class="summary-list" ' +
50 'onos-sortable-header ' +
51 'sort-callback="sortCallback(urlSuffix)">' +
52 '<thead>' +
53 '<tr>' +
54 '<th colId="available"></th>' +
55 '<th colId="id" sortable>Device ID </th>' +
56 '<th colId="hw" sortable>H/W Version </th>' +
57 '<th colId="sw" sortable>S/W Version </th>' +
58 '</tr>' +
59 '</thead>' +
60 '<tbody>' +
61 '<tr>' +
62 '<td>' +
63 '<div icon icon-id="{{dev._iconid_available}}">' +
64 '</div>' +
65 '</td>' +
66 '<td>Some ID</td>' +
67 '<td>Some HW</td>' +
68 '<td>Some Software</td>' +
69 '</tr>' +
70 '</tbody>' +
71 '</table>';
Bri Prebilic Cole093739a2015-01-23 10:22:50 -080072
Bri Prebilic Colee1bda3f2015-02-13 17:01:49 -080073 beforeEach(module('onosWidget', 'onosUtil', 'onosSvg'));
74
75 beforeEach(inject(function (_$log_, _$compile_, _$rootScope_,
76 FnService, IconService) {
Bri Prebilic Cole093739a2015-01-23 10:22:50 -080077 $log = _$log_;
Bri Prebilic Colee1bda3f2015-02-13 17:01:49 -080078 $compile = _$compile_;
79 $rootScope = _$rootScope_;
80 fs = FnService;
81 is = IconService;
Bri Prebilic Cole093739a2015-01-23 10:22:50 -080082 }));
83
Bri Prebilic Colee1bda3f2015-02-13 17:01:49 -080084 beforeEach(function () {
85 });
86
Simon Huntc4ae8302015-01-26 14:22:48 -080087 afterEach(function () {
Bri Prebilic Colee1bda3f2015-02-13 17:01:49 -080088 table = null;
Simon Huntc4ae8302015-01-26 14:22:48 -080089 });
90
Bri Prebilic Colee1bda3f2015-02-13 17:01:49 -080091 it('should affirm that onos-fixed-header is working', function () {
92 table = $compile(onosFixedHeaderTags)($rootScope);
93 $rootScope.$digest();
94
95 table = d3.select(table);
96 expect(table).toBeDefined();
97
98 //expect(table.select('thead').style('display')).toBe('block');
Bri Prebilic Cole093739a2015-01-23 10:22:50 -080099 });
Bri Prebilic Coleaa8d2ed2015-01-23 16:53:29 -0800100
Bri Prebilic Colee1bda3f2015-02-13 17:01:49 -0800101 it('should affirm that onos-sortable-header is working', function () {
102 table = $compile(onosSortableHeaderTags)($rootScope);
103 $rootScope.$digest();
Bri Prebilic Coleaa8d2ed2015-01-23 16:53:29 -0800104
Bri Prebilic Colee1bda3f2015-02-13 17:01:49 -0800105 table = d3.select(table);
106 expect(table).toBeDefined();
Bri Prebilic Coleaa8d2ed2015-01-23 16:53:29 -0800107 });
108
Bri Prebilic Colee1bda3f2015-02-13 17:01:49 -0800109 // TODO: write directive unit tests for table.js
Bri Prebilic Coleaa8d2ed2015-01-23 16:53:29 -0800110});