diff --git a/test/unit/client/simple-query-tests.js b/test/unit/client/simple-query-tests.js index 98827e7..92a0610 100644 --- a/test/unit/client/simple-query-tests.js +++ b/test/unit/client/simple-query-tests.js @@ -1,25 +1,11 @@ -require(__dirname + "/test-helper"); - -var makeClient = function() { - var connection = new Connection({stream: "no"}); - connection.startup = function() {}; - connection.connect = function() {}; - connection.query = function(text) { - this.queries.push(text); - }; - connection.queries = []; - var client = new Client({connection: connection}); - client.connect(); - client.connection.emit('connect'); - return client; -}; +var helper = require(__dirname + "/test-helper"); test('executing query', function() { test("queing query", function() { test('when connection is ready', function() { - var client = makeClient(); + var client = helper.client(); assert.empty(client.connection.queries); client.connection.emit('readyForQuery'); client.query('yes'); @@ -28,7 +14,7 @@ test('executing query', function() { }); test('when connection is not ready', function() { - var client = makeClient(); + var client = helper.client(); test('query is not sent', function() { client.query('boom'); @@ -44,7 +30,7 @@ test('executing query', function() { }); test("multiple in the queue", function() { - var client = makeClient(); + var client = helper.client(); var connection = client.connection; var queries = connection.queries; client.query('one'); @@ -76,7 +62,7 @@ test('executing query', function() { }); test("query event binding and flow", function() { - var client = makeClient(); + var client = helper.client(); var con = client.connection; var query = client.query('whatever'); diff --git a/test/unit/client/test-helper.js b/test/unit/client/test-helper.js index 88cced6..f6ed43c 100644 --- a/test/unit/client/test-helper.js +++ b/test/unit/client/test-helper.js @@ -1 +1,19 @@ -require(__dirname+'/../test-helper') +require(__dirname+'/../test-helper'); + +var makeClient = function() { + var connection = new Connection({stream: "no"}); + connection.startup = function() {}; + connection.connect = function() {}; + connection.query = function(text) { + this.queries.push(text); + }; + connection.queries = []; + var client = new Client({connection: connection}); + client.connect(); + client.connection.emit('connect'); + return client; +}; + +module.exports = { + client: makeClient +};