jquery-ui/tests/unit/core/core.js

158 lines
3.9 KiB
JavaScript
Raw Normal View History

2008-09-20 17:42:04 +00:00
/*
* core unit tests
*/
(function($) {
module('core - jQuery extensions');
test('focus - original functionality', function() {
expect(1);
$('#inputTabindex0')
.focus(function() {
ok(true, 'event triggered');
})
.focus();
});
asyncTest('focus', function() {
expect(2);
$('#inputTabindex0')
.focus(function() {
ok(true, 'event triggered');
})
.focus(500, function() {
ok(true, 'callback triggered');
$(this).unbind('focus');
start();
});
});
test('zIndex', function() {
2010-01-29 18:38:21 +00:00
var el = $('#zIndexAutoWithParent'),
parent = el.parent();
equal(el.zIndex(), 100, 'zIndex traverses up to find value');
equal(parent.zIndex(200), parent, 'zIndex setter is chainable');
equal(el.zIndex(), 200, 'zIndex setter changed zIndex');
2010-01-29 18:38:21 +00:00
el = $('#zIndexAutoWithParentViaCSS');
equal(el.zIndex(), 0, 'zIndex traverses up to find CSS value, not found because not positioned');
2010-01-29 18:38:21 +00:00
el = $('#zIndexAutoWithParentViaCSSPositioned');
equal(el.zIndex(), 100, 'zIndex traverses up to find CSS value');
2010-01-29 18:38:21 +00:00
el.parent().zIndex(200);
equal(el.zIndex(), 200, 'zIndex setter changed zIndex, overriding CSS');
equal($('#zIndexAutoNoParent').zIndex(), 0, 'zIndex never explicitly set in hierarchy');
});
test( "innerWidth - getter", function() {
var el = $( "#dimensions" );
equal( el.innerWidth(), 122, "getter passthru" );
el.hide();
equal( el.innerWidth(), 122, "getter passthru when hidden" );
});
test( "innerWidth - setter", function() {
var el = $( "#dimensions" );
el.innerWidth( 120 );
equal( el.width(), 98, "width set properly" );
el.hide();
el.innerWidth( 100 );
equal( el.width(), 78, "width set properly when hidden" );
});
test( "innerHeight - getter", function() {
var el = $( "#dimensions" );
equal( el.innerHeight(), 70, "getter passthru" );
el.hide();
equal( el.innerHeight(), 70, "getter passthru when hidden" );
});
test( "innerHeight - setter", function() {
var el = $( "#dimensions" );
el.innerHeight( 60 );
equal( el.height(), 40, "height set properly" );
el.hide();
el.innerHeight( 50 );
equal( el.height(), 30, "height set properly when hidden" );
});
test( "outerWidth - getter", function() {
var el = $( "#dimensions" );
equal( el.outerWidth(), 140, "getter passthru" );
el.hide();
equal( el.outerWidth(), 140, "getter passthru when hidden" );
});
test( "outerWidth - setter", function() {
var el = $( "#dimensions" );
el.outerWidth( 130 );
equal( el.width(), 90, "width set properly" );
el.hide();
el.outerWidth( 120 );
equal( el.width(), 80, "width set properly when hidden" );
});
test( "outerWidth(true) - getter", function() {
var el = $( "#dimensions" );
equal( el.outerWidth(true), 154, "getter passthru w/ margin" );
el.hide();
equal( el.outerWidth(true), 154, "getter passthru w/ margin when hidden" );
});
test( "outerWidth(true) - setter", function() {
var el = $( "#dimensions" );
el.outerWidth( 130, true );
equal( el.width(), 76, "width set properly" );
el.hide();
el.outerWidth( 120, true );
equal( el.width(), 66, "width set properly when hidden" );
});
test( "outerHeight - getter", function() {
var el = $( "#dimensions" );
equal( el.outerHeight(), 86, "getter passthru" );
el.hide();
equal( el.outerHeight(), 86, "getter passthru when hidden" );
});
test( "outerHeight - setter", function() {
var el = $( "#dimensions" );
el.outerHeight( 80 );
equal( el.height(), 44, "height set properly" );
el.hide();
el.outerHeight( 70 );
equal( el.height(), 34, "height set properly when hidden" );
});
test( "outerHeight(true) - getter", function() {
var el = $( "#dimensions" );
equal( el.outerHeight(true), 98, "getter passthru w/ margin" );
el.hide();
equal( el.outerHeight(true), 98, "getter passthru w/ margin when hidden" );
});
test( "outerHeight(true) - setter", function() {
var el = $( "#dimensions" );
el.outerHeight( 90, true );
equal( el.height(), 42, "height set properly" );
el.hide();
el.outerHeight( 80, true );
equal( el.height(), 32, "height set properly when hidden" );
});
2008-09-20 17:42:04 +00:00
})(jQuery);