parent
e430a92431
commit
485ba055af
@ -1,5 +1,6 @@
|
||||
- schema.Schema
|
||||
- model.Model
|
||||
- filter.Filter/filter.Focus
|
||||
|
||||
Integration
|
||||
- relations
|
||||
|
@ -0,0 +1,82 @@
|
||||
const { expect } = require('chai')
|
||||
const sinon = require('sinon')
|
||||
|
||||
const Filter = require('../../src/filter/Filter')
|
||||
const Focus = require('../../src/filter/Focus')
|
||||
const FilterProxy = require('../../src/proxy/model/FilterProxy')
|
||||
|
||||
describe('the accumulating filter class', function() {
|
||||
let filter
|
||||
let fake_model
|
||||
beforeEach(function() {
|
||||
fake_model = {}
|
||||
filter = new Filter(fake_model)
|
||||
})
|
||||
|
||||
it('should have a base root property', function() {
|
||||
expect(filter._root).to.be.eql({$and: []})
|
||||
})
|
||||
|
||||
it('should set the model on construction', function() {
|
||||
expect(filter._model).to.be.equal(fake_model)
|
||||
})
|
||||
|
||||
describe('the clone method', function() {
|
||||
it('should be a function', function() {
|
||||
expect(filter.clone).to.be.a('function')
|
||||
})
|
||||
|
||||
it('should return a new filter', function() {
|
||||
expect(filter.clone()).to.be.an.instanceof(Filter)
|
||||
expect(filter.clone()).to.not.be.equal(filter)
|
||||
})
|
||||
|
||||
it('should focus on the same model', function() {
|
||||
expect(filter.clone()._model).to.be.equal(fake_model)
|
||||
})
|
||||
|
||||
it('should have a different root object', function() {
|
||||
expect(filter.clone()._root).to.not.be.equal(filter._root)
|
||||
expect(filter.clone()._root).to.be.eql(filter._root)
|
||||
})
|
||||
})
|
||||
|
||||
describe('the field method', function() {
|
||||
it('should be a function', function() {
|
||||
expect(filter.field).to.be.a('function')
|
||||
})
|
||||
|
||||
it('should expect one argument', function() {
|
||||
expect(filter.field.length).to.be.equal(1)
|
||||
})
|
||||
|
||||
it('should return a new Focus object', function() {
|
||||
const focus = filter.field('test_field')
|
||||
expect(focus).to.be.an.instanceof(Focus)
|
||||
expect(focus._parent).to.be.equal(filter)
|
||||
expect(focus._field).to.be.equal('test_field')
|
||||
})
|
||||
})
|
||||
|
||||
describe('the end method', function() {
|
||||
it('should be a function', function() {
|
||||
expect(filter.end).to.be.a('function')
|
||||
})
|
||||
|
||||
it('should return a filter proxy', function() {
|
||||
const fp = filter.end()
|
||||
expect(fp).to.be.an.instanceof(FilterProxy)
|
||||
})
|
||||
})
|
||||
|
||||
// TODO describe the equal method
|
||||
// TODO describe the less_than method
|
||||
// TODO describe the greater_than method
|
||||
// TODO describe the less_than_equal method
|
||||
// TODO describe the greater_than_equal method
|
||||
// TODO describe the in method
|
||||
// TODO describe the write method
|
||||
// TODO describe the __exec_resolve method
|
||||
// TODO describe the absorb method
|
||||
// TODO describe the _unfocus method
|
||||
})
|
Loading…
Reference in new issue