Simon Hunt

GUI -- Added unit tests for FnService.find().

Change-Id: I17ec1abe4024c761b2f88f03e783eeb1e55f24e9
...@@ -197,7 +197,7 @@ describe('factory: fw/util/fn.js', function() { ...@@ -197,7 +197,7 @@ describe('factory: fw/util/fn.js', function() {
197 }, ['a', 'b'])).toBeTruthy(); 197 }, ['a', 'b'])).toBeTruthy();
198 }); 198 });
199 199
200 - // == use the now-tested areFunctions on our own api: 200 + // == use the now-tested areFunctions() on our own api:
201 it('should define api functions', function () { 201 it('should define api functions', function () {
202 expect(fs.areFunctions(fs, [ 202 expect(fs.areFunctions(fs, [
203 'isF', 'isA', 'isS', 'isO', 'contains', 203 'isF', 'isA', 'isS', 'isO', 'contains',
...@@ -206,8 +206,6 @@ describe('factory: fw/util/fn.js', function() { ...@@ -206,8 +206,6 @@ describe('factory: fw/util/fn.js', function() {
206 }); 206 });
207 207
208 208
209 -
210 -
211 // === Tests for windowSize() 209 // === Tests for windowSize()
212 it('windowSize(): noargs', function () { 210 it('windowSize(): noargs', function () {
213 var dim = fs.windowSize(); 211 var dim = fs.windowSize();
...@@ -233,6 +231,33 @@ describe('factory: fw/util/fn.js', function() { ...@@ -233,6 +231,33 @@ describe('factory: fw/util/fn.js', function() {
233 expect(dim.height).toEqual(99); 231 expect(dim.height).toEqual(99);
234 }); 232 });
235 233
236 - // TODO: write unit tests for find()
237 234
235 + // === Tests for find()
236 + var dataset = [
237 + { id: 'foo', name: 'Furby'},
238 + { id: 'bar', name: 'Barbi'},
239 + { id: 'baz', name: 'Basil'},
240 + { id: 'goo', name: 'Gabby'},
241 + { id: 'zoo', name: 'Zevvv'}
242 + ];
243 +
244 + it('should not find ooo', function () {
245 + expect(fs.find('ooo', dataset)).toEqual(-1);
246 + });
247 + it('should find foo', function () {
248 + expect(fs.find('foo', dataset)).toEqual(0);
249 + });
250 + it('should find zoo', function () {
251 + expect(fs.find('zoo', dataset)).toEqual(4);
252 + });
253 +
254 + it('should not find Simon', function () {
255 + expect(fs.find('Simon', dataset, 'name')).toEqual(-1);
256 + });
257 + it('should find Furby', function () {
258 + expect(fs.find('Furby', dataset, 'name')).toEqual(0);
259 + });
260 + it('should find Zevvv', function () {
261 + expect(fs.find('Zevvv', dataset, 'name')).toEqual(4);
262 + });
238 }); 263 });
......