Add test cases

This commit is contained in:
Raymond Feng 2014-11-18 15:16:50 -08:00
parent 087f353af1
commit 2324316fc6
1 changed files with 35 additions and 0 deletions

View File

@ -325,6 +325,41 @@ describe('app', function() {
});
});
describe('app.utilities', function() {
it('is unique per app instance', function() {
app.utilities.foo = function() {};
var anotherApp = loopback();
expect(anotherApp.utilities.foo).to.equal(undefined);
});
});
describe('app.utility', function() {
// any utility will do
it('adds the utility to the registry', function() {
var fn = function() {};
app.utility('foo-bar', fn);
expect(app.utilities['foo-bar']).to.equal(fn);
});
it('asserts name to be string', function() {
var fn = function() {};
try {
app.utility(12, fn);
} catch(e) {
expect(e).to.be.instanceOf(Error);
}
});
it('asserts utility to be function', function() {
try {
app.utility('x', 'y');
} catch(e) {
expect(e).to.be.instanceOf(Error);
}
});
});
describe('app.settings', function() {
it('can be altered via `app.set(key, value)`', function() {
app.set('write-key', 'write-value');