Skip to content

Instantly share code, notes, and snippets.

@marcusoftnet
Created February 23, 2015 03:45
Show Gist options
  • Save marcusoftnet/db5f368a80021327da29 to your computer and use it in GitHub Desktop.
Save marcusoftnet/db5f368a80021327da29 to your computer and use it in GitHub Desktop.
Testing config
var should = require("should");
describe("Configuration", function() {
var validateConfig = function(config) {
should.exists(config.mode);
config.mode.should.not.be.emtpy;
should.exists(config.mongoUrl);
config.mongoUrl.should.not.be.emtpy;
should.exists(config.port);
config.port.should.not.be.emtpy;
should.exists(config.user);
config.user.should.not.be.emtpy;
should.exists(config.user.name);
config.user.name.should.not.be.emtpy;
should.exists(config.user.pass);
config.user.pass.should.not.be.emtpy;
};
describe("Local configuration", function() {
var config = {};
before(function(done) {
config = require("./config")("local");
done();
});
it("loads local configuration default", function(done) {
var localConfig = require("./config")();
localConfig.mode.should.equal("local");
done();
});
it("loads config by parameter", function(done) {
config = require("./config")("local");
config.mode.should.equal("local");
done();
});
it("loads local configuration for unknown configurations", function(done) {
var config = require("./config")("unknown");
config.mode.should.equal("local");
done();
});
it("has all the valid properties", function(done) {
validateConfig(config);
done();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment