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.
44 lines
646 B
44 lines
646 B
2 years ago
|
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: 0 },
|
||
|
{ index: 1 },
|
||
|
{ index: 2 },
|
||
|
{ index: 3 },
|
||
|
{ index: 4 }
|
||
|
])
|
||
|
|
||
|
assert.equal(data[0].index, 4)
|
||
|
})
|
||
|
|
||
|
it('asc', function() {
|
||
|
|
||
|
const options = [
|
||
|
'index'
|
||
|
]
|
||
|
|
||
|
const data = orderBy(options, [
|
||
|
{ index: 0 },
|
||
|
{ index: 1 },
|
||
|
{ index: 2 },
|
||
|
{ index: 3 },
|
||
|
{ index: 4 }
|
||
|
])
|
||
|
|
||
|
assert.equal(data[0].index, 0)
|
||
|
})
|
||
|
})
|