mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-01-12 22:45:52 +08:00
test(filter): test expression object with inherited properties
Related to #9984
This commit is contained in:
committed by
Caitlin Potter
parent
f7cf846045
commit
a631a759d2
@@ -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':
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user