skypager-project
Version:
skypager project framework
45 lines (33 loc) • 1.73 kB
JavaScript
import Skypager from '.'
describe('Skypager Helpers', function() {
describe('Models', function() {
const project = Skypager.load(process.cwd(), {
sync: false
})
it('makes models available', function() {
project.models.available.should.not.be.empty
})
it('builds a map of which objects were found at which route', function() {
const instanceObjectMap = project.model('Helper').routeResultsMap
instanceObjectMap.should.be.an('object').with.property('*/document-types/*.js').that.is.an('array').that.is.not.empty
})
it('gives us all of the instances keyed by their document id', function() {
project.model('Helper').should.have.property('instances').that.is.an('object')
.that.has.property('document-types/babel-es6')
const instance = project.model('Helper') .get(['instances', 'document-types/babel-es6'])
instance.should.be.an('object').that.has.a.property('file').that.is.an('object')
instance.should.have.property('moduleInfo').that.is.an('function')
instance.moduleInfo().should.be.an('object').that.has.property('imports')
})
it('applies exclusion rules', function() {
const model = project.model('Helper', { exclude: /document-types/ })
model.should.be.an('object')
model.should.have.property('chain').that.has.property('get').that.is.a('function')
model.should.have.property('exclude').that.is.an('array')
model.resultIds.filter(id => id.match(/document-types/)).should.be.empty
})
it('applies inclusion rules', function() {
project.model('Helper', { include: /document-types/ }).resultIds.filter(id => id.match(/document-types/)).should.not.be.empty
})
})
})