Created
July 18, 2014 10:00
-
-
Save tlimpanont/d81383045a2dac2d4164 to your computer and use it in GitHub Desktop.
Testing _. lodash sortBy function for grid list view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('_.sortBy of lodash',function(){ | |
var descData = [ | |
{title: "B", number: 2, date: new Date("October 2, 2014") }, | |
{title: "A", number: 1, date: new Date("October 1, 2014") }, | |
]; | |
var ascData = [ | |
{title: "A", number: 1, date: new Date("October 1, 2014") }, | |
{title: "B", number: 2, date: new Date("October 2, 2014") }, | |
]; | |
it('shoud sort title in ASC order',function(){ | |
var orderedData = _.map(_.sortBy(descData, "title" )); | |
expect(orderedData).toEqual(ascData); | |
var orderedData = _.map(_.sortBy(ascData, "title" )); | |
expect(orderedData).toEqual(ascData); | |
}); | |
it('shoud sort title in DESC order',function(){ | |
var orderedData = _.map(_.sortBy(descData, "title" )).reverse(); | |
expect(orderedData).toEqual(descData); | |
var orderedData = _.map(_.sortBy(ascData, "title" )).reverse(); | |
expect(orderedData).toEqual(descData); | |
}); | |
it('shoud sort date in ASC order',function(){ | |
var orderedData = _.map(_.sortBy(descData, "date" )); | |
expect(orderedData).toEqual(ascData); | |
}); | |
it('shoud sort date in DESC order',function(){ | |
var orderedData = _.map(_.sortBy(ascData, "date" )).reverse(); | |
expect(orderedData).toEqual(descData); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment