You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
const { assert } = require('chai')
|
|
|
|
const fs = require('fs')
|
|
|
|
|
|
|
|
describe('OrderBy', function () {
|
|
|
|
|
|
|
|
// get function
|
|
|
|
const orderBy = require('./../src/orderBy.js')
|
|
|
|
|
|
|
|
// check results
|
|
|
|
it('desc', function() {
|
|
|
|
|
|
|
|
const options = [
|
|
|
|
'-index'
|
|
|
|
]
|
|
|
|
|
|
|
|
const data = orderBy(options, [
|
|
|
|
{ index: 3 },
|
|
|
|
{ index: 1 },
|
|
|
|
{ index: 0 },
|
|
|
|
{ index: 4 },
|
|
|
|
{ index: 2 }
|
|
|
|
])
|
|
|
|
|
|
|
|
assert.equal(data[0].index, 4)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('asc', function() {
|
|
|
|
|
|
|
|
const options = [
|
|
|
|
'index'
|
|
|
|
]
|
|
|
|
|
|
|
|
const data = orderBy(options, [
|
|
|
|
{ index: 3 },
|
|
|
|
{ index: 1 },
|
|
|
|
{ index: 0 },
|
|
|
|
{ index: 4 },
|
|
|
|
{ index: 2 }
|
|
|
|
])
|
|
|
|
|
|
|
|
assert.equal(data[0].index, 0)
|
|
|
|
})
|
|
|
|
})
|