diff --git a/test/logglyAppender-test.js b/test/logglyAppender-test.js index 688e43e..adf1202 100644 --- a/test/logglyAppender-test.js +++ b/test/logglyAppender-test.js @@ -12,10 +12,11 @@ function setupLogging(category, options) { createClient: function(options) { return { config: options, - log: function(msg, tags) { + log: function(msg, tags, cb) { msgs.push({ msg: msg, - tags: tags + tags: tags, + cb: cb }); } }; @@ -107,4 +108,31 @@ vows.describe('log4js logglyAppender').addBatch({ assert.deepEqual(topic.results[0].tags, []); } } +}).addBatch({ + 'with shutdown callback': { + topic: function() { + var setup = setupTaggedLogging(); + + setup.logger.log('trace', 'Log event #1', 'Log 2', { + tags: ['tag1', 'tag2'] + }); + + return setup; + }, + 'after the last message has been sent': { + topic: function (topic) { + var that = this; + + log4js.shutdown(this.callback); + topic.results[0].cb(); + + setTimeout(function() { + that.callback(new Error('Shutdown callback has not been called')); + }, 0); + }, + 'calls `log4js.shutdown`s callback function.': function(error, result) { + assert.equal(error, undefined); + } + } + } }).export(module);