mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-01-12 22:45:52 +08:00
style(filterSpec): fix white-space and newline inconsistencies
Closes #9765
This commit is contained in:
committed by
Caitlin Potter
parent
3b3d9218e8
commit
7574dd25d9
@@ -7,6 +7,7 @@ describe('Filter: filter', function() {
|
||||
filter = $filter('filter');
|
||||
}));
|
||||
|
||||
|
||||
it('should filter by string', function() {
|
||||
var items = ['MIsKO', {name: 'shyam'}, ['adam'], 1234];
|
||||
expect(filter(items, '').length).toBe(4);
|
||||
@@ -27,6 +28,7 @@ describe('Filter: filter', function() {
|
||||
expect(filter(items, "I don't exist").length).toBe(0);
|
||||
});
|
||||
|
||||
|
||||
it('should not read $ properties', function() {
|
||||
expect(''.charAt(0)).toBe(''); // assumption
|
||||
|
||||
@@ -34,6 +36,7 @@ describe('Filter: filter', function() {
|
||||
expect(filter(items, 'misko').length).toBe(0);
|
||||
});
|
||||
|
||||
|
||||
it('should filter on specific property', function() {
|
||||
var items = [{ignore: 'a', name: 'a'}, {ignore: 'a', name: 'abc'}];
|
||||
expect(filter(items, {}).length).toBe(2);
|
||||
@@ -44,11 +47,13 @@ describe('Filter: filter', function() {
|
||||
expect(filter(items, {name: 'b'})[0].name).toBe('abc');
|
||||
});
|
||||
|
||||
|
||||
it('should take function as predicate', function() {
|
||||
var items = [{name: 'a'}, {name: 'abc', done: true}];
|
||||
expect(filter(items, function(i) {return i.done;}).length).toBe(1);
|
||||
});
|
||||
|
||||
|
||||
it('should pass the index to a function predicate', function() {
|
||||
var items = [0, 1, 2, 3];
|
||||
|
||||
@@ -59,6 +64,7 @@ describe('Filter: filter', function() {
|
||||
expect(result).toEqual([0, 2]);
|
||||
});
|
||||
|
||||
|
||||
it('should take object as predicate', function() {
|
||||
var items = [{first: 'misko', last: 'hevery'},
|
||||
{first: 'adam', last: 'abrons'}];
|
||||
@@ -103,10 +109,11 @@ describe('Filter: filter', function() {
|
||||
expect(filter(items, {$: 'hevery'})[0]).toEqual(items[0]);
|
||||
});
|
||||
|
||||
|
||||
it('should support boolean properties', function() {
|
||||
var items = [{name: 'tom', current: true},
|
||||
{name: 'demi', current: false},
|
||||
{name: 'sofia'}];
|
||||
{name: 'demi', current: false},
|
||||
{name: 'sofia'}];
|
||||
|
||||
expect(filter(items, {current:true}).length).toBe(1);
|
||||
expect(filter(items, {current:true})[0].name).toBe('tom');
|
||||
@@ -114,6 +121,7 @@ describe('Filter: filter', function() {
|
||||
expect(filter(items, {current:false})[0].name).toBe('demi');
|
||||
});
|
||||
|
||||
|
||||
it('should support negation operator', function() {
|
||||
var items = ['misko', 'adam'];
|
||||
|
||||
@@ -133,8 +141,8 @@ describe('Filter: filter', function() {
|
||||
{key: 'value1', nonkey: 1},
|
||||
{key: 'value2', nonkey: 2},
|
||||
{key: 'value12', nonkey: 3},
|
||||
{key: 'value1', nonkey:4},
|
||||
{key: 'Value1', nonkey:5}
|
||||
{key: 'value1', nonkey: 4},
|
||||
{key: 'Value1', nonkey: 5}
|
||||
];
|
||||
expr = {key: 'value1'};
|
||||
expect(filter(items, expr, true)).toEqual([items[0], items[3]]);
|
||||
@@ -143,21 +151,22 @@ describe('Filter: filter', function() {
|
||||
{key: 1, nonkey: 1},
|
||||
{key: 2, nonkey: 2},
|
||||
{key: 12, nonkey: 3},
|
||||
{key: 1, nonkey:4}
|
||||
{key: 1, nonkey: 4}
|
||||
];
|
||||
expr = { key: 1 };
|
||||
expr = {key: 1};
|
||||
expect(filter(items, expr, true)).toEqual([items[0], items[3]]);
|
||||
|
||||
expr = 12;
|
||||
expect(filter(items, expr, true)).toEqual([items[2]]);
|
||||
});
|
||||
|
||||
|
||||
it('and use the function given to compare values', function() {
|
||||
var items = [
|
||||
{key: 1, nonkey: 1},
|
||||
{key: 2, nonkey: 2},
|
||||
{key: 12, nonkey: 3},
|
||||
{key: 1, nonkey:14}
|
||||
{key: 1, nonkey: 14}
|
||||
];
|
||||
var expr = {key: 10};
|
||||
var comparator = function(obj, value) {
|
||||
@@ -167,10 +176,6 @@ describe('Filter: filter', function() {
|
||||
|
||||
expr = 10;
|
||||
expect(filter(items, expr, comparator)).toEqual([items[2], items[3]]);
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user