Skip to content

Commit

Permalink
fix: UT order by date
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaslabbe committed Dec 7, 2016
1 parent 8e9064e commit 581d181
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/cli/core/utils/sort.js
Expand Up @@ -8,8 +8,8 @@
* @return {Int} 1 | 0 | -1
*/
export function byDateDesc(a, b) {
var dateA = new Date(a.abe_meta.publish.date)
var dateB = new Date(b.abe_meta.publish.date)
var dateA = (a.abe_meta.publish != null) ? new Date(a.abe_meta.publish.date) : 0
var dateB = (b.abe_meta.publish != null) ? new Date(b.abe_meta.publish.date) : 0
if(dateA < dateB) {
return 1
}else if(dateA > dateB) {
Expand Down Expand Up @@ -54,8 +54,8 @@ export function shuffle(array) {
* @return {Int} 1 | 0 | -1
*/
export function byDateAsc(a, b) {
var dateA = new Date(a.abe_meta.publish.date)
var dateB = new Date(b.abe_meta.publish.date)
var dateA = (a.abe_meta.publish != null) ? new Date(a.abe_meta.publish.date) : 0
var dateB = (b.abe_meta.publish != null) ? new Date(b.abe_meta.publish.date) : 0
if(dateA > dateB) {
return 1
}else if(dateA < dateB) {
Expand Down
2 changes: 1 addition & 1 deletion test/sort.js
Expand Up @@ -24,7 +24,7 @@ describe('Sort', function() {
it('coreUtils.sort.byDateAsc', function() {
var list = Manager.instance.getList()
list.sort(coreUtils.sort.byDateAsc)
chai.expect(list[0].name).to.contain('homepage');
chai.expect(list[0].name).to.contain('article-1');
});

/**
Expand Down

0 comments on commit 581d181

Please sign in to comment.