Simon Hunt | 639dc66 | 2015-02-18 14:19:20 -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 -- Layer -- Flash Service - Unit Tests |
| 19 | */ |
| 20 | describe('factory: fw/layer/quickhelp.js', function () { |
| 21 | var $log, $timeout, fs, qhs, d3Elem; |
| 22 | |
| 23 | beforeEach(module('onosUtil', 'onosSvg', 'onosLayer')); |
| 24 | |
| 25 | beforeEach(inject(function (_$log_, _$timeout_, FnService, QuickHelpService) { |
| 26 | $log = _$log_; |
| 27 | //$timeout = _$timeout_; |
| 28 | fs = FnService; |
| 29 | qhs = QuickHelpService; |
| 30 | //jasmine.clock().install(); |
| 31 | d3Elem = d3.select('body').append('div').attr('id', 'myqhdiv'); |
| 32 | })); |
| 33 | |
| 34 | afterEach(function () { |
| 35 | //jasmine.clock().uninstall(); |
| 36 | d3.select('#myqhdiv').remove(); |
| 37 | }); |
| 38 | |
| 39 | function helpItemSelection() { |
| 40 | return d3Elem.selectAll('.help'); |
| 41 | } |
| 42 | |
| 43 | it('should define QuickHelpService', function () { |
| 44 | expect(qhs).toBeDefined(); |
| 45 | }); |
| 46 | |
| 47 | it('should define api functions', function () { |
| 48 | expect(fs.areFunctions(qhs, [ |
| 49 | 'initQuickHelp', 'showQuickHelp', 'hideQuickHelp' |
| 50 | ])).toBeTruthy(); |
| 51 | }); |
| 52 | |
| 53 | it('should have no items to start', function () { |
| 54 | expect(helpItemSelection().size()).toBe(0); |
| 55 | }); |
| 56 | |
| 57 | // TODO: check that the help stuff appears |
| 58 | /* |
| 59 | it('should show help items', function () { |
| 60 | var item, rect, text; |
| 61 | flash.flash('foo'); |
| 62 | //jasmine.clock().tick(101); |
| 63 | setTimeout(function () { |
| 64 | item = flashItemSelection(); |
| 65 | expect(item.size()).toEqual(1); |
| 66 | expect(item.classed('flashItem')).toBeTruthy(); |
| 67 | expect(item.select('rect').size()).toEqual(1); |
| 68 | text = item.select('text'); |
| 69 | expect(text.size()).toEqual(1); |
| 70 | expect(text.text()).toEqual('foo'); |
| 71 | }, 100); |
| 72 | }); |
| 73 | */ |
| 74 | }); |
| 75 | |