|
|
@@ -39,89 +39,6 @@ describe( 'extend()', function() {
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
-describe( 'extendMixin', function() {
|
|
|
- it( 'should extend classes', function() {
|
|
|
- var utils = modules.utils;
|
|
|
-
|
|
|
- function Car( name ) {
|
|
|
- this.name = name;
|
|
|
- }
|
|
|
-
|
|
|
- Car.prototype.addGas = function() {};
|
|
|
-
|
|
|
- Car.extend = utils.extendMixin;
|
|
|
-
|
|
|
- var Truck = Car.extend( {
|
|
|
- loadContainers: function() {}
|
|
|
- } );
|
|
|
-
|
|
|
- var volvoTruck = new Truck( 'Volvo' );
|
|
|
-
|
|
|
- expect( volvoTruck ).to.be.an.instanceof( Truck );
|
|
|
- expect( volvoTruck ).to.be.an.instanceof( Car );
|
|
|
- expect( volvoTruck ).to.have.property( 'name' ).to.equals( 'Volvo' );
|
|
|
- expect( volvoTruck ).to.have.property( 'addGas' ).to.be.a( 'function' );
|
|
|
- expect( volvoTruck ).to.have.property( 'loadContainers' ).to.be.a( 'function' );
|
|
|
-
|
|
|
- var Spacecraft = Truck.extend( {
|
|
|
- jumpToHyperspace: function() {}
|
|
|
- } );
|
|
|
-
|
|
|
- var falcon = new Spacecraft( 'Millennium Falcon' );
|
|
|
- expect( falcon ).to.be.an.instanceof( Spacecraft );
|
|
|
- expect( falcon ).to.be.an.instanceof( Truck );
|
|
|
- expect( falcon ).to.be.an.instanceof( Car );
|
|
|
- expect( falcon ).to.have.property( 'name' ).to.equals( 'Millennium Falcon' );
|
|
|
- expect( falcon ).to.have.property( 'addGas' ).to.be.a( 'function' );
|
|
|
- expect( falcon ).to.have.property( 'loadContainers' ).to.be.a( 'function' );
|
|
|
- expect( falcon ).to.have.property( 'jumpToHyperspace' ).to.be.a( 'function' );
|
|
|
- } );
|
|
|
-
|
|
|
- it( 'should extend the prototype and add statics', function() {
|
|
|
- var utils = modules.utils;
|
|
|
-
|
|
|
- function Car() {}
|
|
|
-
|
|
|
- Car.extend = utils.extendMixin;
|
|
|
-
|
|
|
- var Truck = Car.extend( {
|
|
|
- property1: 1,
|
|
|
- property2: function() {}
|
|
|
- }, {
|
|
|
- static1: 1,
|
|
|
- static2: function() {}
|
|
|
- } );
|
|
|
-
|
|
|
- expect( Truck ).to.have.property( 'static1' ).to.equals( 1 );
|
|
|
- expect( Truck ).to.have.property( 'static2' ).to.be.a( 'function' );
|
|
|
-
|
|
|
- var truck = new Truck();
|
|
|
-
|
|
|
- expect( truck ).to.have.property( 'property1' ).to.equals( 1 );
|
|
|
- expect( truck ).to.have.property( 'property2' ).to.be.a( 'function' );
|
|
|
- } );
|
|
|
-
|
|
|
- it( 'should use a custom constructor', function() {
|
|
|
- var utils = modules.utils;
|
|
|
-
|
|
|
- function customConstructor() {}
|
|
|
-
|
|
|
- function Car() {}
|
|
|
-
|
|
|
- Car.extend = utils.extendMixin;
|
|
|
-
|
|
|
- var Truck = Car.extend( {
|
|
|
- constructor: customConstructor
|
|
|
- } );
|
|
|
-
|
|
|
- expect( Truck ).to.equals( customConstructor );
|
|
|
- expect( Truck.prototype ).to.not.have.ownProperty( 'constructor' );
|
|
|
-
|
|
|
- expect( new Truck() ).to.be.an.instanceof( Truck );
|
|
|
- expect( new Truck() ).to.be.an.instanceof( Car );
|
|
|
- } );
|
|
|
-} );
|
|
|
-
|
|
|
describe( 'spy', function() {
|
|
|
it( 'should not have `called` after creation', function() {
|
|
|
var utils = modules.utils;
|