UNPKG

3.67 kBJavaScriptView Raw
1import Skypager from '.'
2
3describe('Skypager Project', function () {
4 before(function() {
5 if (!this.project) {
6 this.project = Skypager.load(process.cwd(), {
7 sync: false
8 })
9 }
10 })
11
12 it('has an instance id', function() {
13 this.project.should.have.property('id')
14 })
15
16 it('Can load collections synchronously', function() {
17 this.project.should.have.property('collection')
18 this.project.should.have.property('files').that.is.an('array')
19 this.project.files.should.not.be.empty
20 })
21
22 it('loads the manifest', function() {
23 this.project.should.have.property('manifest')
24 this.project.manifest.should.have.property('name', 'skypager-project')
25 this.project.manifest.should.have.property('dependencies').that.is.an('object')
26 })
27
28 it('uses manifest configuration values for the project options', function() {
29 this.project.options.should.have.property('main', 'skypager.js')
30 })
31
32 it('enhances the pick method', function() {
33 const obj = this.project.slice('manifest.skypager', 'cacheKey', 'cwd')
34 obj.should.be.an('object')
35 obj.should.have.property('manifest').that.is.an('object').that.has.a.property('skypager').that.is.not.empty
36 obj.should.have.property('cacheKey', this.project.cacheKey)
37 obj.should.have.property('cwd', this.project.realCwd)
38 })
39
40 it('creates enhanced entity objects using the slice method', function() {
41 const obj = this.project.createEntityFrom('manifest.dependencies', 'cwd', 'helpers.available', 'compilers.available')
42
43 obj.should.be.an('object')
44 obj.should.have.property('helpers').that.is.an('object').that.has.a.property('available')
45 .that.is.an('array').that.is.not.empty
46 obj.should.have.property('manifest').that.is.an('object').that.has.a.property('dependencies')
47 .that.is.not.empty
48
49 obj.should.have.property('hide').that.is.a('function')
50 })
51})
52
53describe('helpers', function() {
54 before(function(){
55 this.project = Skypager.load(process.cwd(), {
56 sync: true
57 })
58 })
59
60 it('has a bunch of helpers', function() {
61 this.project.helpers.available.should.include('project-type')
62 this.project.should.have.property('projectType').that.is.a('function')
63 this.project.should.have.property('projectTypes').that.is.an('object')
64 })
65})
66
67describe('Project Info', function(){
68 before(function(){
69 this.project = Skypager.load(process.cwd(), {
70 sync: true
71 })
72 })
73
74 it('tells you about the project based on what it finds in the manifest', function() {
75 const project = this.project
76 project.should.have.property('manifest')
77 project.get('manifest.name').should.equal('skypager-project')
78 project.get('manifest.devDependencies').should.be.an('object').that.is.not.empty
79 })
80
81 it('has a selectors system', function() {
82 const project = this.project
83 project.select('dependencies').should.be.an('object').that.is.not.empty
84 })
85
86 it('has identifying features', function() {
87 const project = this.project
88
89 project.should.have.property('id').that.is.not.empty
90 project.should.have.property('name').that.is.not.empty
91 project.should.have.property('namespace').that.is.not.empty
92 })
93
94 it('lists info about the file paths', function() {
95 this.project.should.have.property('subFolderNames').that.contains('src')
96 let names = this.project.subFolderNames
97
98 names.should.include('src/middlewares')
99 })
100
101 it('lists info about the file paths', function() {
102 this.project.should.have.property('childFolderNames').that.contains('src')
103 let names = this.project.childFolderNames
104
105 names.should.not.contain('node_modules')
106 names.should.contain('src')
107 })
108})
\No newline at end of file