blob: f5a8cef808f813db2ed0cc07a6ce3a9b2a513377 [file] [log] [blame]
Bri Prebilic Cole54d09382015-03-19 18:40:27 -07001/*
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 -- Tooltip Service - Unit Tests
19 */
20describe('factory: fw/widget/tooltip.js', function () {
21 var $log, fs, tts, d3Elem;
22
23 beforeEach(module('onosWidget', 'onosUtil'));
24
25 beforeEach(inject(function (_$log_, FnService, TooltipService) {
26 $log = _$log_;
27 fs = FnService;
28 tts = TooltipService;
29 }));
30
31 beforeEach(function () {
32 d3Elem = d3.select('body').append('div').attr('id', 'tooltip');
33 });
34
35 afterEach(function () {
36 d3.select('#tooltip').remove();
37 });
38
39 it('should define TooltipService', function () {
40 expect(tts).toBeDefined();
41 });
42
43 it('should define api functions', function () {
44 expect(fs.areFunctions(tts, [
45 'showTooltip', 'cancelTooltip'
46 ])).toBeTruthy();
47 });
48
49 it('should not accept undefined arguments', function () {
50 var btn = d3.select('body').append('div');
51 expect(tts.showTooltip()).toBeFalsy();
52 expect(tts.showTooltip(btn)).toBeFalsy();
53
54 expect(tts.cancelTooltip()).toBeFalsy();
55 });
56
57 // testing mouse events is tough
58
59 xit('should show a tooltip', function () {
60 var btn = d3.select('body').append('div').attr('id', 'foo');
61 // each is used to trigger a "mouse" event, providing this, d, and i
62 btn.each(function () {
63 tts.showTooltip(this, 'yay a tooltip');
64 });
65 });
66});