Skip to content

Commit 9613938

Browse files
committed
fix(filterFilter): test for pull request
fix(filterFilter): solve issue angular#10991 with null property value when using objects with filter : test
1 parent 030a42e commit 9613938

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/ng/filter/filterSpec.js

+26
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,32 @@ describe('Filter: filter', function() {
428428
});
429429

430430

431+
it ('should not throw an error if property is null when comparing object', function() {
432+
var items = [
433+
{ office:1, people: {name:'john'}},
434+
{ office:2, people: {name:'jane'}},
435+
{ office:3, people: null}
436+
];
437+
var f = { };
438+
expect(filter(items, f).length).toBe(3);
439+
440+
f = { people:null };
441+
expect(filter(items, f).length).toBe(3);
442+
443+
//should throw an error in 1.3.12
444+
f = { people:{ name:'john' }};
445+
expect(filter(items, f).length).toBe(1);
446+
447+
//should throw an error in 1.3.12
448+
f = { people:{ name:'j' }};
449+
expect(filter(items, f).length).toBe(2);
450+
451+
//should throw an error in 1.3.12
452+
f = { people:{ name: '' }};
453+
expect(filter(items, f).length).toBe(2);
454+
455+
});
456+
431457
describe('should support comparator', function() {
432458

433459
it('not consider `object === "[object Object]"` in non-strict comparison', function() {

0 commit comments

Comments
 (0)