From 1cd1721f7f9a26c88a1a1dce0603664598aefa20 Mon Sep 17 00:00:00 2001 From: brianc Date: Fri, 4 Mar 2011 19:30:19 +0000 Subject: [PATCH] integration notification tests --- lib/client.js | 4 ++++ test/integration/client/notice-tests.js | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/client.js b/lib/client.js index c7e613d..b6db53f 100644 --- a/lib/client.js +++ b/lib/client.js @@ -85,6 +85,10 @@ p.connect = function() { } }); + con.on('notification', function(msg) { + self.emit('notification', msg); + }) + }); con.on('readyForQuery', function() { diff --git a/test/integration/client/notice-tests.js b/test/integration/client/notice-tests.js index 2aa0001..b3c5f43 100644 --- a/test/integration/client/notice-tests.js +++ b/test/integration/client/notice-tests.js @@ -1,11 +1,26 @@ var helper = require(__dirname + '/test-helper'); test('emits notice message', function() { var client = helper.client(); - client.query('create temp table boom(id serial, size integer)'); - assert.emits(client, 'notice', function(notice) { assert.ok(notice != null); client.end(); }); }) + +test('emits notify message', function() { + var client = helper.client(); + client.query('LISTEN boom', assert.calls(function() { + var otherClient = helper.client(); + otherClient.query('LISTEN boom', assert.calls(function() { + client.query('NOTIFY boom'); + assert.emits(client, 'notification', function(msg) { + client.end() + }); + assert.emits(otherClient, 'notification', function(msg) { + otherClient.end(); + }); + })); + })); +}) +