mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 19:40:56 +08:00
fix(orderBy): sort by identity if no predicate is given
Closes #5847 Closes #4579 Closes #9403
This commit is contained in:
@@ -6,9 +6,18 @@ describe('Filter: orderBy', function() {
|
||||
orderBy = $filter('orderBy');
|
||||
}));
|
||||
|
||||
it('should return same array if predicate is falsy', function() {
|
||||
var array = [1, 2, 3];
|
||||
expect(orderBy(array)).toBe(array);
|
||||
it('should return sorted array if predicate is not provided', function() {
|
||||
expect(orderBy([2, 1, 3])).toEqual([1, 2, 3]);
|
||||
|
||||
expect(orderBy([2, 1, 3], '')).toEqual([1, 2, 3]);
|
||||
expect(orderBy([2, 1, 3], [])).toEqual([1, 2, 3]);
|
||||
expect(orderBy([2, 1, 3], [''])).toEqual([1, 2, 3]);
|
||||
|
||||
expect(orderBy([2, 1, 3], '+')).toEqual([1, 2, 3]);
|
||||
expect(orderBy([2, 1, 3], ['+'])).toEqual([1, 2, 3]);
|
||||
|
||||
expect(orderBy([2, 1, 3], '-')).toEqual([3, 2, 1]);
|
||||
expect(orderBy([2, 1, 3], ['-'])).toEqual([3, 2, 1]);
|
||||
});
|
||||
|
||||
it('shouldSortArrayInReverse', function() {
|
||||
|
||||
Reference in New Issue
Block a user