Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1dd46d4

Browse files
committedMay 2, 2014
Added more tests for the current implementation of filterFilter, which prove that _deeply-nested_ predicate objects + _multiple conditions_ was not tested well enough, since some expected scenarios fail.
Problem: `filterFilter` is currently behaving like if it was using _OR_ operators (i.e. it doesn't matter if some conditions don't match as long as one does), and should be behaving like if it used _AND_ operators in order to be consistent with the original implementation for non-deeply-nested predicate objects. `filterFilter` working with deeply-nested predicate objects was introduced in 1.2.13 as a result of angular#6215.
1 parent 69d96e8 commit 1dd46d4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎test/ng/filter/filterSpec.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,17 @@ describe('Filter: filter', function() {
7474
var items = [{person: {name: 'John'}},
7575
{person: {name: 'Rita'}},
7676
{person: {name: 'Billy'}},
77-
{person: {name: 'Joan'}}];
77+
{person: {name: 'Joan'}},
78+
{person: {name: 'Albert', surname: 'Boada', contact: {country: 'Catalunya'}}}];
7879
expect(filter(items, {person: {name: 'Jo'}}).length).toBe(2);
7980
expect(filter(items, {person: {name: 'Jo'}})).toEqual([
8081
{person: {name: 'John'}}, {person: {name: 'Joan'}}
8182
]);
83+
expect(filter(items, {person: {name: 'Al', surname: 'Bo'}})).toEqual([items[4]]);
84+
expect(filter(items, {person: {name: 'foo', surname: 'Bo'}}).length).toBe(0);
85+
expect(filter(items, {person: {name: 'Al', surname: 'foo'}}).length).toBe(0);
86+
expect(filter(items, {person: {name: 'Al', contact: {country: 'cat'}}})).toEqual([items[4]]);
87+
expect(filter(items, {person: {name: 'Al', contact: {country: 'foo'}}}).length).toBe(0);
8288
});
8389

8490

0 commit comments

Comments
 (0)
Please sign in to comment.