Bri Prebilic Cole | 093739a | 2015-01-23 10:22:50 -0800 | [diff] [blame] | 1 | /* |
| 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 Cole | e1bda3f | 2015-02-13 17:01:49 -0800 | [diff] [blame^] | 20 | describe('factory: fw/widget/table.js', function () { |
| 21 | var $log, $compile, $rootScope, |
| 22 | fs, is, |
| 23 | table; |
Bri Prebilic Cole | aa8d2ed | 2015-01-23 16:53:29 -0800 | [diff] [blame] | 24 | |
Bri Prebilic Cole | e1bda3f | 2015-02-13 17:01:49 -0800 | [diff] [blame^] | 25 | 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 Cole | 093739a | 2015-01-23 10:22:50 -0800 | [diff] [blame] | 48 | |
Bri Prebilic Cole | e1bda3f | 2015-02-13 17:01:49 -0800 | [diff] [blame^] | 49 | 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 Cole | 093739a | 2015-01-23 10:22:50 -0800 | [diff] [blame] | 72 | |
Bri Prebilic Cole | e1bda3f | 2015-02-13 17:01:49 -0800 | [diff] [blame^] | 73 | beforeEach(module('onosWidget', 'onosUtil', 'onosSvg')); |
| 74 | |
| 75 | beforeEach(inject(function (_$log_, _$compile_, _$rootScope_, |
| 76 | FnService, IconService) { |
Bri Prebilic Cole | 093739a | 2015-01-23 10:22:50 -0800 | [diff] [blame] | 77 | $log = _$log_; |
Bri Prebilic Cole | e1bda3f | 2015-02-13 17:01:49 -0800 | [diff] [blame^] | 78 | $compile = _$compile_; |
| 79 | $rootScope = _$rootScope_; |
| 80 | fs = FnService; |
| 81 | is = IconService; |
Bri Prebilic Cole | 093739a | 2015-01-23 10:22:50 -0800 | [diff] [blame] | 82 | })); |
| 83 | |
Bri Prebilic Cole | e1bda3f | 2015-02-13 17:01:49 -0800 | [diff] [blame^] | 84 | beforeEach(function () { |
| 85 | }); |
| 86 | |
Simon Hunt | c4ae830 | 2015-01-26 14:22:48 -0800 | [diff] [blame] | 87 | afterEach(function () { |
Bri Prebilic Cole | e1bda3f | 2015-02-13 17:01:49 -0800 | [diff] [blame^] | 88 | table = null; |
Simon Hunt | c4ae830 | 2015-01-26 14:22:48 -0800 | [diff] [blame] | 89 | }); |
| 90 | |
Bri Prebilic Cole | e1bda3f | 2015-02-13 17:01:49 -0800 | [diff] [blame^] | 91 | 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 Cole | 093739a | 2015-01-23 10:22:50 -0800 | [diff] [blame] | 99 | }); |
Bri Prebilic Cole | aa8d2ed | 2015-01-23 16:53:29 -0800 | [diff] [blame] | 100 | |
Bri Prebilic Cole | e1bda3f | 2015-02-13 17:01:49 -0800 | [diff] [blame^] | 101 | it('should affirm that onos-sortable-header is working', function () { |
| 102 | table = $compile(onosSortableHeaderTags)($rootScope); |
| 103 | $rootScope.$digest(); |
Bri Prebilic Cole | aa8d2ed | 2015-01-23 16:53:29 -0800 | [diff] [blame] | 104 | |
Bri Prebilic Cole | e1bda3f | 2015-02-13 17:01:49 -0800 | [diff] [blame^] | 105 | table = d3.select(table); |
| 106 | expect(table).toBeDefined(); |
Bri Prebilic Cole | aa8d2ed | 2015-01-23 16:53:29 -0800 | [diff] [blame] | 107 | }); |
| 108 | |
Bri Prebilic Cole | e1bda3f | 2015-02-13 17:01:49 -0800 | [diff] [blame^] | 109 | // TODO: write directive unit tests for table.js |
Bri Prebilic Cole | aa8d2ed | 2015-01-23 16:53:29 -0800 | [diff] [blame] | 110 | }); |