2008-09-20 17:42:04 +00:00
|
|
|
/*
|
|
|
|
* core unit tests
|
|
|
|
*/
|
|
|
|
(function($) {
|
|
|
|
|
2009-09-01 08:16:10 +00:00
|
|
|
module('core - jQuery extensions');
|
2008-11-07 13:49:23 +00:00
|
|
|
|
|
|
|
test("attr - aria", function() {
|
2008-11-15 04:29:08 +00:00
|
|
|
expect(6);
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-11-15 04:29:08 +00:00
|
|
|
var el = $('#aria');
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-11-15 04:29:08 +00:00
|
|
|
ok(!el.attr('role'), 'role is empty via attr');
|
|
|
|
equals(el.attr('role', 'tablist').attr('role'), 'tablist', 'role is tablist');
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-11-15 04:29:08 +00:00
|
|
|
equals(el.attr('aria-expanded'), undefined, 'aria expanded is undefined');
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-11-15 04:29:08 +00:00
|
|
|
el.attr('aria-expanded', true);
|
|
|
|
equals(el.attr('aria-expanded'), 'true', 'aria expanded is true');
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-11-15 04:29:08 +00:00
|
|
|
el.removeAttr('aria-expanded');
|
|
|
|
equals(el.attr('aria-expanded'), undefined, 'aria expanded is undefined after removing');
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-11-15 04:29:08 +00:00
|
|
|
el.attr('aria-expanded', false);
|
|
|
|
equals(el.attr('aria-expanded'), 'false', 'aria expanded is false');
|
2008-09-22 15:47:41 +00:00
|
|
|
});
|
|
|
|
|
2009-04-18 13:04:07 +00:00
|
|
|
test('focus', function() {
|
|
|
|
expect(3);
|
|
|
|
|
|
|
|
var el = $('#inputTabindex0'),
|
|
|
|
// used to remove focus from the main element
|
|
|
|
other = $('#inputTabindex10');
|
|
|
|
|
|
|
|
// test original functionality
|
|
|
|
el.focus(function() {
|
|
|
|
ok(true, 'event triggered');
|
|
|
|
});
|
|
|
|
el.focus();
|
|
|
|
other.focus();
|
|
|
|
|
|
|
|
// trigger event handler + callback
|
|
|
|
stop();
|
|
|
|
el.focus(500, function() {
|
|
|
|
ok(true, 'callback triggered');
|
2010-03-20 14:37:36 +00:00
|
|
|
start();
|
2009-04-18 13:04:07 +00:00
|
|
|
});
|
|
|
|
other.focus();
|
|
|
|
});
|
|
|
|
|
2009-08-05 13:30:55 +00:00
|
|
|
test('zIndex', function() {
|
2010-01-29 18:38:21 +00:00
|
|
|
var el = $('#zIndexAutoWithParent'),
|
|
|
|
parent = el.parent();
|
2009-08-05 13:30:55 +00:00
|
|
|
equals(el.zIndex(), 100, 'zIndex traverses up to find value');
|
2010-01-29 18:38:21 +00:00
|
|
|
equals(parent.zIndex(200), parent, 'zIndex setter is chainable');
|
2009-08-05 13:30:55 +00:00
|
|
|
equals(el.zIndex(), 200, 'zIndex setter changed zIndex');
|
|
|
|
|
2010-01-29 18:38:21 +00:00
|
|
|
el = $('#zIndexAutoWithParentViaCSS');
|
|
|
|
equals(el.zIndex(), 0, 'zIndex traverses up to find CSS value, not found because not positioned');
|
|
|
|
|
|
|
|
el = $('#zIndexAutoWithParentViaCSSPositioned');
|
|
|
|
equals(el.zIndex(), 100, 'zIndex traverses up to find CSS value');
|
|
|
|
el.parent().zIndex(200);
|
|
|
|
equals(el.zIndex(), 200, 'zIndex setter changed zIndex, overriding CSS');
|
|
|
|
|
2009-08-05 13:30:55 +00:00
|
|
|
equals($('#zIndexAutoNoParent').zIndex(), 0, 'zIndex never explicitly set in hierarchy');
|
|
|
|
});
|
|
|
|
|
2008-09-20 17:42:04 +00:00
|
|
|
})(jQuery);
|