blob: 4bd1b4a161a8c8086b2c7ce246a5e12891d62212 [file] [log] [blame]
Simon Huntf3069722014-12-16 18:15:37 -08001/*
2 * Copyright 2014 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 -- General Purpose Functions - Unit Tests
19
20 @author Simon Hunt
21 */
22describe('factory: fw/lib/fn.js', function() {
23 var fs,
24 someFunction = function () {},
25 someArray = [1, 2, 3],
26 someObject = { foo: 'bar'},
27 someNumber = 42,
28 someString = 'xyyzy',
29 someDate = new Date();
30
31 beforeEach(module('onosApp'));
32
33 beforeEach(inject(function (FnService) {
34 fs = FnService;
35 }));
36
37 it('should have ONOS defined', function () {
38 expect(ONOS).toBeDefined();
39 });
40
41 it('should have FnService defined', function () {
42 expect(fs).toBeDefined();
43 });
44
45
46 // === Tests for isF()
47 it('isF(): null for undefined', function () {
48 expect(fs.isF(undefined)).toBeNull();
49 });
50 it('isF(): null for null', function () {
51 expect(fs.isF(null)).toBeNull();
52 });
53 it('isF(): the reference for function', function () {
54 expect(fs.isF(someFunction)).toBe(someFunction);
55 });
56 it('isF(): null for string', function () {
57 expect(fs.isF(someString)).toBeNull();
58 });
59 it('isF(): null for number', function () {
60 expect(fs.isF(someNumber)).toBeNull();
61 });
62 it('isF(): null for Date', function () {
63 expect(fs.isF(someDate)).toBeNull();
64 });
65 it('isF(): null for array', function () {
66 expect(fs.isF(someArray)).toBeNull();
67 });
68 it('isF(): null for object', function () {
69 expect(fs.isF(someObject)).toBeNull();
70 });
71
72
73 // === Tests for isA()
74 it('isA(): null for undefined', function () {
75 expect(fs.isA(undefined)).toBeNull();
76 });
77 it('isA(): null for null', function () {
78 expect(fs.isA(null)).toBeNull();
79 });
80 it('isA(): null for function', function () {
81 expect(fs.isA(someFunction)).toBeNull();
82 });
83 it('isA(): null for string', function () {
84 expect(fs.isA(someString)).toBeNull();
85 });
86 it('isA(): null for number', function () {
87 expect(fs.isA(someNumber)).toBeNull();
88 });
89 it('isA(): null for Date', function () {
90 expect(fs.isA(someDate)).toBeNull();
91 });
92 it('isA(): the reference for array', function () {
93 expect(fs.isA(someArray)).toBe(someArray);
94 });
95 it('isA(): null for object', function () {
96 expect(fs.isA(someObject)).toBeNull();
97 });
98
99
100 // === Tests for isS()
101 it('isS(): null for undefined', function () {
102 expect(fs.isS(undefined)).toBeNull();
103 });
104 it('isS(): null for null', function () {
105 expect(fs.isS(null)).toBeNull();
106 });
107 it('isS(): null for function', function () {
108 expect(fs.isS(someFunction)).toBeNull();
109 });
110 it('isS(): the reference for string', function () {
111 expect(fs.isS(someString)).toBe(someString);
112 });
113 it('isS(): null for number', function () {
114 expect(fs.isS(someNumber)).toBeNull();
115 });
116 it('isS(): null for Date', function () {
117 expect(fs.isS(someDate)).toBeNull();
118 });
119 it('isS(): null for array', function () {
120 expect(fs.isS(someArray)).toBeNull();
121 });
122 it('isS(): null for object', function () {
123 expect(fs.isS(someObject)).toBeNull();
124 });
125
126
127 // === Tests for isO()
128 it('isO(): null for undefined', function () {
129 expect(fs.isO(undefined)).toBeNull();
130 });
131 it('isO(): null for null', function () {
132 expect(fs.isO(null)).toBeNull();
133 });
134 it('isO(): null for function', function () {
135 expect(fs.isO(someFunction)).toBeNull();
136 });
137 it('isO(): null for string', function () {
138 expect(fs.isO(someString)).toBeNull();
139 });
140 it('isO(): null for number', function () {
141 expect(fs.isO(someNumber)).toBeNull();
142 });
143 it('isO(): null for Date', function () {
144 expect(fs.isO(someDate)).toBeNull();
145 });
146 it('isO(): null for array', function () {
147 expect(fs.isO(someArray)).toBeNull();
148 });
149 it('isO(): the reference for object', function () {
150 expect(fs.isO(someObject)).toBe(someObject);
151 });
152});