diff options
author | Richard Worth <rdworth@gmail.com> | 2009-01-07 03:31:15 +0000 |
---|---|---|
committer | Richard Worth <rdworth@gmail.com> | 2009-01-07 03:31:15 +0000 |
commit | b792bd46ec9b1b55bf2289faedd4ab3614c9319a (patch) | |
tree | 4b1736c703d392ec07fd4a5ae3390151470ae933 /tests/unit/core | |
parent | 4707debd645e63ea22d7a076e97a34eb3d310ebc (diff) | |
download | jquery-ui-b792bd46ec9b1b55bf2289faedd4ab3614c9319a.tar.gz jquery-ui-b792bd46ec9b1b55bf2289faedd4ab3614c9319a.zip |
restructured unit tests folder
Diffstat (limited to 'tests/unit/core')
-rw-r--r-- | tests/unit/core/core.html | 63 | ||||
-rw-r--r-- | tests/unit/core/core.js | 78 |
2 files changed, 141 insertions, 0 deletions
diff --git a/tests/unit/core/core.html b/tests/unit/core/core.html new file mode 100644 index 000000000..c8d88c88a --- /dev/null +++ b/tests/unit/core/core.html @@ -0,0 +1,63 @@ +<!doctype html> +<html lang="en"> +<head> + <title>jQuery UI Core Test Suite</title> + + <script type="text/javascript" src="../../../jquery-1.3pre.js"></script> + <script type="text/javascript" src="../../../ui/ui.core.js"></script> + + <link type="text/css" href="../testsuite.css" rel="stylesheet" /> + <script type="text/javascript" src="../testsuite.js"></script> + <script type="text/javascript" src="../../../external/qunit/testrunner.js"></script> + <script type="text/javascript" src="../../../external/simulate/jquery.simulate.js"></script> + + <script type="text/javascript" src="core.js"></script> +</head> +<body> + +<div id="main"> + <div id="wrap1"> + <input id="input1-1" /> + <input type="text" id="input1-2" /> + <input type="checkbox" id="input1-3" /> + <input type="radio" id="input1-4" /> + <input type="button" id="input1-5" /> + <input type="hidden" id="input1-6" /> + <select id="input1-7"></select> + <textarea id="input1-8"></textarea> + <a href="#" id="anchor1-1">anchor</a> + <a id="anchor1-2">anchor</a> + </div> + <div id="wrap2"> + <input id="input2-1" disabled="disabled" /> + <input type="text" id="input2-2" disabled="disabled" /> + <input type="checkbox" id="input2-3" disabled="disabled" /> + <input type="radio" id="input2-4" disabled="disabled" /> + <input type="button" id="input2-5" disabled="disabled" /> + <input type="hidden" id="input2-6" disabled="disabled" /> + <select id="input2-7" disabled="disabled"></select> + <textarea id="input2-8" disabled="disabled"></textarea> + </div> + <div id="wrap3"> + <div id="wrap3-1" style="display: none;"> + <input id="input3-1" /> + <a href="#" id="anchor3-1">anchor</a> + </div> + <div id="wrap3-2" style="visibility: hidden;"> + <input id="input3-2" /> + <a href="#" id="anchor3-2">anchor</a> + </div> + <input id="input3-3" style="display: none;"> + <input id="input3-4" style="visibility: hidden;"> + </div> + <div id="wrap4"> + <input id="input4-1" tabindex="0" /> + <input id="input4-2" tabindex="10" /> + <input id="input4-3" tabindex="-1" /> + <input id="input4-4" tabindex="-50" /> + </div> + <div id="aria"></div> +</div> + +</body> +</html> diff --git a/tests/unit/core/core.js b/tests/unit/core/core.js new file mode 100644 index 000000000..4be475486 --- /dev/null +++ b/tests/unit/core/core.js @@ -0,0 +1,78 @@ +/* + * core unit tests + */ +(function($) { + +module("selectors"); + +test("tabbable - enabled elements", function() { + expect(10); + + ok( $('#input1-1').is(':tabbable'), 'input, no type'); + ok( $('#input1-2').is(':tabbable'), 'input, type text'); + ok( $('#input1-3').is(':tabbable'), 'input, type checkbox'); + ok( $('#input1-4').is(':tabbable'), 'input, type radio'); + ok( $('#input1-5').is(':tabbable'), 'input, type button'); + ok(!$('#input1-6').is(':tabbable'), 'input, type hidden'); + ok( $('#input1-7').is(':tabbable'), 'select'); + ok( $('#input1-8').is(':tabbable'), 'textarea'); + ok( $('#anchor1-1').is(':tabbable'), 'anchor with href'); + ok(!$('#anchor1-2').is(':tabbable'), 'anchor without href'); +}); + +test("tabbable - disabled elements", function() { + expect(8); + + ok(!$('#input2-1').is(':tabbable'), 'input, no type'); + ok(!$('#input2-2').is(':tabbable'), 'input, type text'); + ok(!$('#input2-3').is(':tabbable'), 'input, type checkbox'); + ok(!$('#input2-4').is(':tabbable'), 'input, type radio'); + ok(!$('#input2-5').is(':tabbable'), 'input, type button'); + ok(!$('#input2-6').is(':tabbable'), 'input, type hidden'); + ok(!$('#input2-7').is(':tabbable'), 'select'); + ok(!$('#input2-8').is(':tabbable'), 'textarea'); +}); + +test("tabbable - hidden styles", function() { + expect(6); + + ok(!$('#input3-1').is(':tabbable'), 'input, hidden wrapper - display: none'); + ok(!$('#anchor3-1').is(':tabbable'), 'anchor, hidden wrapper - display: none'); + ok(!$('#input3-2').is(':tabbable'), 'input, hidden wrapper - visibility: hidden'); + ok(!$('#anchor3-2').is(':tabbable'), 'anchor, hidden wrapper - visibility: hidden'); + ok(!$('#input3-3').is(':tabbable'), 'input, display: none'); + ok(!$('#input3-4').is(':tabbable'), 'input, visibility: hidden'); +}); + +test("tabbable - tabindex", function() { + expect(4); + + ok( $('#input4-1').is(':tabbable'), 'input, tabindex 0'); + ok( $('#input4-2').is(':tabbable'), 'input, tabindex 10'); + ok(!$('#input4-3').is(':tabbable'), 'input, tabindex -1'); + ok(!$('#input4-4').is(':tabbable'), 'input, tabindex -50'); +}); + +module('jQuery extensions'); + +test("attr - aria", function() { + expect(6); + + var el = $('#aria'); + + ok(!el.attr('role'), 'role is empty via attr'); + equals(el.attr('role', 'tablist').attr('role'), 'tablist', 'role is tablist'); + + equals(el.attr('aria-expanded'), undefined, 'aria expanded is undefined'); + + el.attr('aria-expanded', true); + equals(el.attr('aria-expanded'), 'true', 'aria expanded is true'); + + el.removeAttr('aria-expanded'); + equals(el.attr('aria-expanded'), undefined, 'aria expanded is undefined after removing'); + + el.attr('aria-expanded', false); + equals(el.attr('aria-expanded'), 'false', 'aria expanded is false'); +}); + +})(jQuery); |