GUI -- Jasmine Unit Tests for fn.js.
Change-Id: I8a187dd04413329e6ab2884319deddc25344e3a0
Showing
4 changed files
with
169 additions
and
5 deletions
web/gui/src/main/webapp/tests/README.txt
0 → 100644
1 | +# Unit and integration tests for code under the /app directory |
web/gui/src/main/webapp/tests/e2e/README.txt
0 → 100644
1 | +/* | ||
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 | + */ | ||
22 | +describe('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 | +}); |
1 | // Karma configuration | 1 | // Karma configuration |
2 | -// Generated on Tue Dec 09 2014 10:41:03 GMT-0800 (PST) | ||
3 | 2 | ||
4 | module.exports = function(config) { | 3 | module.exports = function(config) { |
5 | config.set({ | 4 | config.set({ |
... | @@ -15,10 +14,20 @@ module.exports = function(config) { | ... | @@ -15,10 +14,20 @@ module.exports = function(config) { |
15 | 14 | ||
16 | // list of files / patterns to load in the browser | 15 | // list of files / patterns to load in the browser |
17 | files: [ | 16 | files: [ |
18 | - '../../main/webapp/tp/angular.min.js', | 17 | + // library code... |
19 | - '../../main/webapp/tp/angular-mocks.js', | 18 | + '../tp/angular.js', |
20 | - '../../main/webapp/_sdh/ng-examples/js/*.js', | 19 | + '../tp/angular-mocks.js', |
21 | - '../webapp/_sdh/ng-examples/js/*.js' | 20 | + '../tp/d3.js', |
21 | + '../tp/topojson.v1.min.js', | ||
22 | + '../tp/jquery-2.1.1.min.js', | ||
23 | + | ||
24 | + // production code... | ||
25 | + '../app/onos.js', | ||
26 | + '../app/fw/lib/*.js', | ||
27 | + '../app/fw/mast/*.js', | ||
28 | + | ||
29 | + // unit test code... | ||
30 | + 'fw/lib/*.js' | ||
22 | ], | 31 | ], |
23 | 32 | ||
24 | 33 | ... | ... |
-
Please register or login to post a comment