test(filter): test expression object with inherited properties

Related to #9984
This commit is contained in:
Georgios Kalpakas
2014-11-11 13:29:19 +02:00
committed by Caitlin Potter
parent f7cf846045
commit a631a759d2
2 changed files with 21 additions and 1 deletions

View File

@@ -125,7 +125,7 @@ function filterFilter() {
case 'object':
// Replace `{$: 'xyz'}` with `'xyz'` and fall through
var keys = Object.keys(expression);
if ((keys.length === 1) && (keys[0] === '$')) expression = expression.$;
if ((keys.length === 1) && (keys[0] === '$')) expression = expression.$;
// jshint -W086
case 'boolean':
case 'number':

View File

@@ -156,6 +156,26 @@ describe('Filter: filter', function() {
});
it('should not consider the expression\'s inherited properties', function() {
Object.prototype.noop = noop;
var items = [
{text: 'hello'},
{text: 'goodbye'},
{text: 'kittens'},
{text: 'puppies'}
];
expect(filter(items, {text: 'hell'}).length).toBe(1);
expect(filter(items, {text: 'hell'})[0]).toBe(items[0]);
expect(filter(items, 'hell').length).toBe(1);
expect(filter(items, 'hell')[0]).toBe(items[0]);
delete(Object.prototype.noop);
});
describe('should support comparator', function() {
it('as equality when true', function() {