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

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