UNPKG

skypager-project

Version:
58 lines (47 loc) 1.95 kB
import Document from '.' import { join, resolve as resolvePath } from 'path' const testRoot = join(process.cwd(), 'test') const resolve = (rel) => resolvePath(testRoot, rel) describe('Skypager Document', function() { it('Has an ID', function() { const doc = new Document(`file://${resolve('./fixtures/testcases/structure-spec.md')}`, { cwd: testRoot + '/fixtures' }) doc.should.have.property('id', 'testcases/structure-spec') }) it('Has a parsed URI', function() { const doc = new Document(`file://${resolve('./fixtures/testcases/structure-spec.md')}`, { cwd: testRoot + '/fixtures' }) doc.should.have.property('parsedURI').that.is.an('object') doc.parsedURI.protocol.should.equal('file:') }) it('Has a URL', function() { const doc = new Document(`file://${resolve('./fixtures/testcases/structure-spec.md')}`, { cwd: testRoot + '/fixtures' }) doc.url.should.match(/testcases\/structure-spec\.md$/) }) it('Has options', function() { const doc = new Document(`file://${resolve('./fixtures/testcases/structure-spec.md')}`, { cwd: testRoot + '/fixtures' }) doc.should.have.property('options').that.is.an('object') }) }) describe('Document Naming Variations', function() { it('should create pattern based on the stem', function(){ const doc = new Document(`file://${resolve('./fixtures/components/HomePage/index.js')}`, { cwd: testRoot + '/fixtures' }) Object.values(doc.filenameVariations) .should.include('home-page.js', 'homePage.js', 'HomePage.js') }) it('should create pattern based on the stem using the index', function(){ const doc = new Document(`file://${resolve('./fixtures/components/HomePage/index.js')}`, { cwd: testRoot + '/fixtures' }) const variations = Object.values(doc.indexVariations) variations.should.include('home-page/index.js', 'homePage.js', 'HomePage/index.js') }) })