blob: 7217cc5eba4c5d41dfd2d6dd916e6460dc3f1793 [file] [log] [blame]
Simon Hunt99ee1e22015-02-13 09:24:43 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Simon Hunt99ee1e22015-02-13 09:24:43 -08003 *
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 -- Topo View -- Topo Filter Service - Unit Tests
19 */
20describe('factory: view/topo/topoFilter.js', function() {
Bri Prebilic Colef5e48b12015-04-21 14:52:36 -070021 var $log, fs, fltr, bns, api;
Simon Hunteb0fa052015-02-17 19:20:28 -080022
23 var mockNodes = {
24 each: function () {},
25 classed: function () {}
26 },
27 mockLinks = {
28 each: function () {},
29 classed: function () {}
30 };
Simon Hunt99ee1e22015-02-13 09:24:43 -080031
Bri Prebilic Colef5e48b12015-04-21 14:52:36 -070032 beforeEach(module('ovTopo', 'onosUtil', 'onosLayer', 'ngRoute', 'onosNav',
Matteo Scandolo812aa5a2016-04-19 18:12:45 -070033 'onosWidget', 'onosMast'));
Simon Hunt99ee1e22015-02-13 09:24:43 -080034
Bri Prebilic Colef5e48b12015-04-21 14:52:36 -070035 beforeEach(inject(function (_$log_, FnService,
36 TopoFilterService, ButtonService) {
Simon Hunt99ee1e22015-02-13 09:24:43 -080037 $log = _$log_;
38 fs = FnService;
Simon Hunteb0fa052015-02-17 19:20:28 -080039 fltr = TopoFilterService;
Bri Prebilic Colef5e48b12015-04-21 14:52:36 -070040 bns = ButtonService;
Simon Hunteb0fa052015-02-17 19:20:28 -080041
42 api = {
43 node: function () { return mockNodes; },
44 link: function () { return mockLinks; }
45 };
Simon Hunt99ee1e22015-02-13 09:24:43 -080046 }));
47
Simon Hunteb0fa052015-02-17 19:20:28 -080048 afterEach(function () {
Bri Prebilic Coleb5f2b152015-04-07 14:58:09 -070049
Simon Hunteb0fa052015-02-17 19:20:28 -080050 });
51
Simon Hunt99ee1e22015-02-13 09:24:43 -080052 it('should define TopoFilterService', function () {
Simon Hunteb0fa052015-02-17 19:20:28 -080053 expect(fltr).toBeDefined();
Simon Hunt99ee1e22015-02-13 09:24:43 -080054 });
55
56 it('should define api functions', function () {
Simon Hunteb0fa052015-02-17 19:20:28 -080057 expect(fs.areFunctions(fltr, [
Bri Prebilic Coleb5f2b152015-04-07 14:58:09 -070058 'initFilter',
59 'clickAction', 'selected', 'inLayer'
Simon Hunt99ee1e22015-02-13 09:24:43 -080060 ])).toBeTruthy();
61 });
62
Simon Hunteb0fa052015-02-17 19:20:28 -080063 it('should report the selected button', function () {
Bri Prebilic Coleb5f2b152015-04-07 14:58:09 -070064 fltr.initFilter(api);
Simon Hunteb0fa052015-02-17 19:20:28 -080065 expect(fltr.selected()).toEqual('all');
66 });
67
Bri Prebilic Coleb5f2b152015-04-07 14:58:09 -070068 // TODO: test the on click functions
Simon Hunteb0fa052015-02-17 19:20:28 -080069
Simon Hunt99ee1e22015-02-13 09:24:43 -080070});