fix(filter): filter on false properties

Code was evaluating !expression[key] while attempting to
see if the key was present, but this was evaluating to true for
false values as well as missing keys.

Closes #2797.
This commit is contained in:
Tom Dunstan
2013-08-15 09:33:32 +09:30
committed by Vojta Jina
parent 3a65822023
commit 3bc4e7fd20
2 changed files with 12 additions and 1 deletions

View File

@@ -60,6 +60,17 @@ describe('Filter: filter', function() {
expect(filter(items, {first:'misko', last:'hevery'})[0]).toEqual(items[0]);
});
it('should support boolean properties', function() {
var items = [{name: 'tom', current: true},
{name: 'demi', current: false},
{name: 'sofia'}];
expect(filter(items, {current:true}).length).toBe(1);
expect(filter(items, {current:true})[0].name).toBe('tom');
expect(filter(items, {current:false}).length).toBe(1);
expect(filter(items, {current:false})[0].name).toBe('demi');
});
it('should support negation operator', function() {
var items = ['misko', 'adam'];