Navigation Menu

Skip to content

Commit

Permalink
Starting to write proper unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-jack committed Nov 8, 2014
1 parent 9d1056c commit 9143810
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
3 changes: 3 additions & 0 deletions lib/hosting/startServerFluent.js
Expand Up @@ -21,6 +21,9 @@ var ensureServerRunning = function * () {
}

var runTest = function (testDefinition, done) {
if (!testDefinition) throw new Error("The test definition must be specified.");
if (!testDefinition.runAgainst) throw new Error("The test definition must have a runAgainst method. Please see documentation.");

var self = this;
var deferred = Q.defer();

Expand Down
33 changes: 27 additions & 6 deletions spec/unit/start_server_fluent_error_spec.js
Expand Up @@ -2,11 +2,32 @@
var assert = fixture.assert;
var startServerFluent = fixture.testResources.startServerFluent;

describe("when you ask for a port but the server has not been started", function () {
it("should throw an error", function () {
describe("start server fluent interface", function () {

var underTest;

beforeEach(function () {
var fakeExpress = {};
debugger;
var underTest = startServerFluent(fakeExpress);
assert.throws(function () { underTest.port }, "The port is not allocated until the server is started.")
underTest = startServerFluent(fakeExpress);
});

describe("when you ask for a port but the server has not been started", function () {
it("should throw an error", function () {
assert.throws(function () { underTest.port }, "The port is not allocated until the server is started.")
});
});

describe("when you call run test but don't pass test definition", function () {
it("should throw an error", function () {
assert.throws(function () { underTest.runTest(null, null) }, "The test definition must be specified.")
});
});
});

describe("when you call run test but pass invalid test definition", function () {
it("should throw an error", function () {
debugger;
assert.throws(function () { underTest.runTest({}, null) }, "The test definition must have a runAgainst method. Please see documentation.")
});
});

})

0 comments on commit 9143810

Please sign in to comment.