blob: fc5b5125187c841df1a488091f8efec3f4f4dea6 [file] [log] [blame]
Simon Hunt99ee1e22015-02-13 09:24:43 -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 -- Topo View -- Topo Filter Service - Unit Tests
19 */
20describe('factory: view/topo/topoFilter.js', function() {
Bri Prebilic Coleb5f2b152015-04-07 14:58:09 -070021 var $log, fs, fltr, 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
Simon Hunt2d16fc82015-03-10 20:19:52 -070032 beforeEach(module('ovTopo', 'onosUtil', 'onosLayer', 'ngRoute', 'onosNav'));
Simon Hunt99ee1e22015-02-13 09:24:43 -080033
34 beforeEach(inject(function (_$log_, FnService, TopoFilterService) {
35 $log = _$log_;
36 fs = FnService;
Simon Hunteb0fa052015-02-17 19:20:28 -080037 fltr = TopoFilterService;
Simon Hunteb0fa052015-02-17 19:20:28 -080038
39 api = {
40 node: function () { return mockNodes; },
41 link: function () { return mockLinks; }
42 };
Simon Hunt99ee1e22015-02-13 09:24:43 -080043 }));
44
Simon Hunteb0fa052015-02-17 19:20:28 -080045 afterEach(function () {
Bri Prebilic Coleb5f2b152015-04-07 14:58:09 -070046
Simon Hunteb0fa052015-02-17 19:20:28 -080047 });
48
Simon Hunt99ee1e22015-02-13 09:24:43 -080049 it('should define TopoFilterService', function () {
Simon Hunteb0fa052015-02-17 19:20:28 -080050 expect(fltr).toBeDefined();
Simon Hunt99ee1e22015-02-13 09:24:43 -080051 });
52
53 it('should define api functions', function () {
Simon Hunteb0fa052015-02-17 19:20:28 -080054 expect(fs.areFunctions(fltr, [
Bri Prebilic Coleb5f2b152015-04-07 14:58:09 -070055 'initFilter',
56 'clickAction', 'selected', 'inLayer'
Simon Hunt99ee1e22015-02-13 09:24:43 -080057 ])).toBeTruthy();
58 });
59
Simon Hunteb0fa052015-02-17 19:20:28 -080060 it('should report the selected button', function () {
Bri Prebilic Coleb5f2b152015-04-07 14:58:09 -070061 fltr.initFilter(api);
Simon Hunteb0fa052015-02-17 19:20:28 -080062 expect(fltr.selected()).toEqual('all');
63 });
64
Bri Prebilic Coleb5f2b152015-04-07 14:58:09 -070065 // TODO: test the on click functions
Simon Hunteb0fa052015-02-17 19:20:28 -080066
Simon Hunt99ee1e22015-02-13 09:24:43 -080067});