module("button: core");
test("checkbox", function() {
+ expect( 4 );
var input = $("#check"),
label = $("label[for=check]");
ok( input.is(":visible") );
});
test("radios", function() {
+ expect( 4 );
var inputs = $("#radio0 input"),
labels = $("#radio0 label");
ok( inputs.is(":visible") );
}
test("radio groups", function() {
+ expect( 12 );
$("input[type=radio]").button();
assert(":eq(0)", ":eq(1)", ":eq(2)");
});
test("input type submit, don't create child elements", function() {
+ expect( 2 );
var input = $("#submit");
deepEqual( input.children().length, 0 );
input.button();
});
test("buttonset", function() {
+ expect( 6 );
var set = $("#radio1").buttonset();
ok( set.is(".ui-buttonset") );
deepEqual( set.children(".ui-button").length, 3 );
});
test("buttonset (rtl)", function() {
+ expect( 6 );
var set,
parent = $("#radio1").parent();
// Set to rtl
module("button: options");
test("disabled, explicit value", function() {
+ expect( 4 );
$("#radio01").button({ disabled: false });
deepEqual(false, $("#radio01").button("option", "disabled"),
"disabled option set to false");
});
test("disabled, null", function() {
+ expect( 4 );
$("#radio01").button({ disabled: null });
deepEqual(false, $("#radio01").button("option", "disabled"),
"disabled option set to false");
});
test("text false without icon", function() {
+ expect( 1 );
$("#button").button({
text: false
});
});
test("text false with icon", function() {
+ expect( 1 );
$("#button").button({
text: false,
icons: {
});
test("label, default", function() {
+ expect( 2 );
$("#button").button();
deepEqual( $("#button").text(), "Label" );
deepEqual( $( "#button").button( "option", "label" ), "Label" );
});
test("label", function() {
+ expect( 2 );
$("#button").button({
label: "xxx"
});
});
test("label default with input type submit", function() {
+ expect( 2 );
deepEqual( $("#submit").button().val(), "Label" );
deepEqual( $("#submit").button( "option", "label" ), "Label" );
});
test("label with input type submit", function() {
+ expect( 2 );
var label = $("#submit").button({
label: "xxx"
}).val();
});
test("icons", function() {
+ expect( 1 );
$("#button").button({
text: false,
icons: {
module( "button: tickets" );
test( "#5946 - buttonset should ignore buttons that are not :visible", function() {
+ expect( 2 );
$( "#radio01" ).next().andSelf().hide();
var set = $( "#radio0" ).buttonset({ items: "input[type=radio]:visible" });
ok( set.find( "label:eq(0)" ).is( ":not(.ui-button):not(.ui-corner-left)" ) );
});
test( "#6262 - buttonset not applying ui-corner to invisible elements", function() {
+ expect( 3 );
$( "#radio0" ).hide();
var set = $( "#radio0" ).buttonset();
ok( set.find( "label:eq(0)" ).is( ".ui-button.ui-corner-left" ) );
});
test( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() {
+ expect( 2 );
var check = $( "#check" ).button(),
label = $( "label[for='check']" );
ok( !label.is( ".ui-state-focus" ) );
});
test( "#7092 - button creation that requires a matching label does not find label in all cases", function() {
+ expect( 5 );
var group = $( "<span><label for='t7092a'></label><input type='checkbox' id='t7092a'></span>" );
group.find( "input[type=checkbox]" ).button();
ok( group.find( "label" ).is( ".ui-button" ) );
});
test( "#7534 - Button label selector works for ids with \":\"", function() {
+ expect( 1 );
var group = $( "<span><input type='checkbox' id='check:7534'><label for='check:7534'>Label</label></span>" );
group.find( "input" ).button();
ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" );
});
test( "zIndex", function() {
+ expect( 7 );
var el = $( "#zIndexAutoWithParent" ),
parent = el.parent();
equal( el.zIndex(), 100, "zIndex traverses up to find value" );
});
test( "innerWidth - getter", function() {
+ expect( 2 );
var el = $( "#dimensions" );
equal( el.innerWidth(), 122, "getter passthru" );
});
test( "innerWidth - setter", function() {
+ expect( 2 );
var el = $( "#dimensions" );
el.innerWidth( 120 );
});
test( "innerHeight - getter", function() {
+ expect( 2 );
var el = $( "#dimensions" );
equal( el.innerHeight(), 70, "getter passthru" );
});
test( "innerHeight - setter", function() {
+ expect( 2 );
var el = $( "#dimensions" );
el.innerHeight( 60 );
});
test( "outerWidth - getter", function() {
+ expect( 2 );
var el = $( "#dimensions" );
equal( el.outerWidth(), 140, "getter passthru" );
});
test( "outerWidth - setter", function() {
+ expect( 2 );
var el = $( "#dimensions" );
el.outerWidth( 130 );
});
test( "outerWidth(true) - getter", function() {
+ expect( 2 );
var el = $( "#dimensions" );
equal( el.outerWidth(true), 154, "getter passthru w/ margin" );
});
test( "outerWidth(true) - setter", function() {
+ expect( 2 );
var el = $( "#dimensions" );
el.outerWidth( 130, true );
});
test( "outerHeight - getter", function() {
+ expect( 2 );
var el = $( "#dimensions" );
equal( el.outerHeight(), 86, "getter passthru" );
});
test( "outerHeight - setter", function() {
+ expect( 2 );
var el = $( "#dimensions" );
el.outerHeight( 80 );
});
test( "outerHeight(true) - getter", function() {
+ expect( 2 );
var el = $( "#dimensions" );
equal( el.outerHeight(true), 98, "getter passthru w/ margin" );
});
test( "outerHeight(true) - setter", function() {
+ expect( 2 );
var el = $( "#dimensions" );
el.outerHeight( 90, true );
});
test( "uniqueId / removeUniqueId", function() {
+ expect( 3 );
var el = $( "img" ).eq( 0 );
// support: jQuery <1.6.2
});
test("focusable - area elements", function() {
+ expect( 3 );
+
isFocusable('#areaCoordsHref', 'coords and href');
isFocusable('#areaNoCoordsHref', 'href but no coords');
isNotFocusable('#areaNoImg', 'not associated with an image');
});
test("tabbable - area elements", function() {
+ expect( 3 );
+
isTabbable('#areaCoordsHref', 'coords and href');
isTabbable('#areaNoCoordsHref', 'href but no coords');
isNotTabbable('#areaNoImg', 'not associated with an image');
module("datepicker: core");
test( "widget method - empty collection", function() {
+ expect( 1 );
$( "#nonExist" ).datepicker(); // should create nothing
ok( !$( "#ui-datepicker-div" ).length, "Non init on empty collection" );
});
test("widget method", function() {
+ expect( 1 );
var actual = $("#inp").datepicker().datepicker("widget")[0];
deepEqual($("body > #ui-datepicker-div:last-child")[0], actual);
});
test('baseStructure', function() {
+ expect( 59 );
var header, title, table, thead, week, panel, inl, child,
inp = init('#inp').focus(),
dp = $('#ui-datepicker-div'),
});
test('customStructure', function() {
+ expect( 20 );
var iframe, header, panel, title, thead,
dp = $('#ui-datepicker-div'),
// Check right-to-left localisation
});
test('keystrokes', function() {
+ expect( 26 );
var inp = init('#inp'),
date = new Date();
inp.val('').datepicker('show').
});
test('mouse', function() {
+ expect( 15 );
var inl,
inp = init('#inp'),
dp = $('#ui-datepicker-div'),
}
test('events', function() {
+ expect( 26 );
var dateStr, newMonthYear, inp2,
inp = init('#inp', {onSelect: callback}),
date = new Date();
module("datepicker: methods");
test('destroy', function() {
+ expect( 33 );
var inl,
inp = init('#inp');
ok(inp.is('.hasDatepicker'), 'Default - marker class set');
});
test('enableDisable', function() {
+ expect( 33 );
var inl, dp,
inp = init('#inp');
ok(!inp.datepicker('isDisabled'), 'Enable/disable - initially marked as enabled');
module("datepicker: options");
test('setDefaults', function() {
+ expect( 3 );
var inp = init('#inp');
equal($.datepicker._defaults.showOn, 'focus', 'Initial showOn');
$.datepicker.setDefaults({showOn: 'button'});
});
test('option', function() {
+ expect( 17 );
var inp = init('#inp'),
inst = $.data(inp[0], PROP_NAME);
// Set option
});
test('change', function() {
+ expect( 12 );
var inp = init('#inp'),
inst = $.data(inp[0], PROP_NAME);
equal(inst.settings.showOn, null, 'Initial setting showOn');
});
test('invocation', function() {
+ expect( 29 );
var button, image,
inp = init('#inp'),
dp = $('#ui-datepicker-div'),
});
test('otherMonths', function() {
+ expect( 8 );
var inp = init('#inp'),
pop = $('#ui-datepicker-div');
inp.val('06/01/2009').datepicker('show');
});
test('defaultDate', function() {
+ expect( 17 );
var inp = init('#inp'),
date = new Date();
inp.val('').datepicker('show').
});
test('miscellaneous', function() {
+ expect( 19 );
var curYear, longNames, shortNames, date,
dp = $('#ui-datepicker-div'),
inp = init('#inp');
});
test('minMax', function() {
+ expect( 17 );
var date,
inp = init('#inp'),
lastYear = new Date(2007, 6 - 1, 4),
});
test('setDate', function() {
+ expect( 24 );
var inl, alt, minDate, maxDate, dateAndTimeToSet, dateAndTimeClone,
inp = init('#inp'),
date1 = new Date(2008, 6 - 1, 4),
});
test('altField', function() {
+ expect( 10 );
var inp = init('#inp'),
alt = $('#alt');
// No alternate field set
});
test('autoSize', function() {
+ expect( 15 );
var inp = init('#inp');
equal(inp.prop('size'), 20, 'Auto size - default');
inp.datepicker('option', 'autoSize', true);
});
test('daylightSaving', function() {
+ expect( 25 );
var inp = init('#inp'),
dp = $('#ui-datepicker-div');
ok(true, 'Daylight saving - ' + new Date());
}
test('callbacks', function() {
+ expect( 13 );
// Before show
var dp, day20, day21,
inp = init('#inp', {beforeShow: beforeAll}),
});
test('localisation', function() {
+ expect( 24 );
var dp, month, day, date,
inp = init('#inp', $.datepicker.regional.fr);
inp.datepicker('option', {dateFormat: 'DD, d MM yy', showButtonPanel:true, changeMonth:true, changeYear:true}).val('').datepicker('show');
});
test('noWeekends', function() {
+ expect( 31 );
var i, date;
for (i = 1; i <= 31; i++) {
date = new Date(2001, 1 - 1, i);
});
test('iso8601Week', function() {
+ expect( 12 );
var date = new Date(2000, 12 - 1, 31);
equal($.datepicker.iso8601Week(date), 52, 'ISO 8601 week ' + date);
date = new Date(2001, 1 - 1, 1);
});
test('parseDate', function() {
+ expect( 26 );
init('#inp');
var currentYear, gmtDate, fr, settings, zh;
ok($.datepicker.parseDate('d m y', '') == null, 'Parse date empty');
});
test('parseDateErrors', function() {
+ expect( 17 );
init('#inp');
var fr, settings;
function expectError(expr, value, error) {
});
test('formatDate', function() {
+ expect( 16 );
init('#inp');
var gmtDate, fr, settings;
equal($.datepicker.formatDate('d m y', new Date(2001, 2 - 1, 3)),
// http://forum.jquery.com/topic/several-breaking-changes-in-jquery-ui-1-8rc1
test('beforeShowDay-getDate', function() {
+ expect( 3 );
var inp = init('#inp', {beforeShowDay: function(date) { inp.datepicker('getDate'); return [true, '']; }}),
dp = $('#ui-datepicker-div');
inp.val('01/01/2010').datepicker('show');
});
test('Ticket 7602: Stop datepicker from appearing with beforeShow event handler', function(){
+ expect( 3 );
var inp = init('#inp',{
beforeShow: function(){
return false;
});
test('Ticket 6827: formatDate day of year calculation is wrong during day lights savings time', function(){
+ expect( 1 );
var time = $.datepicker.formatDate("oo", new Date("2010/03/30 12:00:00 CDT"));
equal(time, "089");
});
test('Ticket #7244: date parser does not fail when too many numbers are passed into the date function', function() {
+ expect( 4 );
var date;
try{
date = $.datepicker.parseDate('dd/mm/yy', '18/04/19881');
});
test("widget method", function() {
+ expect( 1 );
var dialog = $("<div>").appendTo("#main").dialog();
deepEqual(dialog.parent()[0], dialog.dialog("widget")[0]);
});
});
test("destroy", function() {
+ expect( 4 );
+
$("<div></div>").appendTo('body').dialog().dialog("destroy").remove();
ok(true, '.dialog("destroy") called on element');
});
test("enable", function() {
+ expect( 3 );
+
var expected = $('<div></div>').dialog(),
actual = expected.dialog('enable');
equal(actual, expected, 'enable is chainable');
});
test("disable", function() {
+ expect( 3 );
+
var expected = $('<div></div>').dialog(),
actual = expected.dialog('disable');
equal(actual, expected, 'disable is chainable');
});
test("close", function() {
+ expect( 3 );
+
var expected = $('<div></div>').dialog(),
actual = expected.dialog('close');
equal(actual, expected, 'close is chainable');
});
test("moveToTop", function() {
+ expect( 3 );
+
var d1, d2, dlg1, dlg2,
expected = $('<div></div>').dialog(),
actual = expected.dialog('moveToTop');
});
test("open", function() {
+ expect( 3 );
var expected = $('<div></div>').dialog(),
actual = expected.dialog('open');
equal(actual, expected, 'open is chainable');
});
test("closeOnEscape", function() {
+ expect( 6 );
el = $('<div></div>').dialog({ closeOnEscape: false });
ok(true, 'closeOnEscape: false');
ok(dlg().is(':visible') && !dlg().is(':hidden'), 'dialog is open before ESC');
});
test("position, default center on window", function() {
+ expect( 2 );
var el = $('<div></div>').dialog(),
dialog = el.dialog('widget'),
offset = dialog.offset();
});
test("position, top on window", function() {
+ expect( 2 );
var el = $('<div></div>').dialog({ position: "top" }),
dialog = el.dialog('widget'),
offset = dialog.offset();
});
test("position, left on window", function() {
+ expect( 2 );
var el = $('<div></div>').dialog({ position: "left" }),
dialog = el.dialog('widget'),
offset = dialog.offset();
});
test("position, right bottom on window", function() {
+ expect( 2 );
var el = $('<div></div>').dialog({ position: "right bottom" }),
dialog = el.dialog('widget'),
offset = dialog.offset();
});
test("position, right bottom on window w/array", function() {
+ expect( 2 );
var el = $('<div></div>').dialog({ position: ["right", "bottom"] }),
dialog = el.dialog('widget'),
offset = dialog.offset();
});
test("position, offset from top left w/array", function() {
+ expect( 2 );
var el = $('<div></div>').dialog({ position: [10, 10] }),
dialog = el.dialog('widget'),
offset = dialog.offset();
});
test("position, right bottom at right bottom via ui.position args", function() {
+ expect( 2 );
var el = $('<div></div>').dialog({
position: {
my: "right bottom",
});
test("position, at another element", function() {
+ expect( 4 );
var parent = $('<div></div>').css({
position: 'absolute',
top: 400,
});
test("#5531: dialog width should be at least minWidth on creation", function () {
+ expect( 4 );
el = $('<div></div>').dialog({
width: 200,
minWidth: 300
});
test("#4980: Destroy should place element back in original DOM position", function(){
+ expect( 2 );
container = $('<div id="container"><div id="modal">Content</div></div>');
modal = container.find('#modal');
modal.dialog();
});
asyncTest( "animateClass: css and class changes during animation are not lost (#7106)", function() {
+ expect( 2 );
var test = $( "div.ticket7106" );
// ensure the class stays and that the css property stays
function run( position, v, h, vo, ho ) {
var desc = "End Position Correct: " + position + " (" + v + "," + h + ") - origin: (" + vo + "," + ho + ")";
asyncTest( desc, function() {
+ expect( 2 );
function complete() {
equal( parseInt( test.css( h ), 10 ), target[ h ], "Horizontal Position Correct " + desc );
equal( parseInt( test.css( v ), 10 ), target[ v ], "Vertical Position Correct " + desc );
(function( $ ) {
test( "offset", function() {
+ expect( 3 );
$( "#elx" ).position({
my: "left top",
at: "left bottom",
module( "progressbar: options" );
test( "{ value : 0 }, default", function() {
+ expect( 1 );
$( "#progressbar" ).progressbar();
equal( 0, $( "#progressbar" ).progressbar( "value" ) );
});
});
test( "{ value : 5 }", function() {
+ expect( 1 );
$( "#progressbar" ).progressbar({
value: 5
});
});
test( "{ value : -5 }", function() {
+ expect( 1 );
$( "#progressbar" ).progressbar({
value: -5
});
});
test( "{ value : 105 }", function() {
+ expect( 1 );
$( "#progressbar" ).progressbar({
value: 105
});
});
test( "{ max : 5, value : 10 }", function() {
+ expect( 1 );
$("#progressbar").progressbar({
max: 5,
value: 10
module( "tabs: methods" );
test( "destroy", function() {
+ expect( 1 );
domEqual( "#tabs1", function() {
$( "#tabs1" ).tabs().tabs( "destroy" );
});
if ( $.uiBackCompat === false ) {
test( "{ active: -Number }", function() {
+ expect( 8 );
+
var element = $( "#tabs1" ).tabs({
active: -1
});
document.write( "<script src='../../../" + url + "'></script>" );
}
+QUnit.config.requireExpects = true;
+
QUnit.config.urlConfig.push( "min" );
TestHelpers.loadResources = QUnit.urlParams.min ?
function() {
// ensure that all defaults have the correct value
test( "defined defaults", function() {
+ var count = 0;
$.each( defaults, function( key, val ) {
+ expect( ++count );
if ( $.isFunction( val ) ) {
ok( $.isFunction( pluginDefaults[ key ] ), key );
return;
// ensure that all defaults were tested
test( "tested defaults", function() {
+ var count = 0;
$.each( pluginDefaults, function( key, val ) {
+ expect( ++count );
ok( key in defaults, key );
});
});
function testWidgetOverrides( widget ) {
if ( $.uiBackCompat === false ) {
test( "$.widget overrides", function() {
+ expect( 4 );
$.each([
"_createWidget",
"destroy",
function testBasicUsage( widget ) {
test( "basic usage", function() {
+ expect( 3 );
+
var defaultElement = $.ui[ widget ].prototype.defaultElement;
$( defaultElement ).appendTo( "body" )[ widget ]().remove();
ok( true, "initialized on element" );
testWidgetOverrides( widget );
testBasicUsage( widget );
test( "version", function() {
+ expect( 1 );
ok( "version" in $.ui[ widget ].prototype, "version property exists" );
});
};
module( "tooltip: options" );
test( "content: default", function() {
+ expect( 1 );
var element = $( "#tooltipped1" ).tooltip().tooltip( "open" );
deepEqual( $( "#" + element.data( "ui-tooltip-id" ) ).text(), "anchortitle" );
});
test( "content: return string", function() {
+ expect( 1 );
var element = $( "#tooltipped1" ).tooltip({
content: function() {
return "customstring";
});
test( "content: return jQuery", function() {
+ expect( 1 );
var element = $( "#tooltipped1" ).tooltip({
content: function() {
return $( "<div>" ).html( "cu<b>s</b>tomstring" );
TestHelpers.testJshint( "widget" );
test( "widget creation", function() {
+ expect( 5 );
var myPrototype = {
_create: function() {},
creationTest: function() {}
});
test( "custom selector expression", function() {
+ expect( 1 );
var elem = $( "<div>" ).appendTo( "#qunit-fixture" );
$.widget( "ui.testWidget", {} );
elem.testWidget();
});
test( "re-init", function() {
+ expect( 3 );
var div = $( "<div>" ),
actions = [];
});
test( "inheritance - options", function() {
+ expect( 4 );
// #5830 - Widget: Using inheritance overwrites the base classes options
$.widget( "ui.testWidgetBase", {
options: {
});
test( ".option() - getter", function() {
+ expect( 6 );
$.widget( "ui.testWidget", {
_create: function() {}
});
});
test( ".option() - deep option getter", function() {
+ expect( 5 );
$.widget( "ui.testWidget", {} );
var div = $( "<div>" ).testWidget({
foo: {
});
test( ".option() - delegate to ._setOptions()", function() {
+ expect( 2 );
var div,
calls = [];
$.widget( "ui.testWidget", {
});
test( ".option() - delegate to ._setOption()", function() {
+ expect( 2 );
var div,
calls = [];
$.widget( "ui.testWidget", {
});
test( ".option() - deep option setter", function() {
+ expect( 6 );
$.widget( "ui.testWidget", {} );
var div = $( "<div>" ).testWidget();
function deepOption( from, to, msg ) {
});
test( ".widget() - base", function() {
+ expect( 1 );
$.widget( "ui.testWidget", {
_create: function() {}
});
});
test( ".widget() - overriden", function() {
+ expect( 1 );
var wrapper = $( "<div>" );
$.widget( "ui.testWidget", {
_create: function() {},
});
test( "._hoverable()", function() {
+ expect( 10 );
$.widget( "ui.testWidget", {
_create: function() {
this._hoverable( this.element.children() );
});
test( "._focusable()", function() {
+ expect( 10 );
$.widget( "ui.testWidget", {
_create: function() {
- this._focusable( this.element.children() );
- }
+ this._focusable( this.element.children() );
+ }
});
var div = $( "#widget" ).testWidget().children();
});
test( "._trigger() - cancelled callback", function() {
+ expect( 1 );
$.widget( "ui.testWidget", {
_create: function() {}
});