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.
76 lines
1009 B
76 lines
1009 B
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)
|
|
})
|
|
})
|