1
0
mirror of https://github.com/videojs/video.js.git synced 2025-11-29 23:07:51 +02:00

Changed to vjs.obj.function naming for object related functions.

Updated mergeOptions to just options.
This commit is contained in:
Steve Heffernan
2013-01-25 17:36:40 -08:00
parent c7d3b9ebf9
commit dc18f475f8
13 changed files with 146 additions and 92 deletions

View File

@@ -37,24 +37,25 @@ test('should init child coponents from options', function(){
});
test('should do a deep merge of child options', function(){
var compDefaultOptions = {
'children': {
// Create a default option for component
vjs.Component.prototype.options_ = {
'example': {
'childOne': { 'foo': 'bar', 'asdf': 'fdsa' },
'childTwo': {},
'childThree': {}
}
}
var compInitOptions = {
'children': {
var comp = new vjs.Component(getFakePlayer(), {
'example': {
'childOne': { 'foo': 'baz', 'abc': '123' },
'childThree': null,
'childFour': {}
}
}
});
var mergedOptions = vjs.Component.prototype.mergeOptions(compDefaultOptions, compInitOptions);
var children = mergedOptions['children'];
var mergedOptions = comp.options();
var children = mergedOptions['example'];
ok(children['childOne']['foo'] === 'baz', 'value three levels deep overridden');
ok(children['childOne']['asdf'] === 'fdsa', 'value three levels deep maintained');
@@ -62,6 +63,11 @@ test('should do a deep merge of child options', function(){
ok(children['childTwo'], 'object two levels deep maintained');
ok(children['childThree'] === null, 'object two levels deep removed');
ok(children['childFour'], 'object two levels deep added');
ok(vjs.Component.prototype.options_['example']['childOne']['foo'] === 'bar', 'prototype options were not overridden');
// Reset default component options to none
vjs.Component.prototype.options_ = null;
});
test('should dispose of component and children', function(){

View File

@@ -5,7 +5,7 @@ test('should create a video tag and have access children in old IE', function(){
fixture.innerHTML += "<video id='test_vid_id'><source type='video/mp4'></video>";
vid = document.getElementById('test_vid_id');
var vid = document.getElementById('test_vid_id');
ok(vid.childNodes.length === 1);
ok(vid.childNodes[0].getAttribute('type') === 'video/mp4');

View File

@@ -22,13 +22,25 @@ test('should loop through each property on an object', function(){
}
// Add 3 to each value
vjs.eachProp(asdf, function(key, value){
vjs.obj.each(asdf, function(key, value){
asdf[key] = value + 3;
});
deepEqual(asdf,{a:4,b:5,'c':6})
});
test('should copy an object', function(){
var asdf = {
a: 1,
b: 2,
'c': 3
}
var fdsa = vjs.obj.copy(asdf);
deepEqual(asdf,fdsa)
});
test('should add context to a function', function(){
var newContext = { test: 'obj'};
var asdf = function(){

View File

@@ -1,6 +1,9 @@
// Fake a media playback tech controller so that player tests
// Fake a media playback tech controller so that player tests
// can run without HTML5 or Flash, of which PhantomJS supports neither.
/**
* @constructor
*/
vjs.MediaFaker = function(player, options, onReady){
goog.base(this, player, options, onReady);
@@ -30,4 +33,4 @@ vjs.MediaFaker.prototype.volume = function(){ return 0; };
goog.exportSymbol('videojs.MediaFaker', vjs.MediaFaker);
goog.exportProperty(vjs.MediaFaker, 'isSupported', vjs.MediaFaker.isSupported);
goog.exportProperty(vjs.MediaFaker, 'canPlaySource', vjs.MediaFaker.canPlaySource);
goog.exportProperty(vjs.MediaFaker, 'canPlaySource', vjs.MediaFaker.canPlaySource);

View File

@@ -8,12 +8,13 @@ var PlayerTest = {
return videoTag;
},
makePlayer: function(playerOptions){
var player;
var videoTag = PlayerTest.makeTag();
var fixture = document.getElementById('qunit-fixture');
fixture.appendChild(videoTag);
var opts = vjs.merge({
var opts = vjs.obj.merge({
'techOrder': ['mediaFaker']
}, playerOptions);