diff --git a/lib/client.js b/lib/client.js index b1f7533..85a0d71 100644 --- a/lib/client.js +++ b/lib/client.js @@ -113,6 +113,13 @@ class LimitdRedis extends EventEmitter { resetAll(cb) { this.db.resetAll(cb); } + + close(callback) { + this.db.close((err) => { + this.db.removeAllListeners(); + callback(err); + }); + } } module.exports = LimitdRedis; diff --git a/test/client.tests.js b/test/client.tests.js index b614a1e..1a2f013 100644 --- a/test/client.tests.js +++ b/test/client.tests.js @@ -168,4 +168,15 @@ describe('LimitdRedis', () => { client.resetAll(done); }); }); + + describe('#close', () => { + it('should call db.close', (done) => { + client.db.close = (cb) => cb(); + client.close((err) => { + assert.equal(client.db.listenerCount('error'), 0); + assert.equal(client.db.listenerCount('ready'), 0); + done(err); + }); + }); + }); });