From 90fb45dffafc2e891b1ebca948ad33e6b94de112 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 7 Jan 2010 03:19:50 +0000 Subject: Merged in /branches/dev r3251:3620 (excluding autocomplete, modal, tooltip, menu; including menu static tests). --- tests/unit/button/button.html | 56 +++++++++++++++++++++++++++++ tests/unit/button/button_core.js | 70 ++++++++++++++++++++++++++++++++++++ tests/unit/button/button_defaults.js | 15 ++++++++ tests/unit/button/button_events.js | 17 +++++++++ tests/unit/button/button_methods.js | 15 ++++++++ tests/unit/button/button_options.js | 69 +++++++++++++++++++++++++++++++++++ tests/unit/button/button_tickets.js | 10 ++++++ 7 files changed, 252 insertions(+) create mode 100644 tests/unit/button/button.html create mode 100644 tests/unit/button/button_core.js create mode 100644 tests/unit/button/button_defaults.js create mode 100644 tests/unit/button/button_events.js create mode 100644 tests/unit/button/button_methods.js create mode 100644 tests/unit/button/button_options.js create mode 100644 tests/unit/button/button_tickets.js (limited to 'tests/unit/button') diff --git a/tests/unit/button/button.html b/tests/unit/button/button.html new file mode 100644 index 000000000..5017c9bc6 --- /dev/null +++ b/tests/unit/button/button.html @@ -0,0 +1,56 @@ + + + + jQuery UI Button Test Suite + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + + +
+
+
+ + + +
+
+
+
+ + + +
+
+ + + +
+
+ + + diff --git a/tests/unit/button/button_core.js b/tests/unit/button/button_core.js new file mode 100644 index 000000000..12016627f --- /dev/null +++ b/tests/unit/button/button_core.js @@ -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); diff --git a/tests/unit/button/button_defaults.js b/tests/unit/button/button_defaults.js new file mode 100644 index 000000000..f0152e3c2 --- /dev/null +++ b/tests/unit/button/button_defaults.js @@ -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 }); diff --git a/tests/unit/button/button_events.js b/tests/unit/button/button_events.js new file mode 100644 index 000000000..17f505458 --- /dev/null +++ b/tests/unit/button/button_events.js @@ -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); diff --git a/tests/unit/button/button_methods.js b/tests/unit/button/button_methods.js new file mode 100644 index 000000000..a162a8930 --- /dev/null +++ b/tests/unit/button/button_methods.js @@ -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); diff --git a/tests/unit/button/button_options.js b/tests/unit/button/button_options.js new file mode 100644 index 000000000..f44679a34 --- /dev/null +++ b/tests/unit/button/button_options.js @@ -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); diff --git a/tests/unit/button/button_tickets.js b/tests/unit/button/button_tickets.js new file mode 100644 index 000000000..d3b981e21 --- /dev/null +++ b/tests/unit/button/button_tickets.js @@ -0,0 +1,10 @@ +/* + * button_tickets.js + */ +(function($) { + +module("button: tickets"); + + + +})(jQuery); -- cgit v1.2.3