From ee6b53618b694a1719be60bcc054ea4a4240a75c Mon Sep 17 00:00:00 2001 From: Janny Date: Tue, 21 Jan 2020 11:06:46 -0500 Subject: [PATCH] test: add tests for isactive (#165) --- test/transaction.test.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/transaction.test.js b/test/transaction.test.js index 458b968..8909111 100644 --- a/test/transaction.test.js +++ b/test/transaction.test.js @@ -210,6 +210,32 @@ describe('transactions', function() { }); }); + describe('isActive', function() { + it('returns true when connection is active', function(done) { + Post.beginTransaction({ + isolationLevel: Transaction.READ_COMMITTED, + timeout: 1000, + }, + function(err, tx) { + if (err) return done(err); + expect(tx.isActive()).to.equal(true); + return done(); + }); + }); + it('returns false when connection is not active', function(done) { + Post.beginTransaction({ + isolationLevel: Transaction.READ_COMMITTED, + timeout: 1000, + }, + function(err, tx) { + if (err) return done(err); + delete tx.connection; + expect(tx.isActive()).to.equal(false); + return done(); + }); + }); + }); + describe('transaction instance', function() { function TestTransaction(connector, connection) { this.connector = connector;