skypager-project
Version:
skypager project framework
83 lines (67 loc) • 2.38 kB
JavaScript
import Collection from '.'
import { join } from 'path'
describe('Skypager Document Collection', function() {
it('has an instance id', function() {
const docsCollection = new Collection({
type: 'documents',
cwd: join(process.cwd(), 'test', 'fixtures', 'testcases') ,
})
docsCollection.should.have.property('instanceId')
docsCollection.should.have.property('pathId')
})
it('has a type', function() {
const docsCollection = new Collection({
type: 'documents',
cwd: join(process.cwd(), 'test', 'fixtures', 'testcases') ,
})
docsCollection.should.have.property('type', 'document')
})
it('has a path router', function() {
const docsCollection = new Collection({
type: 'documents',
cwd: join(process.cwd(), 'test', 'fixtures', 'testcases') ,
})
docsCollection.should.have.property('router')
})
it('has an importer with some files', function() {
const docsCollection = new Collection({
type: 'documents',
cwd: join(process.cwd(), 'test', 'fixtures', 'testcases') ,
})
docsCollection.should.have.property('importer').that.is.an('object')
docsCollection.should.have.property('files').that.is.an('array')
})
it('passes patterns to the importer', function() {
const docsCollection = new Collection({
type: 'documents',
cwd: join(process.cwd(), 'test', 'fixtures', 'testcases'),
exclude: ['whatever'],
importerOptions: {
patterns: ['whatever-else']
},
})
docsCollection.importer.patterns.should.include(...docsCollection.patterns)
})
it('loads simple files', function() {
const docsCollection = new Collection({
type: 'documents',
cwd: join(process.cwd(), 'test', 'fixtures', 'testcases') ,
})
docsCollection.loadFile({path:'nice.js',contents:'nice'})
docsCollection.files.length.should.equal(1)
})
it('loads files', function(done) {
const docsCollection = new Collection({
type: 'documents',
cwd: join(process.cwd(), 'test', 'fixtures', 'testcases') ,
})
done()
})
it('specifies patterns based on the type of collection', function() {
const docsCollection = new Collection({
type: 'documents',
cwd: join(process.cwd(), 'test', 'fixtures', 'testcases') ,
})
docsCollection.patterns.should.include('**/*.md')
})
})