From e2fa43031e552745aea9c30675374bb6f786b3b8 Mon Sep 17 00:00:00 2001 From: Tobias Reiss Date: Mon, 20 Apr 2015 00:43:55 +0200 Subject: [PATCH] should call new and old constructor with arguments --- src/utils/__tests__/PooledClass-test.js | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/utils/__tests__/PooledClass-test.js b/src/utils/__tests__/PooledClass-test.js index 15c3de8b9d..f4ecfced05 100644 --- a/src/utils/__tests__/PooledClass-test.js +++ b/src/utils/__tests__/PooledClass-test.js @@ -71,6 +71,32 @@ describe('Pooled class', function() { expect(log).toEqual(['a', 'b']); }); + it('should call a new constructor with arguments', function() { + var log = []; + var PoolableClassWithOneArgument = function(a) { + log.push(a); + }; + PooledClass.addPoolingTo( + PoolableClassWithOneArgument + ); + PoolableClassWithOneArgument.getPooled('new'); + expect(log).toEqual(['new']); + }); + + it('should call an old constructor with arguments', function() { + var log = []; + var PoolableClassWithOneArgument = function(a) { + log.push(a); + }; + PooledClass.addPoolingTo( + PoolableClassWithOneArgument + ); + var instance = PoolableClassWithOneArgument.getPooled('new'); + PoolableClassWithOneArgument.release(instance); + PoolableClassWithOneArgument.getPooled('old'); + expect(log).toEqual(['new', 'old']); + }); + it('should throw when the class releases an instance of a different type', function() { var RandomClass = function() {};