From a3fea601c5bd1740568a6bf268880d7ec88bc391 Mon Sep 17 00:00:00 2001 From: Reid Burke Date: Tue, 3 Apr 2012 16:08:52 -0700 Subject: [PATCH] Add teardown methods to Vows contexts. --- test/functional.js | 8 +++++++- test/lib/blizzard-http.js | 5 ++++- test/lib/blizzard.js | 4 ++++ test/lib/hub.js | 3 +++ test/listen.js | 3 +++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/test/functional.js b/test/functional.js index cd4861d4..185e3141 100644 --- a/test/functional.js +++ b/test/functional.js @@ -216,6 +216,9 @@ function attachServerContext(testContext, explicitRoute) { vow.callback(null, server); }); }, + teardown: function (server) { + server.close(); + }, "is connected": function (server) { assert.isNumber(server.address().port); }, @@ -260,6 +263,10 @@ function attachServerContext(testContext, explicitRoute) { "used by the Hub Client": { // TODO: Handle without trailing slash. topic: hub.clientTopic(route + "/"), + teardown: function (topic) { + // TODO Add end method, bug #54. + // topic.client.end(); + }, "a browser for testing": { topic: hub.phantomTopic(), "visits Yeti": testContext @@ -270,7 +277,6 @@ function attachServerContext(testContext, explicitRoute) { } function attachServerBatch(definition) { - var batch = {}, routeWords = ["foo", "bar", "baz", "quux"]; diff --git a/test/lib/blizzard-http.js b/test/lib/blizzard-http.js index 23417523..4a36d516 100644 --- a/test/lib/blizzard-http.js +++ b/test/lib/blizzard-http.js @@ -28,7 +28,10 @@ exports.sessionContext = function (subContext) { server: serverBlizzardSession }); }); - + }, + teardown: function (topic) { + topic.client.end(); + topic.server.end(); } }; diff --git a/test/lib/blizzard.js b/test/lib/blizzard.js index b7da44a0..3994be85 100644 --- a/test/lib/blizzard.js +++ b/test/lib/blizzard.js @@ -50,6 +50,10 @@ exports.sessionContext = function (subContext) { }); clientSocket.once("error", vow.callback); + }, + teardown: function (topic) { + topic.client.end(); + topic.server.end(); } }; diff --git a/test/lib/hub.js b/test/lib/hub.js index 872444a7..87c3f60b 100644 --- a/test/lib/hub.js +++ b/test/lib/hub.js @@ -50,6 +50,9 @@ var clientContext = exports.clientContext = function (subContext) { }); hub.once("error", vow.callback); }, + teardown: function (hub) { + hub.close(); + }, "is ok": function (hub) { assert.ok(hub); assert.isNumber(hub.server.address().port); diff --git a/test/listen.js b/test/listen.js index 7b542485..e0a2040b 100644 --- a/test/listen.js +++ b/test/listen.js @@ -52,6 +52,9 @@ vows.describe("Yeti Listen").addBatch({ vow.callback(null, server); }); }, + teardown: function (server) { + server.close(); + }, "is connected": function (topic) { assert.ok(topic.address().port); },