fix(orderBy): sort by identity if no predicate is given

Closes #5847
Closes #4579
Closes #9403
This commit is contained in:
Peter Bacon Darwin
2014-10-02 22:27:52 +01:00
parent f2942447c1
commit 607f016a0b
2 changed files with 24 additions and 6 deletions

View File

@@ -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() {