mirror of
https://github.com/jquery/jquery-ui.git
synced 2026-04-20 03:02:41 -04:00
Merged in /branches/dev r3251:3620 (excluding autocomplete, modal, tooltip, menu; including menu static tests).
This commit is contained in:
56
tests/unit/button/button.html
Normal file
56
tests/unit/button/button.html
Normal file
@@ -0,0 +1,56 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>jQuery UI Button Test Suite</title>
|
||||
|
||||
<script type="text/javascript" src="../../../jquery-1.3.2.js"></script>
|
||||
<script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
|
||||
<script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
|
||||
<script type="text/javascript" src="../../../ui/jquery.ui.button.js"></script>
|
||||
|
||||
<link type="text/css" href="../testsuite.css" rel="stylesheet" />
|
||||
<script type="text/javascript" src="../../../external/testrunner-r6588.js"></script>
|
||||
<script type="text/javascript" src="../../jquery.simulate.js"></script>
|
||||
<script type="text/javascript" src="../testsuite.js"></script>
|
||||
|
||||
<script type="text/javascript" src="button_core.js"></script>
|
||||
<script type="text/javascript" src="button_defaults.js"></script>
|
||||
<script type="text/javascript" src="button_events.js"></script>
|
||||
<script type="text/javascript" src="button_methods.js"></script>
|
||||
<script type="text/javascript" src="button_options.js"></script>
|
||||
<script type="text/javascript" src="button_tickets.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<div><button id="button" class="foo">Label</button></div>
|
||||
|
||||
<div id="radio0" style="margin-top: 2em;">
|
||||
<input type="radio" id="radio01" name="radio" checked="checked" /><label for="radio01">Choice 1</label>
|
||||
<input type="radio" id="radio02" name="radio" /><label for="radio02">Choice 2</label>
|
||||
<input type="radio" id="radio03" name="radio" /><label for="radio03">Choice 3</label>
|
||||
</div>
|
||||
<form>
|
||||
<div id="radio1" style="margin-top: 2em;">
|
||||
<input type="radio" id="radio11" name="radio" /><label for="radio11">Choice 1</label>
|
||||
<input type="radio" id="radio12" name="radio" checked="checked" /><label for="radio12">Choice 2</label>
|
||||
<input type="radio" id="radio13" name="radio" /><label for="radio13">Choice 3</label>
|
||||
</div>
|
||||
</form>
|
||||
<form>
|
||||
<div id="radio2" style="margin-top: 2em;">
|
||||
<input type="radio" id="radio21" name="radio" /><label for="radio21">Choice 1</label>
|
||||
<input type="radio" id="radio22" name="radio" /><label for="radio22">Choice 2</label>
|
||||
<input type="radio" id="radio23" name="radio" checked="checked" /><label for="radio23">Choice 3</label>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<input type="checkbox" id="check" /><label for="check">Toggle</label>
|
||||
|
||||
<div><input id="submit" type="submit" value="Label" /></div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
70
tests/unit/button/button_core.js
Normal file
70
tests/unit/button/button_core.js
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* button_core.js
|
||||
*/
|
||||
|
||||
|
||||
(function($) {
|
||||
|
||||
module("button: core");
|
||||
|
||||
test("checkbox", function() {
|
||||
var input = $("#check");
|
||||
label = $("label[for=check]");
|
||||
ok( input.is(":visble") );
|
||||
ok( label.is(":not(.ui-button)") );
|
||||
input.button();
|
||||
ok( input.is(":hidden") );
|
||||
ok( label.is(".ui-button") );
|
||||
});
|
||||
|
||||
test("radios", function() {
|
||||
var inputs = $("#radio0 input");
|
||||
labels = $("#radio0 label");
|
||||
ok( inputs.is(":visble") );
|
||||
ok( labels.is(":not(.ui-button)") );
|
||||
inputs.button();
|
||||
ok( inputs.is(":hidden") );
|
||||
ok( labels.is(".ui-button") );
|
||||
});
|
||||
|
||||
function assert(noForm, form1, form2) {
|
||||
ok( $("#radio0 .ui-button" + noForm).is(".ui-state-active") );
|
||||
ok( $("#radio1 .ui-button" + form1).is(".ui-state-active") );
|
||||
ok( $("#radio2 .ui-button" + form2).is(".ui-state-active") );
|
||||
}
|
||||
|
||||
test("radio groups", function() {
|
||||
$(":radio").button();
|
||||
assert(":eq(0)", ":eq(1)", ":eq(2)");
|
||||
|
||||
// click outside of forms
|
||||
$("#radio0 .ui-button:eq(1)").click();
|
||||
assert(":eq(1)", ":eq(1)", ":eq(2)");
|
||||
|
||||
// click in first form
|
||||
$("#radio1 .ui-button:eq(0)").click();
|
||||
assert(":eq(1)", ":eq(0)", ":eq(2)");
|
||||
|
||||
// click in second form
|
||||
$("#radio2 .ui-button:eq(0)").click();
|
||||
assert(":eq(1)", ":eq(0)", ":eq(0)");
|
||||
});
|
||||
|
||||
test("input type submit, don't create child elements", function() {
|
||||
var input = $("#submit")
|
||||
same( input.children().length, 0 );
|
||||
input.button();
|
||||
same( input.children().length, 0 );
|
||||
});
|
||||
|
||||
test("buttonset", function() {
|
||||
var set = $("#radio1").buttonset();
|
||||
ok( set.is(".ui-button-set") );
|
||||
same( set.children(".ui-button").length, 3 );
|
||||
same( set.children("input:radio:hidden").length, 3 );
|
||||
ok( set.children("label:eq(0)").is(".ui-button.ui-corner-left:not(.ui-corner-all)") );
|
||||
ok( set.children("label:eq(1)").is(".ui-button:not(.ui-corner-all)") );
|
||||
ok( set.children("label:eq(2)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") );
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
15
tests/unit/button/button_defaults.js
Normal file
15
tests/unit/button/button_defaults.js
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* button_defaults.js
|
||||
*/
|
||||
|
||||
var button_defaults = {
|
||||
disabled: false,
|
||||
text: true,
|
||||
label: null,
|
||||
icons: {
|
||||
primary: null,
|
||||
secondary: null
|
||||
}
|
||||
};
|
||||
|
||||
commonWidgetTests('button', { defaults: button_defaults });
|
||||
17
tests/unit/button/button_events.js
Normal file
17
tests/unit/button/button_events.js
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* button_events.js
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
module("button: events");
|
||||
|
||||
test("click-through", function() {
|
||||
expect(2);
|
||||
var set = $("#radio1").buttonset();
|
||||
set.find("input:first").click(function() {
|
||||
ok( true );
|
||||
});
|
||||
ok( set.find("label:first").click().is(".ui-button") );
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
15
tests/unit/button/button_methods.js
Normal file
15
tests/unit/button/button_methods.js
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* button_methods.js
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
|
||||
module("button: methods");
|
||||
|
||||
test("destroy", function() {
|
||||
var beforeHtml = $("#button").parent().html();
|
||||
var afterHtml = $("#button").button().button("destroy").parent().html();
|
||||
same( beforeHtml, afterHtml );
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
69
tests/unit/button/button_options.js
Normal file
69
tests/unit/button/button_options.js
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* button_options.js
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
module("button: options");
|
||||
|
||||
test("text false without icon", function() {
|
||||
$("#button").button({
|
||||
text: false
|
||||
});
|
||||
ok( $("#button").is(".ui-button-text-only:not(.ui-button-icon-only)") );
|
||||
|
||||
$("#button").button("destroy");
|
||||
});
|
||||
|
||||
test("text false with icon", function() {
|
||||
$("#button").button({
|
||||
text: false,
|
||||
icons: {
|
||||
primary: "iconclass"
|
||||
}
|
||||
});
|
||||
ok( $("#button").is(".ui-button-icon-only:not(.ui-button-text):has(span.ui-icon.iconclass)") );
|
||||
|
||||
$("#button").button("destroy");
|
||||
});
|
||||
|
||||
test("label, default", function() {
|
||||
$("#button").button();
|
||||
same( $("#button").text(), "Label" );
|
||||
|
||||
$("#button").button("destroy");
|
||||
});
|
||||
|
||||
test("label", function() {
|
||||
$("#button").button({
|
||||
label: "xxx"
|
||||
});
|
||||
same( $("#button").text(), "xxx" );
|
||||
|
||||
$("#button").button("destroy");
|
||||
});
|
||||
|
||||
test("label default with input type submit", function() {
|
||||
same( $("#submit").button().val(), "Label" );
|
||||
});
|
||||
|
||||
test("label with input type submit", function() {
|
||||
var label = $("#submit").button({
|
||||
label: "xxx"
|
||||
}).val();
|
||||
same( label, "xxx" );
|
||||
});
|
||||
|
||||
test("icons", function() {
|
||||
$("#button").button({
|
||||
text: false,
|
||||
icons: {
|
||||
primary: "iconclass",
|
||||
secondary: "iconclass2"
|
||||
}
|
||||
});
|
||||
ok( $("#button").is(":has(span.ui-icon.ui-button-icon-primary.iconclass):has(span.ui-icon.ui-button-icon-secondary.iconclass2)") );
|
||||
|
||||
$("#button").button("destroy");
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
10
tests/unit/button/button_tickets.js
Normal file
10
tests/unit/button/button_tickets.js
Normal file
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* button_tickets.js
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
module("button: tickets");
|
||||
|
||||
|
||||
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user