1
0
mirror of https://github.com/videojs/video.js.git synced 2025-07-13 01:30:17 +02:00

@heff added and `extends` function for external subclassing. closes #2078

This commit is contained in:
heff
2015-04-28 11:50:09 -07:00
parent 94f33c8d43
commit f19d13b9bb
5 changed files with 101 additions and 5 deletions

View File

@ -255,4 +255,27 @@ function testHelperMakeTag(){
return videoTag;
}
})();
test('should extend Component', function(){
var Component = videojs.getComponent('Component');
var MyComponent = videojs.extends(Component, {
constructor: function() {
this.bar = true;
},
foo: function() {
return true;
}
});
var myComponent = new MyComponent();
ok(myComponent instanceof Component, 'creates an instance of Component');
ok(myComponent instanceof MyComponent, 'creates an instance of MyComponent');
ok(myComponent.bar, 'the constructor function is used');
ok(myComponent.foo(), 'instance methods are applied');
var NoMethods = videojs.extends(Component);
var noMethods = new NoMethods({});
ok(noMethods.on, 'should extend component with no methods or constructor');
});
})();