Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tests] Added tests based on mocha and should.js. Renamed tests-folde…
…r to test, in order to match mochas defaults.
- Loading branch information
Showing
5 changed files
with
280 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
var should = require('should'); | ||
var path = require('path'); | ||
var root = path.resolve('./'); | ||
|
||
describe('tests for the project helper', function() { | ||
|
||
var validAppPath = path.resolve('templates/project'); | ||
var invalidAppPath = path.resolve('templates'); | ||
var Project = null; | ||
var myProject = null; | ||
var curAppPath = ''; | ||
|
||
beforeEach(function() { | ||
Project = require(root + '/lib/helper/project'); | ||
myProject = new Project(); | ||
}); | ||
|
||
afterEach(function() { | ||
Project = null; | ||
myProject = null; | ||
curAppPath = ''; | ||
}); | ||
|
||
describe('findAppPath', function() { | ||
|
||
it('should find a valid app path', function() { | ||
curAppPath = validAppPath; | ||
var result = myProject.findAppPath(curAppPath); | ||
result.should.have.property('path'); | ||
result.should.have.property('searched'); | ||
result.should.have.property('found', true); | ||
result.path.should.be.a('string'); | ||
result.searched.should.be.an.instanceOf(Array); | ||
}); | ||
|
||
it('should not find an invalid app path', function() { | ||
curAppPath = invalidAppPath; | ||
var result = myProject.findAppPath(curAppPath); | ||
result.should.have.property('path'); | ||
result.should.have.property('searched'); | ||
result.should.have.property('found', false); | ||
result.path.should.be.a('string'); | ||
result.searched.should.be.an.instanceOf(Array); | ||
}); | ||
}); | ||
|
||
describe('listContexts', function() { | ||
|
||
it('should find contexts in a valid project', function() { | ||
curAppPath = validAppPath; | ||
var result = myProject.listContexts(curAppPath); | ||
result.should.have.property('path'); | ||
result.should.have.property('contexts'); | ||
result.path.should.be.a('string'); | ||
result.contexts.should.be.an.instanceOf(Array); | ||
}); | ||
|
||
it('should not find contexts in an invalid project', function() { | ||
curAppPath = invalidAppPath; | ||
var result = myProject.listContexts(curAppPath); | ||
result.should.have.property('path'); | ||
result.should.have.property('contexts'); | ||
result.path.should.be.a('string'); | ||
result.path.should.not.be.empty; | ||
result.contexts.should.be.an.instanceOf(Array); | ||
result.contexts.should.be.empty; | ||
}); | ||
}); | ||
|
||
describe('listModules', function() { | ||
|
||
it('should find modules in a valid project', function() { | ||
curAppPath = validAppPath; | ||
var result = myProject.listModules(curAppPath); | ||
result.should.have.property('path'); | ||
result.should.have.property('modules'); | ||
result.path.should.be.a('string'); | ||
result.path.should.not.be.empty; | ||
result.modules.should.be.an.instanceOf(Array); | ||
result.modules.should.include('acme'); | ||
}); | ||
|
||
it('should not find modules in an invalid project', function() { | ||
curAppPath = invalidAppPath; | ||
var result = myProject.listModules(curAppPath); | ||
result.should.have.property('path'); | ||
result.should.have.property('modules'); | ||
result.path.should.be.a('string'); | ||
result.path.should.not.be.empty; | ||
result.modules.should.be.empty; | ||
}); | ||
}); | ||
|
||
// NOT WORKING YET | ||
describe('loadContexts', function() { | ||
|
||
// not working yet (reason: path issues) | ||
return; | ||
|
||
var contextObject = {}; | ||
|
||
beforeEach(function() { | ||
|
||
// create contextObject mockup | ||
curAppPath = validAppPath; | ||
contextObject = myProject.listContexts(curAppPath); | ||
}); | ||
|
||
it('instantiate each provided context', function() { | ||
|
||
}); | ||
|
||
}); | ||
|
||
describe('findStartScript', function() { | ||
|
||
it('should find the start script for a valid project', function() { | ||
curAppPath = validAppPath; | ||
var result = myProject.findStartScript(curAppPath); | ||
result.should.be.a('string'); | ||
result.should.not.be.empty; | ||
}); | ||
|
||
it('should not find the start script for an invalid project', function() { | ||
curAppPath = invalidAppPath; | ||
var result = myProject.findStartScript(curAppPath); | ||
false.should.equal(result); | ||
}); | ||
}); | ||
|
||
describe('listConfigs', function() { | ||
|
||
it('should list configs for a valid project', function() { | ||
curAppPath = validAppPath; | ||
var result = myProject.listConfigs(curAppPath); | ||
result.path.should.be.a.string; | ||
result.configs.should.be.an.instanceOf(Array); | ||
result.path.should.not.be.empty; | ||
result.configs.should.include('application'); | ||
}); | ||
|
||
it('should not list configs for an invalid project', function() { | ||
curAppPath = invalidAppPath; | ||
var result = myProject.listConfigs(curAppPath); | ||
result.path.should.be.a.string; | ||
result.configs.should.be.an.instanceOf(Array); | ||
result.configs.should.be.empty; | ||
}); | ||
}); | ||
|
||
describe('loadConfigs', function() { | ||
|
||
it('should load configs for a valid project', function() { | ||
curAppPath = validAppPath; | ||
|
||
// get config object and configs | ||
var configObj = myProject.listConfigs(curAppPath); | ||
var configs = configObj.configs; | ||
var result = myProject.loadConfigs(configObj); | ||
|
||
configs.forEach(function(config) { | ||
should.exist(result.instance[config]); | ||
result.instance[config].should.be.a('object'); | ||
should.exist(result.instance[config].infrastructure); | ||
result.instance[config].infrastructure.should.be.a('object'); | ||
}); | ||
}); | ||
|
||
it('should not load configs for an invalid project', function() { | ||
curAppPath = invalidAppPath; | ||
|
||
// get config object | ||
var configObj = myProject.listConfigs(curAppPath); | ||
var result = myProject.loadConfigs(configObj); | ||
|
||
result.path.should.be.a.string; | ||
result.path.should.not.be.empty; | ||
result.configs.should.be.an.instanceOf(Array); | ||
result.configs.should.be.empty; | ||
result.instance.should.be.a.object; | ||
should.deepEqual(result.instance, {}, 'expected result.instance to be an empty object.'); | ||
}); | ||
}); | ||
|
||
// NOT WORKING YET | ||
describe('listModels', function() { | ||
|
||
// not working yet (reason: models need to be generated first) | ||
return; | ||
|
||
}); | ||
|
||
// NOT WORKING YET | ||
describe('listModelsForAllModules', function() { | ||
|
||
// not working yet (reason: models need to be generated first) | ||
return; | ||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
var should = require('should'); | ||
var path = require('path'); | ||
var root = path.resolve('./'); | ||
|
||
describe('tests for the store', function() { | ||
|
||
var Store = null; | ||
var myStore = null; | ||
|
||
beforeEach(function() { | ||
Store = require(root + '/lib/store'); | ||
}); | ||
|
||
afterEach(function() { | ||
Store = null; | ||
myStore = null; | ||
}); | ||
|
||
describe('constructor', function() { | ||
|
||
it('should register namespaces passed in as argument via the constructor', function() { | ||
var namespaces = ['checkMe', 'lookAtThis', 'ohWow']; | ||
var namespacesExpected = namespaces.slice(0); | ||
|
||
namespacesExpected.push('default'); | ||
|
||
myStore = new Store(namespaces); | ||
|
||
myStore.namespaces.should.have.keys(namespacesExpected); | ||
}); | ||
|
||
it('should always have a default namespace', function() { | ||
var namespaces = ['checkMe', 'lookAtThis', 'ohWow']; | ||
|
||
myStore = new Store(namespaces); | ||
|
||
should.exist(myStore.namespaces.default); | ||
}); | ||
|
||
it('should only have a default namespace when nothing was passed to the constructor', function() { | ||
myStore = new Store(); | ||
|
||
myStore.namespaces.should.have.keys('default'); | ||
}); | ||
}); | ||
|
||
describe('getter', function() { | ||
it('should get a value which was set without providing a namespace', function() { | ||
myStore = new Store(); | ||
|
||
myStore.set('fiz', 'buz'); | ||
|
||
myStore.get('fiz').should.equal('buz'); | ||
myStore.get('default', 'fiz').should.equal('buz'); | ||
}); | ||
|
||
it('should get a value which was set providing a namespace', function() { | ||
myStore = new Store(['customSpace']); | ||
|
||
myStore.set('customSpace', 'foo', 'bar'); | ||
|
||
myStore.get('customSpace', 'foo').should.equal('bar'); | ||
}); | ||
|
||
|
||
//it('should return undefined when accessing an undefined namespace', function() { | ||
|
||
// current version of store throws a typeerror, this should be fixed first | ||
//}); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--recursive | ||
--require should |