diff options
| author | RoyLING | 2014-01-05 15:51:04 +0800 |
|---|---|---|
| committer | Igor Minar | 2014-01-05 00:36:04 -0800 |
| commit | e0ce9ed36d9b8c1858e4f928b61d21d7d4c023b8 (patch) | |
| tree | dd40a8d83bf1597cdbf78ac3963745c6721488d0 /test | |
| parent | caeb7402651702cd13df2f1594e9827439a8b760 (diff) | |
| download | angular.js-e0ce9ed36d9b8c1858e4f928b61d21d7d4c023b8.tar.bz2 | |
refactor(filterFilter): simplify code by a ternary op instead of if-else
- use only one IIFE and a ternary op in it, instead of invoking separate IIFEs in if-else
(this also completely fixed the same issue closed by PR #3597)
- also add a spec to verify usage of '$' property in expression object (e.g. `{$: 'a'}`)
Closes #5637
Diffstat (limited to 'test')
| -rw-r--r-- | test/ng/filter/filterSpec.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ng/filter/filterSpec.js b/test/ng/filter/filterSpec.js index 881cefab..cab24ec5 100644 --- a/test/ng/filter/filterSpec.js +++ b/test/ng/filter/filterSpec.js @@ -60,6 +60,17 @@ describe('Filter: filter', function() { expect(filter(items, {first:'misko', last:'hevery'})[0]).toEqual(items[0]); }); + it('should match any properties for given "$" property', function() { + var items = [{first: 'tom', last: 'hevery'}, + {first: 'adam', last: 'hevery', alias: 'tom', done: false}, + {first: 'john', last: 'clark', middle: 'tommy'}]; + expect(filter(items, {$: 'tom'}).length).toBe(3); + expect(filter(items, {$: 'a'}).length).toBe(2); + expect(filter(items, {$: false}).length).toBe(1); + expect(filter(items, {$: 10}).length).toBe(0); + expect(filter(items, {$: 'hevery'})[0]).toEqual(items[0]); + }); + it('should support boolean properties', function() { var items = [{name: 'tom', current: true}, {name: 'demi', current: false}, |
