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.

166 lines
2.0 KiB

const { assert } = require('chai')
const fs = require('fs')
describe('Filter', function () {
// get function
const Filter = require('./../src/filter.js')
// check results
it('_eq', function() {
const filter = new Filter({
view: {
_eq: 'post.njk'
}
})
const data = {
view: 'post.njk'
}
assert.equal(filter.validate(data), true)
})
it('_neq', function() {
const filter = new Filter({
view: {
_neq: 'post.njk'
}
})
const data = {
view: 'blog.njk'
}
assert.equal(filter.validate(data), true)
})
it('_in single', function() {
const filter = new Filter({
tags: {
_in: 'monday'
}
})
const data = {
tags: [
'monday', 'friday'
]
}
assert.equal(filter.validate(data), true)
})
it('_in array', function() {
const filter = new Filter({
tags: {
_in: [
'monday'
]
}
})
const data = {
tags: [
'monday', 'friday'
]
}
assert.equal(filter.validate(data), true)
})
it('_lt', function() {
const filter = new Filter({
number: {
_lt: 100
}
})
const data = {
number: 150
}
assert.equal(filter.validate(data), true)
})
it('_lte', function() {
const filter = new Filter({
number: {
_lte: 150
}
})
const data = {
number: 150
}
assert.equal(filter.validate(data), true)
})
it('_gt', function() {
const filter = new Filter({
number: {
_gt: 150
}
})
const data = {
number: 100
}
assert.equal(filter.validate(data), true)
})
it('_gte', function() {
const filter = new Filter({
number: {
_gte: 150
}
})
const data = {
number: 100
}
assert.equal(filter.validate(data), true)
})
it('_null', function() {
const filter = new Filter({
not: {
_null: true
}
})
const data = {
}
assert.equal(filter.validate(data), true)
})
it('_nnull', function() {
const filter = new Filter({
not: {
_nnull: true
}
})
const data = {
not: true
}
assert.equal(filter.validate(data), true)
})
})