Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tests] Added new tests and extended an old one.
- Loading branch information
Showing
3 changed files
with
165 additions
and
4 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
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,63 @@ | ||
/** | ||
* Tests for lib/app/worker/context.js | ||
* | ||
* @author Nabil Krause <nabil.krause@silberlicht.eu> | ||
*/ | ||
|
||
var should = require('should'); | ||
var path = require('path'); | ||
var root = path.resolve('./'); | ||
var express = require('express'); | ||
var Context = require(root + '/lib/app/worker/context'); | ||
|
||
|
||
describe('context', function() { | ||
|
||
var context = null; | ||
|
||
it('should have a property name which is based on the provided constructor-parameter', function() { | ||
var param = 'i/am/some/path/to/a/file.js'; | ||
|
||
context = new Context(param); | ||
|
||
context.name.should.equal('file'); | ||
}); | ||
|
||
it('should have a property description which should be a string', function() { | ||
context = new Context(); | ||
|
||
context.description.should.be.a('string'); | ||
}); | ||
|
||
it('should have a property backends which should be an empty object', function() { | ||
context = new Context(); | ||
|
||
context.backends.should.eql({}); | ||
}); | ||
|
||
it('should have a property modules which should be an empty array', function() { | ||
context = new Context(); | ||
|
||
context.modules.should.eql([]); | ||
}); | ||
|
||
it('should have a property controllers which should be an empty object', function() { | ||
context = new Context(); | ||
|
||
context.controllers.should.eql({}); | ||
}); | ||
|
||
it('should have a property routes which should be an empty object', function() { | ||
context = new Context(); | ||
|
||
context.modules.should.eql({}); | ||
}); | ||
|
||
it('should have a method configure which calls a given callback', function(done) { | ||
context = new Context(); | ||
|
||
context.configure(null, null, function() { | ||
done(); | ||
}); | ||
}); | ||
}); |
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,51 @@ | ||
/** | ||
* Tests for lib/http/mvc/controller.js | ||
* | ||
* @author Nabil Krause <nabil.krause@silberlicht.eu> | ||
*/ | ||
|
||
var should = require('should'); | ||
var path = require('path'); | ||
var root = path.resolve('./'); | ||
var Controller = require(root + '/lib/http/mvc/controller'); | ||
var controller = null; | ||
|
||
describe('controller', function() { | ||
|
||
beforeEach(function() { | ||
controller = new Controller(); | ||
}); | ||
|
||
it('should have an options property with the correct structure and values', function() { | ||
controller.options.should.have.property('path'); | ||
controller.options.should.have.property('auth'); | ||
controller.options.auth.should.have.property('handler'); | ||
controller.options.auth.should.have.property('routes'); | ||
controller.options.path.should.equal(''); | ||
should.equal(controller.options.auth.handler, null); | ||
should.equal(controller.options.auth.routes, null); | ||
}); | ||
|
||
it('should have an actions object', function() { | ||
controller.actions.should.be.a('object'); | ||
}); | ||
|
||
it('should have a viewPath property', function() { | ||
controller.viewPath.should.be.a('string'); | ||
}); | ||
|
||
it('should have a configure method which calls the provided callback', function(done) { | ||
controller.configure(null, null, function() { | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should have a method view which returns the view-path for a given file', function() { | ||
controller.view('xyz.jade').should.equal('/xyz.jade'); | ||
|
||
controller.viewPath = '/some/path/'; | ||
|
||
controller.view('myView.jade').should.equal('/some/path/myView.jade'); | ||
}); | ||
}); | ||
|