module('Lib');
test('should create an element', function(){
var div = vjs.createEl();
var span = vjs.createEl('span', { 'data-test': 'asdf', innerHTML:'fdsa' });
ok(div.nodeName === 'DIV');
ok(span.nodeName === 'SPAN');
ok(span['data-test'] === 'asdf');
ok(span.innerHTML === 'fdsa');
});
test('should make a string start with an uppercase letter', function(){
var foo = vjs.capitalize('bar');
ok(foo === 'Bar');
});
test('should loop through each property on an object', function(){
var asdf = {
a: 1,
b: 2,
'c': 3
};
// Add 3 to each 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(){
ok(this === newContext);
};
var fdsa = vjs.bind(newContext, asdf);
fdsa();
});
test('should add and remove a class name on an element', function(){
var el = document.createElement('div');
vjs.addClass(el, 'test-class');
ok(el.className === 'test-class', 'class added');
vjs.addClass(el, 'test-class');
ok(el.className === 'test-class', 'same class not duplicated');
vjs.addClass(el, 'test-class2');
ok(el.className === 'test-class test-class2', 'added second class');
vjs.removeClass(el, 'test-class');
ok(el.className === 'test-class2', 'removed first class');
});
test('should get and remove data from an element', function(){
var el = document.createElement('div');
var data = vjs.getData(el);
var id = el[vjs.expando];
ok(typeof data === 'object', 'data object created');
// Add data
var testData = { asdf: 'fdsa' };
data.test = testData;
ok(vjs.getData(el).test === testData, 'data added');
// Remove all data
vjs.removeData(el);
ok(!vjs.cache[id], 'cached item nulled');
ok(el[vjs.expando] === null || el[vjs.expando] === undefined, 'element data id removed');
});
test('should read tag attributes from elements, including HTML5 in all browsers', function(){
var container = document.createElement('div');
var tags = '';
tags += '