From 97f3c5ed5d6bef064b89756bc1055fb36a8a804c Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Thu, 11 Nov 2010 21:02:09 -0500 Subject: [PATCH] Added tests to ensure it is possible to extend classes that were not previously created using Class.extend() --- test/test-class-extend.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/test-class-extend.js b/test/test-class-extend.js index b16fcf9..e716c0d 100644 --- a/test/test-class-extend.js +++ b/test/test-class-extend.js @@ -99,3 +99,30 @@ assert.ok( "Subtypes should not be considered instances of their siblings" ); + +// to test inheritance of classes that were not previously created via the +// Class.extend() method +var OtherClass = function() {}; +OtherClass.prototype = +{ + foo: 'bla', +}; + +var SubOther = Class.extend( OtherClass, +{ + newFoo: 2, +}); + + +assert.equal( + SubOther.prototype.foo, + OtherClass.prototype.foo, + "Prototype of existing class should be copied to subclass" +); + +assert.notEqual( + SubOther.prototype.newFoo, + undefined, + "Subtype should contain extended members" +); +