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.
65 lines
992 B
65 lines
992 B
2 years ago
|
const { assert } = require('chai')
|
||
|
const fs = require('fs')
|
||
|
|
||
|
describe('Filter', function () {
|
||
|
|
||
|
// get function
|
||
|
const reduce = require('./../src/reduce.js')
|
||
|
|
||
|
// check results
|
||
|
it('reduce, limit', function() {
|
||
|
|
||
|
const options = {
|
||
|
limit: 2
|
||
|
}
|
||
|
|
||
|
const data = reduce(options, [
|
||
|
{ index: 0 },
|
||
|
{ index: 1 },
|
||
|
{ index: 2 },
|
||
|
{ index: 3 },
|
||
|
{ index: 4 }
|
||
|
])
|
||
|
|
||
|
assert.equal(data.length, 2)
|
||
|
})
|
||
|
|
||
|
// check results
|
||
|
it('reduce, offset', function() {
|
||
|
|
||
|
const options = {
|
||
|
offset: 2
|
||
|
}
|
||
|
|
||
|
const data = reduce(options, [
|
||
|
{ index: 0 },
|
||
|
{ index: 1 },
|
||
|
{ index: 2 },
|
||
|
{ index: 3 },
|
||
|
{ index: 4 }
|
||
|
])
|
||
|
|
||
|
assert.equal(data[0].index, 2)
|
||
|
})
|
||
|
|
||
|
// check results
|
||
|
it('reduce, limit / offset', function() {
|
||
|
|
||
|
const options = {
|
||
|
offset: 2,
|
||
|
limit: 3
|
||
|
}
|
||
|
|
||
|
const data = reduce(options, [
|
||
|
{ index: 0 },
|
||
|
{ index: 1 },
|
||
|
{ index: 2 },
|
||
|
{ index: 3 },
|
||
|
{ index: 4 }
|
||
|
])
|
||
|
|
||
|
assert.equal(data[0].index, 2)
|
||
|
assert.equal(data.length, 3)
|
||
|
})
|
||
|
})
|