From e9f6a366e9554fc47d7bd570f0cdbbfe372dd610 Mon Sep 17 00:00:00 2001 From: Georgios Kalpakas Date: Tue, 21 Oct 2014 14:58:06 +0300 Subject: [PATCH] style(filterSpec): fix white-space and newline inconsistencies --- test/ng/filter/filterSpec.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/test/ng/filter/filterSpec.js b/test/ng/filter/filterSpec.js index 1330db8fb9f4..0508a696fc21 100644 --- a/test/ng/filter/filterSpec.js +++ b/test/ng/filter/filterSpec.js @@ -7,6 +7,7 @@ describe('Filter: filter', function() { filter = $filter('filter'); })); + it('should filter by string', function() { var items = ['MIsKO', {name: 'shyam'}, ['adam'], 1234]; expect(filter(items, '').length).toBe(4); @@ -27,6 +28,7 @@ describe('Filter: filter', function() { expect(filter(items, "I don't exist").length).toBe(0); }); + it('should not read $ properties', function() { expect(''.charAt(0)).toBe(''); // assumption @@ -34,6 +36,7 @@ describe('Filter: filter', function() { expect(filter(items, 'misko').length).toBe(0); }); + it('should filter on specific property', function() { var items = [{ignore: 'a', name: 'a'}, {ignore: 'a', name: 'abc'}]; expect(filter(items, {}).length).toBe(2); @@ -44,11 +47,13 @@ describe('Filter: filter', function() { expect(filter(items, {name: 'b'})[0].name).toBe('abc'); }); + it('should take function as predicate', function() { var items = [{name: 'a'}, {name: 'abc', done: true}]; expect(filter(items, function(i) {return i.done;}).length).toBe(1); }); + it('should pass the index to a function predicate', function() { var items = [0, 1, 2, 3]; @@ -59,6 +64,7 @@ describe('Filter: filter', function() { expect(result).toEqual([0, 2]); }); + it('should take object as predicate', function() { var items = [{first: 'misko', last: 'hevery'}, {first: 'adam', last: 'abrons'}]; @@ -103,10 +109,11 @@ describe('Filter: filter', function() { expect(filter(items, {$: 'hevery'})[0]).toEqual(items[0]); }); + it('should support boolean properties', function() { var items = [{name: 'tom', current: true}, - {name: 'demi', current: false}, - {name: 'sofia'}]; + {name: 'demi', current: false}, + {name: 'sofia'}]; expect(filter(items, {current:true}).length).toBe(1); expect(filter(items, {current:true})[0].name).toBe('tom'); @@ -114,6 +121,7 @@ describe('Filter: filter', function() { expect(filter(items, {current:false})[0].name).toBe('demi'); }); + it('should support negation operator', function() { var items = ['misko', 'adam']; @@ -133,8 +141,8 @@ describe('Filter: filter', function() { {key: 'value1', nonkey: 1}, {key: 'value2', nonkey: 2}, {key: 'value12', nonkey: 3}, - {key: 'value1', nonkey:4}, - {key: 'Value1', nonkey:5} + {key: 'value1', nonkey: 4}, + {key: 'Value1', nonkey: 5} ]; expr = {key: 'value1'}; expect(filter(items, expr, true)).toEqual([items[0], items[3]]); @@ -143,21 +151,22 @@ describe('Filter: filter', function() { {key: 1, nonkey: 1}, {key: 2, nonkey: 2}, {key: 12, nonkey: 3}, - {key: 1, nonkey:4} + {key: 1, nonkey: 4} ]; - expr = { key: 1 }; + expr = {key: 1}; expect(filter(items, expr, true)).toEqual([items[0], items[3]]); expr = 12; expect(filter(items, expr, true)).toEqual([items[2]]); }); + it('and use the function given to compare values', function() { var items = [ {key: 1, nonkey: 1}, {key: 2, nonkey: 2}, {key: 12, nonkey: 3}, - {key: 1, nonkey:14} + {key: 1, nonkey: 14} ]; var expr = {key: 10}; var comparator = function(obj, value) { @@ -167,10 +176,6 @@ describe('Filter: filter', function() { expr = 10; expect(filter(items, expr, comparator)).toEqual([items[2], items[3]]); - }); - - }); - });