should call new and old constructor with arguments
Tobias Reiss committed
Apr 20, 2015 at 00:43 UTC
e2fa43031e552745aea9c30675374bb6f786b3b8
1 file changed
+26
src/utils/__tests__/PooledClass-test.js
+26
@@ -71,6 +71,32 @@ describe('Pooled class', function() {
71
expect(log).toEqual(['a', 'b']);
72
});
73
74
+ it('should call a new constructor with arguments', function() {
75
+ var log = [];
76
+ var PoolableClassWithOneArgument = function(a) {
77
+ log.push(a);
78
+ };
79
+ PooledClass.addPoolingTo(
80
+ PoolableClassWithOneArgument
81
+ );
82
+ PoolableClassWithOneArgument.getPooled('new');
83
+ expect(log).toEqual(['new']);
84
+ });
85
+
86
+ it('should call an old constructor with arguments', function() {
87
+ var log = [];
88
+ var PoolableClassWithOneArgument = function(a) {
89
+ log.push(a);
90
+ };
91
+ PooledClass.addPoolingTo(
92
+ PoolableClassWithOneArgument
93
+ );
94
+ var instance = PoolableClassWithOneArgument.getPooled('new');
95
+ PoolableClassWithOneArgument.release(instance);
96
+ PoolableClassWithOneArgument.getPooled('old');
97
+ expect(log).toEqual(['new', 'old']);
98
+ });
99
+
100
it('should throw when the class releases an instance of a different type',
101
function() {
102
var RandomClass = function() {};