diff options
Diffstat (limited to 'tests/unit')
34 files changed, 2085 insertions, 2085 deletions
diff --git a/tests/unit/core/selector.js b/tests/unit/core/selector.js index f30ad17be..f86526b96 100644 --- a/tests/unit/core/selector.js +++ b/tests/unit/core/selector.js @@ -6,19 +6,19 @@ module("core - selectors"); function isFocusable(selector, msg) { - QUnit.push($(selector).is(':focusable'), null, null, msg + " - selector " + selector + " is focusable"); + QUnit.push($(selector).is(":focusable"), null, null, msg + " - selector " + selector + " is focusable"); } function isNotFocusable(selector, msg) { - QUnit.push($(selector).length && !$(selector).is(':focusable'), null, null, msg + " - selector " + selector + " is not focusable"); + QUnit.push($(selector).length && !$(selector).is(":focusable"), null, null, msg + " - selector " + selector + " is not focusable"); } function isTabbable(selector, msg) { - QUnit.push($(selector).is(':tabbable'), null, null, msg + " - selector " + selector + " is tabbable"); + QUnit.push($(selector).is(":tabbable"), null, null, msg + " - selector " + selector + " is tabbable"); } function isNotTabbable(selector, msg) { - QUnit.push($(selector).length && !$(selector).is(':tabbable'), null, null, msg + " - selector " + selector + " is not tabbable"); + QUnit.push($(selector).length && !$(selector).is(":tabbable"), null, null, msg + " - selector " + selector + " is not tabbable"); } test("data", function() { @@ -26,135 +26,135 @@ test("data", function() { var el; function shouldHaveData(msg) { - ok(el.is(':data(test)'), msg); + ok(el.is(":data(test)"), msg); } function shouldNotHaveData(msg) { - ok(!el.is(':data(test)'), msg); + ok(!el.is(":data(test)"), msg); } - el = $('<div>'); - shouldNotHaveData('data never set'); + el = $("<div>"); + shouldNotHaveData("data never set"); - el = $('<div>').data('test', null); - shouldNotHaveData('data is null'); + el = $("<div>").data("test", null); + shouldNotHaveData("data is null"); - el = $('<div>').data('test', true); - shouldHaveData('data set to true'); + el = $("<div>").data("test", true); + shouldHaveData("data set to true"); - el = $('<div>').data('test', false); - shouldNotHaveData('data set to false'); + el = $("<div>").data("test", false); + shouldNotHaveData("data set to false"); - el = $('<div>').data('test', 0); - shouldNotHaveData('data set to 0'); + el = $("<div>").data("test", 0); + shouldNotHaveData("data set to 0"); - el = $('<div>').data('test', 1); - shouldHaveData('data set to 1'); + el = $("<div>").data("test", 1); + shouldHaveData("data set to 1"); - el = $('<div>').data('test', ''); - shouldNotHaveData('data set to empty string'); + el = $("<div>").data("test", ""); + shouldNotHaveData("data set to empty string"); - el = $('<div>').data('test', 'foo'); - shouldHaveData('data set to string'); + el = $("<div>").data("test", "foo"); + shouldHaveData("data set to string"); - el = $('<div>').data('test', []); - shouldHaveData('data set to empty array'); + el = $("<div>").data("test", []); + shouldHaveData("data set to empty array"); - el = $('<div>').data('test', [1]); - shouldHaveData('data set to array'); + el = $("<div>").data("test", [1]); + shouldHaveData("data set to array"); - el = $('<div>').data('test', {}); - shouldHaveData('data set to empty object'); + el = $("<div>").data("test", {}); + shouldHaveData("data set to empty object"); - el = $('<div>').data('test', {foo: 'bar'}); - shouldHaveData('data set to object'); + el = $("<div>").data("test", {foo: "bar"}); + shouldHaveData("data set to object"); - el = $('<div>').data('test', new Date()); - shouldHaveData('data set to date'); + el = $("<div>").data("test", new Date()); + shouldHaveData("data set to date"); - el = $('<div>').data('test', /test/); - shouldHaveData('data set to regexp'); + el = $("<div>").data("test", /test/); + shouldHaveData("data set to regexp"); - el = $('<div>').data('test', function() {}); - shouldHaveData('data set to function'); + el = $("<div>").data("test", function() {}); + shouldHaveData("data set to function"); }); test("focusable - visible, enabled elements", function() { expect(18); - isNotFocusable('#formNoTabindex', 'form'); - isFocusable('#formTabindex', 'form with tabindex'); - isFocusable('#visibleAncestor-inputTypeNone', 'input, no type'); - isFocusable('#visibleAncestor-inputTypeText', 'input, type text'); - isFocusable('#visibleAncestor-inputTypeCheckbox', 'input, type checkbox'); - isFocusable('#visibleAncestor-inputTypeRadio', 'input, type radio'); - isFocusable('#visibleAncestor-inputTypeButton', 'input, type button'); - isNotFocusable('#visibleAncestor-inputTypeHidden', 'input, type hidden'); - isFocusable('#visibleAncestor-button', 'button'); - isFocusable('#visibleAncestor-select', 'select'); - isFocusable('#visibleAncestor-textarea', 'textarea'); - isFocusable('#visibleAncestor-object', 'object'); - isFocusable('#visibleAncestor-anchorWithHref', 'anchor with href'); - isNotFocusable('#visibleAncestor-anchorWithoutHref', 'anchor without href'); - isNotFocusable('#visibleAncestor-span', 'span'); - isNotFocusable('#visibleAncestor-div', 'div'); - isFocusable("#visibleAncestor-spanWithTabindex", 'span with tabindex'); - isFocusable("#visibleAncestor-divWithNegativeTabindex", 'div with tabindex'); + isNotFocusable("#formNoTabindex", "form"); + isFocusable("#formTabindex", "form with tabindex"); + isFocusable("#visibleAncestor-inputTypeNone", "input, no type"); + isFocusable("#visibleAncestor-inputTypeText", "input, type text"); + isFocusable("#visibleAncestor-inputTypeCheckbox", "input, type checkbox"); + isFocusable("#visibleAncestor-inputTypeRadio", "input, type radio"); + isFocusable("#visibleAncestor-inputTypeButton", "input, type button"); + isNotFocusable("#visibleAncestor-inputTypeHidden", "input, type hidden"); + isFocusable("#visibleAncestor-button", "button"); + isFocusable("#visibleAncestor-select", "select"); + isFocusable("#visibleAncestor-textarea", "textarea"); + isFocusable("#visibleAncestor-object", "object"); + isFocusable("#visibleAncestor-anchorWithHref", "anchor with href"); + isNotFocusable("#visibleAncestor-anchorWithoutHref", "anchor without href"); + isNotFocusable("#visibleAncestor-span", "span"); + isNotFocusable("#visibleAncestor-div", "div"); + isFocusable("#visibleAncestor-spanWithTabindex", "span with tabindex"); + isFocusable("#visibleAncestor-divWithNegativeTabindex", "div with tabindex"); }); test("focusable - disabled elements", function() { expect(9); - isNotFocusable('#disabledElement-inputTypeNone', 'input, no type'); - isNotFocusable('#disabledElement-inputTypeText', 'input, type text'); - isNotFocusable('#disabledElement-inputTypeCheckbox', 'input, type checkbox'); - isNotFocusable('#disabledElement-inputTypeRadio', 'input, type radio'); - isNotFocusable('#disabledElement-inputTypeButton', 'input, type button'); - isNotFocusable('#disabledElement-inputTypeHidden', 'input, type hidden'); - isNotFocusable('#disabledElement-button', 'button'); - isNotFocusable('#disabledElement-select', 'select'); - isNotFocusable('#disabledElement-textarea', 'textarea'); + isNotFocusable("#disabledElement-inputTypeNone", "input, no type"); + isNotFocusable("#disabledElement-inputTypeText", "input, type text"); + isNotFocusable("#disabledElement-inputTypeCheckbox", "input, type checkbox"); + isNotFocusable("#disabledElement-inputTypeRadio", "input, type radio"); + isNotFocusable("#disabledElement-inputTypeButton", "input, type button"); + isNotFocusable("#disabledElement-inputTypeHidden", "input, type hidden"); + isNotFocusable("#disabledElement-button", "button"); + isNotFocusable("#disabledElement-select", "select"); + isNotFocusable("#disabledElement-textarea", "textarea"); }); test("focusable - hidden styles", function() { expect(8); - isNotFocusable('#displayNoneAncestor-input', 'input, display: none parent'); - isNotFocusable('#displayNoneAncestor-span', 'span with tabindex, display: none parent'); + isNotFocusable("#displayNoneAncestor-input", "input, display: none parent"); + isNotFocusable("#displayNoneAncestor-span", "span with tabindex, display: none parent"); - isNotFocusable('#visibilityHiddenAncestor-input', 'input, visibility: hidden parent'); - isNotFocusable('#visibilityHiddenAncestor-span', 'span with tabindex, visibility: hidden parent'); + isNotFocusable("#visibilityHiddenAncestor-input", "input, visibility: hidden parent"); + isNotFocusable("#visibilityHiddenAncestor-span", "span with tabindex, visibility: hidden parent"); - isNotFocusable('#displayNone-input', 'input, display: none'); - isNotFocusable('#visibilityHidden-input', 'input, visibility: hidden'); + isNotFocusable("#displayNone-input", "input, display: none"); + isNotFocusable("#visibilityHidden-input", "input, visibility: hidden"); - isNotFocusable('#displayNone-span', 'span with tabindex, display: none'); - isNotFocusable('#visibilityHidden-span', 'span with tabindex, visibility: hidden'); + isNotFocusable("#displayNone-span", "span with tabindex, display: none"); + isNotFocusable("#visibilityHidden-span", "span with tabindex, visibility: hidden"); }); test("focusable - natively focusable with various tabindex", function() { expect(4); - isFocusable('#inputTabindex0', 'input, tabindex 0'); - isFocusable('#inputTabindex10', 'input, tabindex 10'); - isFocusable('#inputTabindex-1', 'input, tabindex -1'); - isFocusable('#inputTabindex-50', 'input, tabindex -50'); + isFocusable("#inputTabindex0", "input, tabindex 0"); + isFocusable("#inputTabindex10", "input, tabindex 10"); + isFocusable("#inputTabindex-1", "input, tabindex -1"); + isFocusable("#inputTabindex-50", "input, tabindex -50"); }); test("focusable - not natively focusable with various tabindex", function() { expect(4); - isFocusable('#spanTabindex0', 'span, tabindex 0'); - isFocusable('#spanTabindex10', 'span, tabindex 10'); - isFocusable('#spanTabindex-1', 'span, tabindex -1'); - isFocusable('#spanTabindex-50', 'span, tabindex -50'); + isFocusable("#spanTabindex0", "span, tabindex 0"); + isFocusable("#spanTabindex10", "span, tabindex 10"); + isFocusable("#spanTabindex-1", "span, tabindex -1"); + isFocusable("#spanTabindex-50", "span, tabindex -50"); }); 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'); + isFocusable("#areaCoordsHref", "coords and href"); + isFocusable("#areaNoCoordsHref", "href but no coords"); + isNotFocusable("#areaNoImg", "not associated with an image"); }); test( "focusable - dimensionless parent with overflow", function() { @@ -166,80 +166,80 @@ test( "focusable - dimensionless parent with overflow", function() { test("tabbable - visible, enabled elements", function() { expect(18); - isNotTabbable('#formNoTabindex', 'form'); - isTabbable('#formTabindex', 'form with tabindex'); - isTabbable('#visibleAncestor-inputTypeNone', 'input, no type'); - isTabbable('#visibleAncestor-inputTypeText', 'input, type text'); - isTabbable('#visibleAncestor-inputTypeCheckbox', 'input, type checkbox'); - isTabbable('#visibleAncestor-inputTypeRadio', 'input, type radio'); - isTabbable('#visibleAncestor-inputTypeButton', 'input, type button'); - isNotTabbable('#visibleAncestor-inputTypeHidden', 'input, type hidden'); - isTabbable('#visibleAncestor-button', 'button'); - isTabbable('#visibleAncestor-select', 'select'); - isTabbable('#visibleAncestor-textarea', 'textarea'); - isTabbable('#visibleAncestor-object', 'object'); - isTabbable('#visibleAncestor-anchorWithHref', 'anchor with href'); - isNotTabbable('#visibleAncestor-anchorWithoutHref', 'anchor without href'); - isNotTabbable('#visibleAncestor-span', 'span'); - isNotTabbable('#visibleAncestor-div', 'div'); - isTabbable("#visibleAncestor-spanWithTabindex", 'span with tabindex'); - isNotTabbable("#visibleAncestor-divWithNegativeTabindex", 'div with tabindex'); + isNotTabbable("#formNoTabindex", "form"); + isTabbable("#formTabindex", "form with tabindex"); + isTabbable("#visibleAncestor-inputTypeNone", "input, no type"); + isTabbable("#visibleAncestor-inputTypeText", "input, type text"); + isTabbable("#visibleAncestor-inputTypeCheckbox", "input, type checkbox"); + isTabbable("#visibleAncestor-inputTypeRadio", "input, type radio"); + isTabbable("#visibleAncestor-inputTypeButton", "input, type button"); + isNotTabbable("#visibleAncestor-inputTypeHidden", "input, type hidden"); + isTabbable("#visibleAncestor-button", "button"); + isTabbable("#visibleAncestor-select", "select"); + isTabbable("#visibleAncestor-textarea", "textarea"); + isTabbable("#visibleAncestor-object", "object"); + isTabbable("#visibleAncestor-anchorWithHref", "anchor with href"); + isNotTabbable("#visibleAncestor-anchorWithoutHref", "anchor without href"); + isNotTabbable("#visibleAncestor-span", "span"); + isNotTabbable("#visibleAncestor-div", "div"); + isTabbable("#visibleAncestor-spanWithTabindex", "span with tabindex"); + isNotTabbable("#visibleAncestor-divWithNegativeTabindex", "div with tabindex"); }); test("tabbable - disabled elements", function() { expect(9); - isNotTabbable('#disabledElement-inputTypeNone', 'input, no type'); - isNotTabbable('#disabledElement-inputTypeText', 'input, type text'); - isNotTabbable('#disabledElement-inputTypeCheckbox', 'input, type checkbox'); - isNotTabbable('#disabledElement-inputTypeRadio', 'input, type radio'); - isNotTabbable('#disabledElement-inputTypeButton', 'input, type button'); - isNotTabbable('#disabledElement-inputTypeHidden', 'input, type hidden'); - isNotTabbable('#disabledElement-button', 'button'); - isNotTabbable('#disabledElement-select', 'select'); - isNotTabbable('#disabledElement-textarea', 'textarea'); + isNotTabbable("#disabledElement-inputTypeNone", "input, no type"); + isNotTabbable("#disabledElement-inputTypeText", "input, type text"); + isNotTabbable("#disabledElement-inputTypeCheckbox", "input, type checkbox"); + isNotTabbable("#disabledElement-inputTypeRadio", "input, type radio"); + isNotTabbable("#disabledElement-inputTypeButton", "input, type button"); + isNotTabbable("#disabledElement-inputTypeHidden", "input, type hidden"); + isNotTabbable("#disabledElement-button", "button"); + isNotTabbable("#disabledElement-select", "select"); + isNotTabbable("#disabledElement-textarea", "textarea"); }); test("tabbable - hidden styles", function() { expect(8); - isNotTabbable('#displayNoneAncestor-input', 'input, display: none parent'); - isNotTabbable('#displayNoneAncestor-span', 'span with tabindex, display: none parent'); + isNotTabbable("#displayNoneAncestor-input", "input, display: none parent"); + isNotTabbable("#displayNoneAncestor-span", "span with tabindex, display: none parent"); - isNotTabbable('#visibilityHiddenAncestor-input', 'input, visibility: hidden parent'); - isNotTabbable('#visibilityHiddenAncestor-span', 'span with tabindex, visibility: hidden parent'); + isNotTabbable("#visibilityHiddenAncestor-input", "input, visibility: hidden parent"); + isNotTabbable("#visibilityHiddenAncestor-span", "span with tabindex, visibility: hidden parent"); - isNotTabbable('#displayNone-input', 'input, display: none'); - isNotTabbable('#visibilityHidden-input', 'input, visibility: hidden'); + isNotTabbable("#displayNone-input", "input, display: none"); + isNotTabbable("#visibilityHidden-input", "input, visibility: hidden"); - isNotTabbable('#displayNone-span', 'span with tabindex, display: none'); - isNotTabbable('#visibilityHidden-span', 'span with tabindex, visibility: hidden'); + isNotTabbable("#displayNone-span", "span with tabindex, display: none"); + isNotTabbable("#visibilityHidden-span", "span with tabindex, visibility: hidden"); }); test("tabbable - natively tabbable with various tabindex", function() { expect(4); - isTabbable('#inputTabindex0', 'input, tabindex 0'); - isTabbable('#inputTabindex10', 'input, tabindex 10'); - isNotTabbable('#inputTabindex-1', 'input, tabindex -1'); - isNotTabbable('#inputTabindex-50', 'input, tabindex -50'); + isTabbable("#inputTabindex0", "input, tabindex 0"); + isTabbable("#inputTabindex10", "input, tabindex 10"); + isNotTabbable("#inputTabindex-1", "input, tabindex -1"); + isNotTabbable("#inputTabindex-50", "input, tabindex -50"); }); test("tabbable - not natively tabbable with various tabindex", function() { expect(4); - isTabbable('#spanTabindex0', 'span, tabindex 0'); - isTabbable('#spanTabindex10', 'span, tabindex 10'); - isNotTabbable('#spanTabindex-1', 'span, tabindex -1'); - isNotTabbable('#spanTabindex-50', 'span, tabindex -50'); + isTabbable("#spanTabindex0", "span, tabindex 0"); + isTabbable("#spanTabindex10", "span, tabindex 10"); + isNotTabbable("#spanTabindex-1", "span, tabindex -1"); + isNotTabbable("#spanTabindex-50", "span, tabindex -50"); }); 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'); + isTabbable("#areaCoordsHref", "coords and href"); + isTabbable("#areaNoCoordsHref", "href but no coords"); + isNotTabbable("#areaNoImg", "not associated with an image"); }); test( "tabbable - dimensionless parent with overflow", function() { diff --git a/tests/unit/datepicker/datepicker_core.js b/tests/unit/datepicker/datepicker_core.js index 1388f9222..befda3b2a 100644 --- a/tests/unit/datepicker/datepicker_core.js +++ b/tests/unit/datepicker/datepicker_core.js @@ -10,12 +10,12 @@ TestHelpers.testJshint( "datepicker" ); test("initialization - Reinitialization after body had been emptied.", function() { expect( 1 ); - var bodyContent = $('body').children(), inp = $("#inp"); + var bodyContent = $("body").children(), inp = $("#inp"); $("#inp").datepicker(); - $('body').empty().append(inp); + $("body").empty().append(inp); $("#inp").datepicker(); ok( $("#"+$.datepicker._mainDivId).length===1, "Datepicker container added" ); - $('body').empty().append(bodyContent); // Returning to initial state for later tests + $("body").empty().append(bodyContent); // Returning to initial state for later tests }); test( "widget method - empty collection", function() { @@ -30,46 +30,46 @@ test("widget method", function() { deepEqual($("body > #ui-datepicker-div:last-child")[0], actual); }); -asyncTest('baseStructure', function() { +asyncTest("baseStructure", function() { expect( 58 ); var header, title, table, thead, week, panel, inl, child, - inp = TestHelpers.datepicker.init('#inp'), - dp = $('#ui-datepicker-div'); + inp = TestHelpers.datepicker.init("#inp"), + dp = $("#ui-datepicker-div"); function step1() { inp[0].focus(); setTimeout(function() { - ok(dp.is(':visible'), 'Structure - datepicker visible'); - ok(!dp.is('.ui-datepicker-rtl'), 'Structure - not right-to-left'); - ok(!dp.is('.ui-datepicker-multi'), 'Structure - not multi-month'); - equal(dp.children().length, 2, 'Structure - child count'); - - header = dp.children(':first'); - ok(header.is('div.ui-datepicker-header'), 'Structure - header division'); - equal(header.children().length, 3, 'Structure - header child count'); - ok(header.children(':first').is('a.ui-datepicker-prev') && header.children(':first').html() !== '', 'Structure - prev link'); - ok(header.children(':eq(1)').is('a.ui-datepicker-next') && header.children(':eq(1)').html() !== '', 'Structure - next link'); - - title = header.children(':last'); - ok(title.is('div.ui-datepicker-title') && title.html() !== '','Structure - title division'); - equal(title.children().length, 2, 'Structure - title child count'); - ok(title.children(':first').is('span.ui-datepicker-month') && title.children(':first').text() !== '', 'Structure - month text'); - ok(title.children(':last').is('span.ui-datepicker-year') && title.children(':last').text() !== '', 'Structure - year text'); - - table = dp.children(':eq(1)'); - ok(table.is('table.ui-datepicker-calendar'), 'Structure - month table'); - ok(table.children(':first').is('thead'), 'Structure - month table thead'); - thead = table.children(':first').children(':first'); - ok(thead.is('tr'), 'Structure - month table title row'); - equal(thead.find('th').length, 7, 'Structure - month table title cells'); - ok(table.children(':eq(1)').is('tbody'), 'Structure - month table body'); - ok(table.children(':eq(1)').children('tr').length >= 4, 'Structure - month table week count'); - week = table.children(':eq(1)').children(':first'); - ok(week.is('tr'), 'Structure - month table week row'); - equal(week.children().length, 7, 'Structure - week child count'); - ok(week.children(':first').is('td.ui-datepicker-week-end'), 'Structure - month table first day cell'); - ok(week.children(':last').is('td.ui-datepicker-week-end'), 'Structure - month table second day cell'); - inp.datepicker('hide').datepicker('destroy'); + ok(dp.is(":visible"), "Structure - datepicker visible"); + ok(!dp.is(".ui-datepicker-rtl"), "Structure - not right-to-left"); + ok(!dp.is(".ui-datepicker-multi"), "Structure - not multi-month"); + equal(dp.children().length, 2, "Structure - child count"); + + header = dp.children(":first"); + ok(header.is("div.ui-datepicker-header"), "Structure - header division"); + equal(header.children().length, 3, "Structure - header child count"); + ok(header.children(":first").is("a.ui-datepicker-prev") && header.children(":first").html() !== "", "Structure - prev link"); + ok(header.children(":eq(1)").is("a.ui-datepicker-next") && header.children(":eq(1)").html() !== "", "Structure - next link"); + + title = header.children(":last"); + ok(title.is("div.ui-datepicker-title") && title.html() !== "","Structure - title division"); + equal(title.children().length, 2, "Structure - title child count"); + ok(title.children(":first").is("span.ui-datepicker-month") && title.children(":first").text() !== "", "Structure - month text"); + ok(title.children(":last").is("span.ui-datepicker-year") && title.children(":last").text() !== "", "Structure - year text"); + + table = dp.children(":eq(1)"); + ok(table.is("table.ui-datepicker-calendar"), "Structure - month table"); + ok(table.children(":first").is("thead"), "Structure - month table thead"); + thead = table.children(":first").children(":first"); + ok(thead.is("tr"), "Structure - month table title row"); + equal(thead.find("th").length, 7, "Structure - month table title cells"); + ok(table.children(":eq(1)").is("tbody"), "Structure - month table body"); + ok(table.children(":eq(1)").children("tr").length >= 4, "Structure - month table week count"); + week = table.children(":eq(1)").children(":first"); + ok(week.is("tr"), "Structure - month table week row"); + equal(week.children().length, 7, "Structure - week child count"); + ok(week.children(":first").is("td.ui-datepicker-week-end"), "Structure - month table first day cell"); + ok(week.children(":last").is("td.ui-datepicker-week-end"), "Structure - month table second day cell"); + inp.datepicker("hide").datepicker("destroy"); step2(); }); @@ -77,19 +77,19 @@ asyncTest('baseStructure', function() { function step2() { // Editable month/year and button panel - inp = TestHelpers.datepicker.init('#inp', {changeMonth: true, changeYear: true, showButtonPanel: true}); + inp = TestHelpers.datepicker.init("#inp", {changeMonth: true, changeYear: true, showButtonPanel: true}); inp.focus(); setTimeout(function() { - title = dp.find('div.ui-datepicker-title'); - ok(title.children(':first').is('select.ui-datepicker-month'), 'Structure - month selector'); - ok(title.children(':last').is('select.ui-datepicker-year'), 'Structure - year selector'); + title = dp.find("div.ui-datepicker-title"); + ok(title.children(":first").is("select.ui-datepicker-month"), "Structure - month selector"); + ok(title.children(":last").is("select.ui-datepicker-year"), "Structure - year selector"); - panel = dp.children(':last'); - ok(panel.is('div.ui-datepicker-buttonpane'), 'Structure - button panel division'); - equal(panel.children().length, 2, 'Structure - button panel child count'); - ok(panel.children(':first').is('button.ui-datepicker-current'), 'Structure - today button'); - ok(panel.children(':last').is('button.ui-datepicker-close'), 'Structure - close button'); - inp.datepicker('hide').datepicker('destroy'); + panel = dp.children(":last"); + ok(panel.is("div.ui-datepicker-buttonpane"), "Structure - button panel division"); + equal(panel.children().length, 2, "Structure - button panel child count"); + ok(panel.children(":first").is("button.ui-datepicker-current"), "Structure - today button"); + ok(panel.children(":last").is("button.ui-datepicker-close"), "Structure - close button"); + inp.datepicker("hide").datepicker("destroy"); step3(); }); @@ -97,19 +97,19 @@ asyncTest('baseStructure', function() { function step3() { // Multi-month 2 - inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: 2}); + inp = TestHelpers.datepicker.init("#inp", {numberOfMonths: 2}); inp.focus(); setTimeout(function() { - ok(dp.is('.ui-datepicker-multi'), 'Structure multi [2] - multi-month'); - equal(dp.children().length, 3, 'Structure multi [2] - child count'); - child = dp.children(':first'); - ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2] - first month division'); - child = dp.children(':eq(1)'); - ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure multi [2] - second month division'); - child = dp.children(':eq(2)'); - ok(child.is('div.ui-datepicker-row-break'), 'Structure multi [2] - row break'); - ok(dp.is('.ui-datepicker-multi-2'), 'Structure multi [2] - multi-2'); - inp.datepicker('hide').datepicker('destroy'); + ok(dp.is(".ui-datepicker-multi"), "Structure multi [2] - multi-month"); + equal(dp.children().length, 3, "Structure multi [2] - child count"); + child = dp.children(":first"); + ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-first"), "Structure multi [2] - first month division"); + child = dp.children(":eq(1)"); + ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-last"), "Structure multi [2] - second month division"); + child = dp.children(":eq(2)"); + ok(child.is("div.ui-datepicker-row-break"), "Structure multi [2] - row break"); + ok(dp.is(".ui-datepicker-multi-2"), "Structure multi [2] - multi-2"); + inp.datepicker("hide").datepicker("destroy"); step4(); }); @@ -117,12 +117,12 @@ asyncTest('baseStructure', function() { function step4() { // Multi-month 3 - inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: 3}); + inp = TestHelpers.datepicker.init("#inp", {numberOfMonths: 3}); inp.focus(); setTimeout(function() { - ok(dp.is('.ui-datepicker-multi-3'), 'Structure multi [3] - multi-3'); - ok(! dp.is('.ui-datepicker-multi-2'), 'Structure multi [3] - Trac #6704'); - inp.datepicker('hide').datepicker('destroy'); + ok(dp.is(".ui-datepicker-multi-3"), "Structure multi [3] - multi-3"); + ok(! dp.is(".ui-datepicker-multi-2"), "Structure multi [3] - Trac #6704"); + inp.datepicker("hide").datepicker("destroy"); step5(); }); @@ -130,53 +130,53 @@ asyncTest('baseStructure', function() { function step5() { // Multi-month [2, 2] - inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: [2, 2]}); + inp = TestHelpers.datepicker.init("#inp", {numberOfMonths: [2, 2]}); inp.focus(); setTimeout(function() { - ok(dp.is('.ui-datepicker-multi'), 'Structure multi - multi-month'); - equal(dp.children().length, 6, 'Structure multi [2,2] - child count'); - child = dp.children(':first'); - ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2,2] - first month division'); - child = dp.children(':eq(1)'); - ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure multi [2,2] - second month division'); - child = dp.children(':eq(2)'); - ok(child.is('div.ui-datepicker-row-break'), 'Structure multi [2,2] - row break'); - child = dp.children(':eq(3)'); - ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2,2] - third month division'); - child = dp.children(':eq(4)'); - ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure multi [2,2] - fourth month division'); - child = dp.children(':eq(5)'); - ok(child.is('div.ui-datepicker-row-break'), 'Structure multi [2,2] - row break'); - inp.datepicker('hide').datepicker('destroy'); + ok(dp.is(".ui-datepicker-multi"), "Structure multi - multi-month"); + equal(dp.children().length, 6, "Structure multi [2,2] - child count"); + child = dp.children(":first"); + ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-first"), "Structure multi [2,2] - first month division"); + child = dp.children(":eq(1)"); + ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-last"), "Structure multi [2,2] - second month division"); + child = dp.children(":eq(2)"); + ok(child.is("div.ui-datepicker-row-break"), "Structure multi [2,2] - row break"); + child = dp.children(":eq(3)"); + ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-first"), "Structure multi [2,2] - third month division"); + child = dp.children(":eq(4)"); + ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-last"), "Structure multi [2,2] - fourth month division"); + child = dp.children(":eq(5)"); + ok(child.is("div.ui-datepicker-row-break"), "Structure multi [2,2] - row break"); + inp.datepicker("hide").datepicker("destroy"); // Inline - inl = TestHelpers.datepicker.init('#inl'); + inl = TestHelpers.datepicker.init("#inl"); dp = inl.children(); - ok(dp.is('.ui-datepicker-inline'), 'Structure inline - main div'); - ok(!dp.is('.ui-datepicker-rtl'), 'Structure inline - not right-to-left'); - ok(!dp.is('.ui-datepicker-multi'), 'Structure inline - not multi-month'); - equal(dp.children().length, 2, 'Structure inline - child count'); - header = dp.children(':first'); - ok(header.is('div.ui-datepicker-header'), 'Structure inline - header division'); - equal(header.children().length, 3, 'Structure inline - header child count'); - table = dp.children(':eq(1)'); - ok(table.is('table.ui-datepicker-calendar'), 'Structure inline - month table'); - ok(table.children(':first').is('thead'), 'Structure inline - month table thead'); - ok(table.children(':eq(1)').is('tbody'), 'Structure inline - month table body'); - inl.datepicker('destroy'); + ok(dp.is(".ui-datepicker-inline"), "Structure inline - main div"); + ok(!dp.is(".ui-datepicker-rtl"), "Structure inline - not right-to-left"); + ok(!dp.is(".ui-datepicker-multi"), "Structure inline - not multi-month"); + equal(dp.children().length, 2, "Structure inline - child count"); + header = dp.children(":first"); + ok(header.is("div.ui-datepicker-header"), "Structure inline - header division"); + equal(header.children().length, 3, "Structure inline - header child count"); + table = dp.children(":eq(1)"); + ok(table.is("table.ui-datepicker-calendar"), "Structure inline - month table"); + ok(table.children(":first").is("thead"), "Structure inline - month table thead"); + ok(table.children(":eq(1)").is("tbody"), "Structure inline - month table body"); + inl.datepicker("destroy"); // Inline multi-month - inl = TestHelpers.datepicker.init('#inl', {numberOfMonths: 2}); + inl = TestHelpers.datepicker.init("#inl", {numberOfMonths: 2}); dp = inl.children(); - ok(dp.is('.ui-datepicker-inline') && dp.is('.ui-datepicker-multi'), 'Structure inline multi - main div'); - equal(dp.children().length, 3, 'Structure inline multi - child count'); - child = dp.children(':first'); - ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure inline multi - first month division'); - child = dp.children(':eq(1)'); - ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure inline multi - second month division'); - child = dp.children(':eq(2)'); - ok(child.is('div.ui-datepicker-row-break'), 'Structure inline multi - row break'); - inl.datepicker('destroy'); + ok(dp.is(".ui-datepicker-inline") && dp.is(".ui-datepicker-multi"), "Structure inline multi - main div"); + equal(dp.children().length, 3, "Structure inline multi - child count"); + child = dp.children(":first"); + ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-first"), "Structure inline multi - first month division"); + child = dp.children(":eq(1)"); + ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-last"), "Structure inline multi - second month division"); + child = dp.children(":eq(2)"); + ok(child.is("div.ui-datepicker-row-break"), "Structure inline multi - row break"); + inl.datepicker("destroy"); start(); }); @@ -185,279 +185,279 @@ asyncTest('baseStructure', function() { step1(); }); -test('customStructure', function() { +test("customStructure", function() { expect( 20 ); var header, panel, title, thead, - dp = $('#ui-datepicker-div'), + dp = $("#ui-datepicker-div"), // Check right-to-left localisation - inp = TestHelpers.datepicker.init('#inp', $.datepicker.regional.he); - inp.datepicker( 'option', 'showButtonPanel', true); + inp = TestHelpers.datepicker.init("#inp", $.datepicker.regional.he); + inp.datepicker( "option", "showButtonPanel", true); inp.focus(); - ok(dp.is('.ui-datepicker-rtl'), 'Structure RTL - right-to-left'); - header = dp.children(':first'); - ok(header.is('div.ui-datepicker-header'), 'Structure RTL - header division'); - equal(header.children().length, 3, 'Structure RTL - header child count'); - ok(header.children(':first').is('a.ui-datepicker-next'), 'Structure RTL - prev link'); - ok(header.children(':eq(1)').is('a.ui-datepicker-prev'), 'Structure RTL - next link'); - panel = dp.children(':last'); - ok(panel.is('div.ui-datepicker-buttonpane'), 'Structure RTL - button division'); - equal(panel.children().length, 2, 'Structure RTL - button panel child count'); - ok(panel.children(':first').is('button.ui-datepicker-close'), 'Structure RTL - close button'); - ok(panel.children(':last').is('button.ui-datepicker-current'), 'Structure RTL - today button'); - inp.datepicker('hide').datepicker('destroy'); + ok(dp.is(".ui-datepicker-rtl"), "Structure RTL - right-to-left"); + header = dp.children(":first"); + ok(header.is("div.ui-datepicker-header"), "Structure RTL - header division"); + equal(header.children().length, 3, "Structure RTL - header child count"); + ok(header.children(":first").is("a.ui-datepicker-next"), "Structure RTL - prev link"); + ok(header.children(":eq(1)").is("a.ui-datepicker-prev"), "Structure RTL - next link"); + panel = dp.children(":last"); + ok(panel.is("div.ui-datepicker-buttonpane"), "Structure RTL - button division"); + equal(panel.children().length, 2, "Structure RTL - button panel child count"); + ok(panel.children(":first").is("button.ui-datepicker-close"), "Structure RTL - close button"); + ok(panel.children(":last").is("button.ui-datepicker-current"), "Structure RTL - today button"); + inp.datepicker("hide").datepicker("destroy"); // Hide prev/next - inp = TestHelpers.datepicker.init('#inp', {hideIfNoPrevNext: true, minDate: new Date(2008, 2 - 1, 4), maxDate: new Date(2008, 2 - 1, 14)}); - inp.val('02/10/2008').focus(); - header = dp.children(':first'); - ok(header.is('div.ui-datepicker-header'), 'Structure hide prev/next - header division'); - equal(header.children().length, 1, 'Structure hide prev/next - links child count'); - ok(header.children(':first').is('div.ui-datepicker-title'), 'Structure hide prev/next - title division'); - inp.datepicker('hide').datepicker('destroy'); + inp = TestHelpers.datepicker.init("#inp", {hideIfNoPrevNext: true, minDate: new Date(2008, 2 - 1, 4), maxDate: new Date(2008, 2 - 1, 14)}); + inp.val("02/10/2008").focus(); + header = dp.children(":first"); + ok(header.is("div.ui-datepicker-header"), "Structure hide prev/next - header division"); + equal(header.children().length, 1, "Structure hide prev/next - links child count"); + ok(header.children(":first").is("div.ui-datepicker-title"), "Structure hide prev/next - title division"); + inp.datepicker("hide").datepicker("destroy"); // Changeable Month with read-only year - inp = TestHelpers.datepicker.init('#inp', {changeMonth: true}); + inp = TestHelpers.datepicker.init("#inp", {changeMonth: true}); inp.focus(); - title = dp.children(':first').children(':last'); - equal(title.children().length, 2, 'Structure changeable month - title child count'); - ok(title.children(':first').is('select.ui-datepicker-month'), 'Structure changeable month - month selector'); - ok(title.children(':last').is('span.ui-datepicker-year'), 'Structure changeable month - read-only year'); - inp.datepicker('hide').datepicker('destroy'); + title = dp.children(":first").children(":last"); + equal(title.children().length, 2, "Structure changeable month - title child count"); + ok(title.children(":first").is("select.ui-datepicker-month"), "Structure changeable month - month selector"); + ok(title.children(":last").is("span.ui-datepicker-year"), "Structure changeable month - read-only year"); + inp.datepicker("hide").datepicker("destroy"); // Changeable year with read-only month - inp = TestHelpers.datepicker.init('#inp', {changeYear: true}); + inp = TestHelpers.datepicker.init("#inp", {changeYear: true}); inp.focus(); - title = dp.children(':first').children(':last'); - equal(title.children().length, 2, 'Structure changeable year - title child count'); - ok(title.children(':first').is('span.ui-datepicker-month'), 'Structure changeable year - read-only month'); - ok(title.children(':last').is('select.ui-datepicker-year'), 'Structure changeable year - year selector'); - inp.datepicker('hide').datepicker('destroy'); + title = dp.children(":first").children(":last"); + equal(title.children().length, 2, "Structure changeable year - title child count"); + ok(title.children(":first").is("span.ui-datepicker-month"), "Structure changeable year - read-only month"); + ok(title.children(":last").is("select.ui-datepicker-year"), "Structure changeable year - year selector"); + inp.datepicker("hide").datepicker("destroy"); // Read-only first day of week - inp = TestHelpers.datepicker.init('#inp', {changeFirstDay: false}); + inp = TestHelpers.datepicker.init("#inp", {changeFirstDay: false}); inp.focus(); - thead = dp.find('.ui-datepicker-calendar thead tr'); - equal(thead.children().length, 7, 'Structure read-only first day - thead child count'); - equal(thead.find('a').length, 0, 'Structure read-only first day - thead links count'); - inp.datepicker('hide').datepicker('destroy'); + thead = dp.find(".ui-datepicker-calendar thead tr"); + equal(thead.children().length, 7, "Structure read-only first day - thead child count"); + equal(thead.find("a").length, 0, "Structure read-only first day - thead links count"); + inp.datepicker("hide").datepicker("destroy"); }); -test('keystrokes', function() { +test("keystrokes", function() { expect( 26 ); - var inp = TestHelpers.datepicker.init('#inp'), + var inp = TestHelpers.datepicker.init("#inp"), date = new Date(); - inp.val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke enter'); - inp.val('02/04/2008').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4), - 'Keystroke enter - preset'); - inp.val('02/04/2008').datepicker('show'). - simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.HOME}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+home'); - inp.val('02/04/2008').datepicker('show'). - simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.END}); - ok(inp.datepicker('getDate') == null, 'Keystroke ctrl+end'); - inp.val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE}); - ok(inp.datepicker('getDate') == null, 'Keystroke esc'); - inp.val('02/04/2008').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4), - 'Keystroke esc - preset'); - inp.val('02/04/2008').datepicker('show'). - simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). - simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4), - 'Keystroke esc - abandoned'); + inp.val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke enter"); + inp.val("02/04/2008").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), + "Keystroke enter - preset"); + inp.val("02/04/2008").datepicker("show"). + simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.HOME}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+home"); + inp.val("02/04/2008").datepicker("show"). + simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.END}); + ok(inp.datepicker("getDate") == null, "Keystroke ctrl+end"); + inp.val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE}); + ok(inp.datepicker("getDate") == null, "Keystroke esc"); + inp.val("02/04/2008").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), + "Keystroke esc - preset"); + inp.val("02/04/2008").datepicker("show"). + simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). + simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), + "Keystroke esc - abandoned"); // Moving by day or week - inp.val('').datepicker('show'). - simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.LEFT}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + inp.val("").datepicker("show"). + simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.LEFT}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() - 1); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+left'); - inp.val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.LEFT}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+left"); + inp.val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.LEFT}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() + 1); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke left'); - inp.val('').datepicker('show'). - simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.RIGHT}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke left"); + inp.val("").datepicker("show"). + simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.RIGHT}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() + 1); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+right'); - inp.val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.RIGHT}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+right"); + inp.val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.RIGHT}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() - 1); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke right'); - inp.val('').datepicker('show'). - simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.UP}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke right"); + inp.val("").datepicker("show"). + simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.UP}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() - 7); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+up'); - inp.val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.UP}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+up"); + inp.val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.UP}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() + 7); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke up'); - inp.val('').datepicker('show'). - simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.DOWN}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke up"); + inp.val("").datepicker("show"). + simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.DOWN}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() + 7); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+down'); - inp.val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.DOWN}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+down"); + inp.val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.DOWN}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() - 7); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke down'); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke down"); // Moving by month or year - inp.val('02/04/2008').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.PAGE_UP}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 1 - 1, 4), - 'Keystroke pgup'); - inp.val('02/04/2008').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 3 - 1, 4), - 'Keystroke pgdn'); - inp.val('02/04/2008').datepicker('show'). - simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2007, 2 - 1, 4), - 'Keystroke ctrl+pgup'); - inp.val('02/04/2008').datepicker('show'). - simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2009, 2 - 1, 4), - 'Keystroke ctrl+pgdn'); + inp.val("02/04/2008").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 1 - 1, 4), + "Keystroke pgup"); + inp.val("02/04/2008").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 3 - 1, 4), + "Keystroke pgdn"); + inp.val("02/04/2008").datepicker("show"). + simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2007, 2 - 1, 4), + "Keystroke ctrl+pgup"); + inp.val("02/04/2008").datepicker("show"). + simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2009, 2 - 1, 4), + "Keystroke ctrl+pgdn"); // Check for moving to short months - inp.val('03/31/2008').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.PAGE_UP}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 29), - 'Keystroke pgup - Feb'); - inp.val('01/30/2008').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 29), - 'Keystroke pgdn - Feb'); - inp.val('02/29/2008').datepicker('show'). - simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2007, 2 - 1, 28), - 'Keystroke ctrl+pgup - Feb'); - inp.val('02/29/2008').datepicker('show'). - simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2009, 2 - 1, 28), - 'Keystroke ctrl+pgdn - Feb'); + inp.val("03/31/2008").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 29), + "Keystroke pgup - Feb"); + inp.val("01/30/2008").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 29), + "Keystroke pgdn - Feb"); + inp.val("02/29/2008").datepicker("show"). + simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2007, 2 - 1, 28), + "Keystroke ctrl+pgup - Feb"); + inp.val("02/29/2008").datepicker("show"). + simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2009, 2 - 1, 28), + "Keystroke ctrl+pgdn - Feb"); // Goto current - inp.datepicker('option', {gotoCurrent: true}). - datepicker('hide').val('02/04/2008').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}). - simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.HOME}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4), - 'Keystroke ctrl+home'); + inp.datepicker("option", {gotoCurrent: true}). + datepicker("hide").val("02/04/2008").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}). + simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.HOME}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), + "Keystroke ctrl+home"); // Change steps - inp.datepicker('option', {stepMonths: 2, gotoCurrent: false}). - datepicker('hide').val('02/04/2008').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.PAGE_UP}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2007, 12 - 1, 4), - 'Keystroke pgup step 2'); - inp.val('02/04/2008').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 4 - 1, 4), - 'Keystroke pgdn step 2'); + inp.datepicker("option", {stepMonths: 2, gotoCurrent: false}). + datepicker("hide").val("02/04/2008").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2007, 12 - 1, 4), + "Keystroke pgup step 2"); + inp.val("02/04/2008").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 4 - 1, 4), + "Keystroke pgdn step 2"); }); -test('mouse', function() { +test("mouse", function() { expect( 15 ); var inl, - inp = TestHelpers.datepicker.init('#inp'), - dp = $('#ui-datepicker-div'), + inp = TestHelpers.datepicker.init("#inp"), + dp = $("#ui-datepicker-div"), date = new Date(); - inp.val('').datepicker('show'); - $('.ui-datepicker-calendar tbody a:contains(10)', dp).simulate('click', {}); + inp.val("").datepicker("show"); + $(".ui-datepicker-calendar tbody a:contains(10)", dp).simulate("click", {}); date.setDate(10); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Mouse click'); - inp.val('02/04/2008').datepicker('show'); - $('.ui-datepicker-calendar tbody a:contains(12)', dp).simulate('click', {}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 12), - 'Mouse click - preset'); - inp.val('02/04/2008').datepicker('show'); - inp.val('').datepicker('show'); - $('button.ui-datepicker-close', dp).simulate('click', {}); - ok(inp.datepicker('getDate') == null, 'Mouse click - close'); - inp.val('02/04/2008').datepicker('show'); - $('button.ui-datepicker-close', dp).simulate('click', {}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4), - 'Mouse click - close + preset'); - inp.val('02/04/2008').datepicker('show'); - $('a.ui-datepicker-prev', dp).simulate('click', {}); - $('button.ui-datepicker-close', dp).simulate('click', {}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4), - 'Mouse click - abandoned'); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Mouse click"); + inp.val("02/04/2008").datepicker("show"); + $(".ui-datepicker-calendar tbody a:contains(12)", dp).simulate("click", {}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 12), + "Mouse click - preset"); + inp.val("02/04/2008").datepicker("show"); + inp.val("").datepicker("show"); + $("button.ui-datepicker-close", dp).simulate("click", {}); + ok(inp.datepicker("getDate") == null, "Mouse click - close"); + inp.val("02/04/2008").datepicker("show"); + $("button.ui-datepicker-close", dp).simulate("click", {}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), + "Mouse click - close + preset"); + inp.val("02/04/2008").datepicker("show"); + $("a.ui-datepicker-prev", dp).simulate("click", {}); + $("button.ui-datepicker-close", dp).simulate("click", {}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), + "Mouse click - abandoned"); // Current/previous/next - inp.val('02/04/2008').datepicker('option', {showButtonPanel: true}).datepicker('show'); - $('.ui-datepicker-current', dp).simulate('click', {}); - $('.ui-datepicker-calendar tbody a:contains(14)', dp).simulate('click', {}); + inp.val("02/04/2008").datepicker("option", {showButtonPanel: true}).datepicker("show"); + $(".ui-datepicker-current", dp).simulate("click", {}); + $(".ui-datepicker-calendar tbody a:contains(14)", dp).simulate("click", {}); date.setDate(14); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Mouse click - current'); - inp.val('02/04/2008').datepicker('show'); - $('.ui-datepicker-prev', dp).simulate('click'); - $('.ui-datepicker-calendar tbody a:contains(16)', dp).simulate('click'); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 1 - 1, 16), - 'Mouse click - previous'); - inp.val('02/04/2008').datepicker('show'); - $('.ui-datepicker-next', dp).simulate('click'); - $('.ui-datepicker-calendar tbody a:contains(18)', dp).simulate('click'); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 3 - 1, 18), - 'Mouse click - next'); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Mouse click - current"); + inp.val("02/04/2008").datepicker("show"); + $(".ui-datepicker-prev", dp).simulate("click"); + $(".ui-datepicker-calendar tbody a:contains(16)", dp).simulate("click"); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 1 - 1, 16), + "Mouse click - previous"); + inp.val("02/04/2008").datepicker("show"); + $(".ui-datepicker-next", dp).simulate("click"); + $(".ui-datepicker-calendar tbody a:contains(18)", dp).simulate("click"); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 3 - 1, 18), + "Mouse click - next"); // Previous/next with minimum/maximum - inp.datepicker('option', {minDate: new Date(2008, 2 - 1, 2), - maxDate: new Date(2008, 2 - 1, 26)}).val('02/04/2008').datepicker('show'); - $('.ui-datepicker-prev', dp).simulate('click'); - $('.ui-datepicker-calendar tbody a:contains(16)', dp).simulate('click'); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 16), - 'Mouse click - previous + min/max'); - inp.val('02/04/2008').datepicker('show'); - $('.ui-datepicker-next', dp).simulate('click'); - $('.ui-datepicker-calendar tbody a:contains(18)', dp).simulate('click'); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 18), - 'Mouse click - next + min/max'); + inp.datepicker("option", {minDate: new Date(2008, 2 - 1, 2), + maxDate: new Date(2008, 2 - 1, 26)}).val("02/04/2008").datepicker("show"); + $(".ui-datepicker-prev", dp).simulate("click"); + $(".ui-datepicker-calendar tbody a:contains(16)", dp).simulate("click"); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 16), + "Mouse click - previous + min/max"); + inp.val("02/04/2008").datepicker("show"); + $(".ui-datepicker-next", dp).simulate("click"); + $(".ui-datepicker-calendar tbody a:contains(18)", dp).simulate("click"); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 18), + "Mouse click - next + min/max"); // Inline - inl = TestHelpers.datepicker.init('#inl'); - dp = $('.ui-datepicker-inline', inl); + inl = TestHelpers.datepicker.init("#inl"); + dp = $(".ui-datepicker-inline", inl); date = new Date(); - inl.datepicker('setDate', date); - $('.ui-datepicker-calendar tbody a:contains(10)', dp).simulate('click', {}); + inl.datepicker("setDate", date); + $(".ui-datepicker-calendar tbody a:contains(10)", dp).simulate("click", {}); date.setDate(10); - TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), date, 'Mouse click inline'); - inl.datepicker('option', {showButtonPanel: true}).datepicker('setDate', new Date(2008, 2 - 1, 4)); - $('.ui-datepicker-calendar tbody a:contains(12)', dp).simulate('click', {}); - TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), new Date(2008, 2 - 1, 12), 'Mouse click inline - preset'); - inl.datepicker('option', {showButtonPanel: true}); - $('.ui-datepicker-current', dp).simulate('click', {}); - $('.ui-datepicker-calendar tbody a:contains(14)', dp).simulate('click', {}); + TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), date, "Mouse click inline"); + inl.datepicker("option", {showButtonPanel: true}).datepicker("setDate", new Date(2008, 2 - 1, 4)); + $(".ui-datepicker-calendar tbody a:contains(12)", dp).simulate("click", {}); + TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), new Date(2008, 2 - 1, 12), "Mouse click inline - preset"); + inl.datepicker("option", {showButtonPanel: true}); + $(".ui-datepicker-current", dp).simulate("click", {}); + $(".ui-datepicker-calendar tbody a:contains(14)", dp).simulate("click", {}); date.setDate(14); - TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), date, 'Mouse click inline - current'); - inl.datepicker('setDate', new Date(2008, 2 - 1, 4)); - $('.ui-datepicker-prev', dp).simulate('click'); - $('.ui-datepicker-calendar tbody a:contains(16)', dp).simulate('click'); - TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), new Date(2008, 1 - 1, 16), - 'Mouse click inline - previous'); - inl.datepicker('setDate', new Date(2008, 2 - 1, 4)); - $('.ui-datepicker-next', dp).simulate('click'); - $('.ui-datepicker-calendar tbody a:contains(18)', dp).simulate('click'); - TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), new Date(2008, 3 - 1, 18), - 'Mouse click inline - next'); + TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), date, "Mouse click inline - current"); + inl.datepicker("setDate", new Date(2008, 2 - 1, 4)); + $(".ui-datepicker-prev", dp).simulate("click"); + $(".ui-datepicker-calendar tbody a:contains(16)", dp).simulate("click"); + TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), new Date(2008, 1 - 1, 16), + "Mouse click inline - previous"); + inl.datepicker("setDate", new Date(2008, 2 - 1, 4)); + $(".ui-datepicker-next", dp).simulate("click"); + $(".ui-datepicker-calendar tbody a:contains(18)", dp).simulate("click"); + TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), new Date(2008, 3 - 1, 18), + "Mouse click inline - next"); }); })(jQuery); diff --git a/tests/unit/datepicker/datepicker_events.js b/tests/unit/datepicker/datepicker_events.js index 43b0a4b23..dfc42ccf9 100644 --- a/tests/unit/datepicker/datepicker_events.js +++ b/tests/unit/datepicker/datepicker_events.js @@ -17,137 +17,137 @@ function callback(date, inst) { function callback2(year, month, inst) { selectedThis = this; - selectedDate = year + '/' + month; + selectedDate = year + "/" + month; selectedInst = inst; } -test('events', function() { +test("events", function() { expect( 26 ); var dateStr, newMonthYear, inp2, - inp = TestHelpers.datepicker.init('#inp', {onSelect: callback}), + inp = TestHelpers.datepicker.init("#inp", {onSelect: callback}), date = new Date(); // onSelect - inp.val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - equal(selectedThis, inp[0], 'Callback selected this'); - equal(selectedInst, $.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Callback selected inst'); - equal(selectedDate, $.datepicker.formatDate('mm/dd/yy', date), - 'Callback selected date'); - inp.val('').datepicker('show'). - simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.DOWN}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + inp.val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + equal(selectedThis, inp[0], "Callback selected this"); + equal(selectedInst, $.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Callback selected inst"); + equal(selectedDate, $.datepicker.formatDate("mm/dd/yy", date), + "Callback selected date"); + inp.val("").datepicker("show"). + simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.DOWN}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() + 7); - equal(selectedDate, $.datepicker.formatDate('mm/dd/yy', date), - 'Callback selected date - ctrl+down'); - inp.val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE}); - equal(selectedDate, $.datepicker.formatDate('mm/dd/yy', date), - 'Callback selected date - esc'); - dateStr = '02/04/2008'; - inp.val(dateStr).datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + equal(selectedDate, $.datepicker.formatDate("mm/dd/yy", date), + "Callback selected date - ctrl+down"); + inp.val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE}); + equal(selectedDate, $.datepicker.formatDate("mm/dd/yy", date), + "Callback selected date - esc"); + dateStr = "02/04/2008"; + inp.val(dateStr).datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); equal(dateStr, selectedDate, - 'onSelect is called after enter keydown'); + "onSelect is called after enter keydown"); // onChangeMonthYear - inp.datepicker('option', {onChangeMonthYear: callback2, onSelect: null}). - val('').datepicker('show'); + inp.datepicker("option", {onChangeMonthYear: callback2, onSelect: null}). + val("").datepicker("show"); newMonthYear = function(date) { - return date.getFullYear() + '/' + (date.getMonth() + 1); + return date.getFullYear() + "/" + (date.getMonth() + 1); }; date = new Date(); date.setDate(1); - inp.simulate('keydown', {keyCode: $.ui.keyCode.PAGE_UP}); + inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP}); date.setMonth(date.getMonth() - 1); - equal(selectedThis, inp[0], 'Callback change month/year this'); - equal(selectedInst, $.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Callback change month/year inst'); + equal(selectedThis, inp[0], "Callback change month/year this"); + equal(selectedInst, $.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Callback change month/year inst"); equal(selectedDate, newMonthYear(date), - 'Callback change month/year date - pgup'); - inp.simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}); + "Callback change month/year date - pgup"); + inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}); date.setMonth(date.getMonth() + 1); equal(selectedDate, newMonthYear(date), - 'Callback change month/year date - pgdn'); - inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}); + "Callback change month/year date - pgdn"); + inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}); date.setFullYear(date.getFullYear() - 1); equal(selectedDate, newMonthYear(date), - 'Callback change month/year date - ctrl+pgup'); - inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.HOME}); + "Callback change month/year date - ctrl+pgup"); + inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.HOME}); date.setFullYear(date.getFullYear() + 1); equal(selectedDate, newMonthYear(date), - 'Callback change month/year date - ctrl+home'); - inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}); + "Callback change month/year date - ctrl+home"); + inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}); date.setFullYear(date.getFullYear() + 1); equal(selectedDate, newMonthYear(date), - 'Callback change month/year date - ctrl+pgdn'); - inp.datepicker('setDate', new Date(2007, 1 - 1, 26)); - equal(selectedDate, '2007/1', 'Callback change month/year date - setDate'); + "Callback change month/year date - ctrl+pgdn"); + inp.datepicker("setDate", new Date(2007, 1 - 1, 26)); + equal(selectedDate, "2007/1", "Callback change month/year date - setDate"); selectedDate = null; - inp.datepicker('setDate', new Date(2007, 1 - 1, 12)); - ok(selectedDate == null, 'Callback change month/year date - setDate no change'); + inp.datepicker("setDate", new Date(2007, 1 - 1, 12)); + ok(selectedDate == null, "Callback change month/year date - setDate no change"); // onChangeMonthYear step by 2 - inp.datepicker('option', {stepMonths: 2}). - datepicker('hide').val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.PAGE_UP}); + inp.datepicker("option", {stepMonths: 2}). + datepicker("hide").val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP}); date.setMonth(date.getMonth() - 14); equal(selectedDate, newMonthYear(date), - 'Callback change month/year by 2 date - pgup'); - inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}); + "Callback change month/year by 2 date - pgup"); + inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}); date.setMonth(date.getMonth() - 12); equal(selectedDate, newMonthYear(date), - 'Callback change month/year by 2 date - ctrl+pgup'); - inp.simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}); + "Callback change month/year by 2 date - ctrl+pgup"); + inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}); date.setMonth(date.getMonth() + 2); equal(selectedDate, newMonthYear(date), - 'Callback change month/year by 2 date - pgdn'); - inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}); + "Callback change month/year by 2 date - pgdn"); + inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}); date.setMonth(date.getMonth() + 12); equal(selectedDate, newMonthYear(date), - 'Callback change month/year by 2 date - ctrl+pgdn'); + "Callback change month/year by 2 date - ctrl+pgdn"); // onClose - inp.datepicker('option', {onClose: callback, onChangeMonthYear: null, stepMonths: 1}). - val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE}); - equal(selectedThis, inp[0], 'Callback close this'); - equal(selectedInst, $.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Callback close inst'); - equal(selectedDate, '', 'Callback close date - esc'); - inp.val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - equal(selectedDate, $.datepicker.formatDate('mm/dd/yy', new Date()), - 'Callback close date - enter'); - inp.val('02/04/2008').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE}); - equal(selectedDate, '02/04/2008', 'Callback close date - preset'); - inp.val('02/04/2008').datepicker('show'). - simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.END}); - equal(selectedDate, '', 'Callback close date - ctrl+end'); + inp.datepicker("option", {onClose: callback, onChangeMonthYear: null, stepMonths: 1}). + val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE}); + equal(selectedThis, inp[0], "Callback close this"); + equal(selectedInst, $.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Callback close inst"); + equal(selectedDate, "", "Callback close date - esc"); + inp.val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + equal(selectedDate, $.datepicker.formatDate("mm/dd/yy", new Date()), + "Callback close date - enter"); + inp.val("02/04/2008").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE}); + equal(selectedDate, "02/04/2008", "Callback close date - preset"); + inp.val("02/04/2008").datepicker("show"). + simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.END}); + equal(selectedDate, "", "Callback close date - ctrl+end"); - inp2 = TestHelpers.datepicker.init('#inp2'); - inp2.datepicker().datepicker('option', {onClose: callback}).datepicker('show'); - inp.datepicker('show'); - equal(selectedThis, inp2[0], 'Callback close this'); + inp2 = TestHelpers.datepicker.init("#inp2"); + inp2.datepicker().datepicker("option", {onClose: callback}).datepicker("show"); + inp.datepicker("show"); + equal(selectedThis, inp2[0], "Callback close this"); }); -test('beforeShowDay-getDate', function() { +test("beforeShowDay-getDate", function() { expect( 3 ); - var inp = TestHelpers.datepicker.init('#inp', {beforeShowDay: function() { inp.datepicker('getDate'); return [true, '']; }}), - dp = $('#ui-datepicker-div'); - inp.val('01/01/2010').datepicker('show'); + var inp = TestHelpers.datepicker.init("#inp", {beforeShowDay: function() { inp.datepicker("getDate"); return [true, ""]; }}), + dp = $("#ui-datepicker-div"); + inp.val("01/01/2010").datepicker("show"); // contains non-breaking space - equal($('div.ui-datepicker-title').text(), + equal($("div.ui-datepicker-title").text(), // support: IE <9, jQuery <1.8 // In IE7/8 with jQuery <1.8, encoded spaces behave in strange ways - $( "<span>January 2010</span>" ).text(), 'Initial month'); - $('a.ui-datepicker-next', dp).click(); - $('a.ui-datepicker-next', dp).click(); + $( "<span>January 2010</span>" ).text(), "Initial month"); + $("a.ui-datepicker-next", dp).click(); + $("a.ui-datepicker-next", dp).click(); // contains non-breaking space - equal($('div.ui-datepicker-title').text(), - $( "<span>March 2010</span>" ).text(), 'After next clicks'); - inp.datepicker('hide').datepicker('show'); - $('a.ui-datepicker-prev', dp).click(); - $('a.ui-datepicker-prev', dp).click(); + equal($("div.ui-datepicker-title").text(), + $( "<span>March 2010</span>" ).text(), "After next clicks"); + inp.datepicker("hide").datepicker("show"); + $("a.ui-datepicker-prev", dp).click(); + $("a.ui-datepicker-prev", dp).click(); // contains non-breaking space - equal($('div.ui-datepicker-title').text(), - $( "<span>November 2009</span>" ).text(), 'After prev clicks'); - inp.datepicker('hide'); + equal($("div.ui-datepicker-title").text(), + $( "<span>November 2009</span>" ).text(), "After prev clicks"); + inp.datepicker("hide"); }); })(jQuery); diff --git a/tests/unit/datepicker/datepicker_methods.js b/tests/unit/datepicker/datepicker_methods.js index d2964a266..77217e449 100644 --- a/tests/unit/datepicker/datepicker_methods.js +++ b/tests/unit/datepicker/datepicker_methods.js @@ -5,121 +5,121 @@ module("datepicker: methods"); -test('destroy', function() { +test("destroy", function() { expect( 33 ); var inl, - inp = TestHelpers.datepicker.init('#inp'); - ok(inp.is('.hasDatepicker'), 'Default - marker class set'); - ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Default - instance present'); - ok(inp.next().is('#alt'), 'Default - button absent'); - inp.datepicker('destroy'); - inp = $('#inp'); - ok(!inp.is('.hasDatepicker'), 'Default - marker class cleared'); - ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Default - instance absent'); - ok(inp.next().is('#alt'), 'Default - button absent'); + inp = TestHelpers.datepicker.init("#inp"); + ok(inp.is(".hasDatepicker"), "Default - marker class set"); + ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Default - instance present"); + ok(inp.next().is("#alt"), "Default - button absent"); + inp.datepicker("destroy"); + inp = $("#inp"); + ok(!inp.is(".hasDatepicker"), "Default - marker class cleared"); + ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Default - instance absent"); + ok(inp.next().is("#alt"), "Default - button absent"); // With button - inp= TestHelpers.datepicker.init('#inp', {showOn: 'both'}); - ok(inp.is('.hasDatepicker'), 'Button - marker class set'); - ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Button - instance present'); - ok(inp.next().text() === '...', 'Button - button added'); - inp.datepicker('destroy'); - inp = $('#inp'); - ok(!inp.is('.hasDatepicker'), 'Button - marker class cleared'); - ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Button - instance absent'); - ok(inp.next().is('#alt'), 'Button - button removed'); + inp= TestHelpers.datepicker.init("#inp", {showOn: "both"}); + ok(inp.is(".hasDatepicker"), "Button - marker class set"); + ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Button - instance present"); + ok(inp.next().text() === "...", "Button - button added"); + inp.datepicker("destroy"); + inp = $("#inp"); + ok(!inp.is(".hasDatepicker"), "Button - marker class cleared"); + ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Button - instance absent"); + ok(inp.next().is("#alt"), "Button - button removed"); // With append text - inp = TestHelpers.datepicker.init('#inp', {appendText: 'Testing'}); - ok(inp.is('.hasDatepicker'), 'Append - marker class set'); - ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Append - instance present'); - ok(inp.next().text() === 'Testing', 'Append - append text added'); - inp.datepicker('destroy'); - inp = $('#inp'); - ok(!inp.is('.hasDatepicker'), 'Append - marker class cleared'); - ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Append - instance absent'); - ok(inp.next().is('#alt'), 'Append - append text removed'); + inp = TestHelpers.datepicker.init("#inp", {appendText: "Testing"}); + ok(inp.is(".hasDatepicker"), "Append - marker class set"); + ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Append - instance present"); + ok(inp.next().text() === "Testing", "Append - append text added"); + inp.datepicker("destroy"); + inp = $("#inp"); + ok(!inp.is(".hasDatepicker"), "Append - marker class cleared"); + ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Append - instance absent"); + ok(inp.next().is("#alt"), "Append - append text removed"); // With both - inp= TestHelpers.datepicker.init('#inp', {showOn: 'both', buttonImageOnly: true, - buttonImage: 'img/calendar.gif', appendText: 'Testing'}); - ok(inp.is('.hasDatepicker'), 'Both - marker class set'); - ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Both - instance present'); - ok(inp.next()[0].nodeName.toLowerCase() === 'img', 'Both - button added'); - ok(inp.next().next().text() === 'Testing', 'Both - append text added'); - inp.datepicker('destroy'); - inp = $('#inp'); - ok(!inp.is('.hasDatepicker'), 'Both - marker class cleared'); - ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Both - instance absent'); - ok(inp.next().is('#alt'), 'Both - button and append text absent'); + inp= TestHelpers.datepicker.init("#inp", {showOn: "both", buttonImageOnly: true, + buttonImage: "img/calendar.gif", appendText: "Testing"}); + ok(inp.is(".hasDatepicker"), "Both - marker class set"); + ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Both - instance present"); + ok(inp.next()[0].nodeName.toLowerCase() === "img", "Both - button added"); + ok(inp.next().next().text() === "Testing", "Both - append text added"); + inp.datepicker("destroy"); + inp = $("#inp"); + ok(!inp.is(".hasDatepicker"), "Both - marker class cleared"); + ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Both - instance absent"); + ok(inp.next().is("#alt"), "Both - button and append text absent"); // Inline - inl = TestHelpers.datepicker.init('#inl'); - ok(inl.is('.hasDatepicker'), 'Inline - marker class set'); - ok(inl.html() !== '', 'Inline - datepicker present'); - ok($.data(inl[0], TestHelpers.datepicker.PROP_NAME), 'Inline - instance present'); - ok(inl.next().length === 0 || inl.next().is('p'), 'Inline - button absent'); - inl.datepicker('destroy'); - inl = $('#inl'); - ok(!inl.is('.hasDatepicker'), 'Inline - marker class cleared'); - ok(inl.html() === '', 'Inline - datepicker absent'); - ok(!$.data(inl[0], TestHelpers.datepicker.PROP_NAME), 'Inline - instance absent'); - ok(inl.next().length === 0 || inl.next().is('p'), 'Inline - button absent'); + inl = TestHelpers.datepicker.init("#inl"); + ok(inl.is(".hasDatepicker"), "Inline - marker class set"); + ok(inl.html() !== "", "Inline - datepicker present"); + ok($.data(inl[0], TestHelpers.datepicker.PROP_NAME), "Inline - instance present"); + ok(inl.next().length === 0 || inl.next().is("p"), "Inline - button absent"); + inl.datepicker("destroy"); + inl = $("#inl"); + ok(!inl.is(".hasDatepicker"), "Inline - marker class cleared"); + ok(inl.html() === "", "Inline - datepicker absent"); + ok(!$.data(inl[0], TestHelpers.datepicker.PROP_NAME), "Inline - instance absent"); + ok(inl.next().length === 0 || inl.next().is("p"), "Inline - button absent"); }); -test('enableDisable', function() { +test("enableDisable", function() { expect( 33 ); var inl, dp, - inp = TestHelpers.datepicker.init('#inp'); - ok(!inp.datepicker('isDisabled'), 'Enable/disable - initially marked as enabled'); - ok(!inp[0].disabled, 'Enable/disable - field initially enabled'); - inp.datepicker('disable'); - ok(inp.datepicker('isDisabled'), 'Enable/disable - now marked as disabled'); - ok(inp[0].disabled, 'Enable/disable - field now disabled'); - inp.datepicker('enable'); - ok(!inp.datepicker('isDisabled'), 'Enable/disable - now marked as enabled'); - ok(!inp[0].disabled, 'Enable/disable - field now enabled'); - inp.datepicker('destroy'); + inp = TestHelpers.datepicker.init("#inp"); + ok(!inp.datepicker("isDisabled"), "Enable/disable - initially marked as enabled"); + ok(!inp[0].disabled, "Enable/disable - field initially enabled"); + inp.datepicker("disable"); + ok(inp.datepicker("isDisabled"), "Enable/disable - now marked as disabled"); + ok(inp[0].disabled, "Enable/disable - field now disabled"); + inp.datepicker("enable"); + ok(!inp.datepicker("isDisabled"), "Enable/disable - now marked as enabled"); + ok(!inp[0].disabled, "Enable/disable - field now enabled"); + inp.datepicker("destroy"); // With a button - inp = TestHelpers.datepicker.init('#inp', {showOn: 'button'}); - ok(!inp.datepicker('isDisabled'), 'Enable/disable button - initially marked as enabled'); - ok(!inp[0].disabled, 'Enable/disable button - field initially enabled'); - ok(!inp.next('button')[0].disabled, 'Enable/disable button - button initially enabled'); - inp.datepicker('disable'); - ok(inp.datepicker('isDisabled'), 'Enable/disable button - now marked as disabled'); - ok(inp[0].disabled, 'Enable/disable button - field now disabled'); - ok(inp.next('button')[0].disabled, 'Enable/disable button - button now disabled'); - inp.datepicker('enable'); - ok(!inp.datepicker('isDisabled'), 'Enable/disable button - now marked as enabled'); - ok(!inp[0].disabled, 'Enable/disable button - field now enabled'); - ok(!inp.next('button')[0].disabled, 'Enable/disable button - button now enabled'); - inp.datepicker('destroy'); + inp = TestHelpers.datepicker.init("#inp", {showOn: "button"}); + ok(!inp.datepicker("isDisabled"), "Enable/disable button - initially marked as enabled"); + ok(!inp[0].disabled, "Enable/disable button - field initially enabled"); + ok(!inp.next("button")[0].disabled, "Enable/disable button - button initially enabled"); + inp.datepicker("disable"); + ok(inp.datepicker("isDisabled"), "Enable/disable button - now marked as disabled"); + ok(inp[0].disabled, "Enable/disable button - field now disabled"); + ok(inp.next("button")[0].disabled, "Enable/disable button - button now disabled"); + inp.datepicker("enable"); + ok(!inp.datepicker("isDisabled"), "Enable/disable button - now marked as enabled"); + ok(!inp[0].disabled, "Enable/disable button - field now enabled"); + ok(!inp.next("button")[0].disabled, "Enable/disable button - button now enabled"); + inp.datepicker("destroy"); // With an image button - inp = TestHelpers.datepicker.init('#inp', {showOn: 'button', buttonImageOnly: true, - buttonImage: 'img/calendar.gif'}); - ok(!inp.datepicker('isDisabled'), 'Enable/disable image - initially marked as enabled'); - ok(!inp[0].disabled, 'Enable/disable image - field initially enabled'); - ok(parseFloat(inp.next('img').css('opacity')) === 1, 'Enable/disable image - image initially enabled'); - inp.datepicker('disable'); - ok(inp.datepicker('isDisabled'), 'Enable/disable image - now marked as disabled'); - ok(inp[0].disabled, 'Enable/disable image - field now disabled'); - ok(parseFloat(inp.next('img').css('opacity')) !== 1, 'Enable/disable image - image now disabled'); - inp.datepicker('enable'); - ok(!inp.datepicker('isDisabled'), 'Enable/disable image - now marked as enabled'); - ok(!inp[0].disabled, 'Enable/disable image - field now enabled'); - ok(parseFloat(inp.next('img').css('opacity')) === 1, 'Enable/disable image - image now enabled'); - inp.datepicker('destroy'); + inp = TestHelpers.datepicker.init("#inp", {showOn: "button", buttonImageOnly: true, + buttonImage: "img/calendar.gif"}); + ok(!inp.datepicker("isDisabled"), "Enable/disable image - initially marked as enabled"); + ok(!inp[0].disabled, "Enable/disable image - field initially enabled"); + ok(parseFloat(inp.next("img").css("opacity")) === 1, "Enable/disable image - image initially enabled"); + inp.datepicker("disable"); + ok(inp.datepicker("isDisabled"), "Enable/disable image - now marked as disabled"); + ok(inp[0].disabled, "Enable/disable image - field now disabled"); + ok(parseFloat(inp.next("img").css("opacity")) !== 1, "Enable/disable image - image now disabled"); + inp.datepicker("enable"); + ok(!inp.datepicker("isDisabled"), "Enable/disable image - now marked as enabled"); + ok(!inp[0].disabled, "Enable/disable image - field now enabled"); + ok(parseFloat(inp.next("img").css("opacity")) === 1, "Enable/disable image - image now enabled"); + inp.datepicker("destroy"); // Inline - inl = TestHelpers.datepicker.init('#inl', {changeYear: true}); - dp = $('.ui-datepicker-inline', inl); - ok(!inl.datepicker('isDisabled'), 'Enable/disable inline - initially marked as enabled'); - ok(!dp.children().is('.ui-state-disabled'), 'Enable/disable inline - not visually disabled initially'); - ok(!dp.find('select').prop('disabled'), 'Enable/disable inline - form element enabled initially'); - inl.datepicker('disable'); - ok(inl.datepicker('isDisabled'), 'Enable/disable inline - now marked as disabled'); - ok(dp.children().is('.ui-state-disabled'), 'Enable/disable inline - visually disabled'); - ok(dp.find('select').prop('disabled'), 'Enable/disable inline - form element disabled'); - inl.datepicker('enable'); - ok(!inl.datepicker('isDisabled'), 'Enable/disable inline - now marked as enabled'); - ok(!dp.children().is('.ui-state-disabled'), 'Enable/disable inline - not visiually disabled'); - ok(!dp.find('select').prop('disabled'), 'Enable/disable inline - form element enabled'); - inl.datepicker('destroy'); + inl = TestHelpers.datepicker.init("#inl", {changeYear: true}); + dp = $(".ui-datepicker-inline", inl); + ok(!inl.datepicker("isDisabled"), "Enable/disable inline - initially marked as enabled"); + ok(!dp.children().is(".ui-state-disabled"), "Enable/disable inline - not visually disabled initially"); + ok(!dp.find("select").prop("disabled"), "Enable/disable inline - form element enabled initially"); + inl.datepicker("disable"); + ok(inl.datepicker("isDisabled"), "Enable/disable inline - now marked as disabled"); + ok(dp.children().is(".ui-state-disabled"), "Enable/disable inline - visually disabled"); + ok(dp.find("select").prop("disabled"), "Enable/disable inline - form element disabled"); + inl.datepicker("enable"); + ok(!inl.datepicker("isDisabled"), "Enable/disable inline - now marked as enabled"); + ok(!dp.children().is(".ui-state-disabled"), "Enable/disable inline - not visiually disabled"); + ok(!dp.find("select").prop("disabled"), "Enable/disable inline - form element enabled"); + inl.datepicker("destroy"); }); })(jQuery); diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index c5e53b85e..5603dc87b 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -6,113 +6,113 @@ module("datepicker: options"); -test('setDefaults', function() { +test("setDefaults", function() { expect( 3 ); - TestHelpers.datepicker.init('#inp'); - equal($.datepicker._defaults.showOn, 'focus', 'Initial showOn'); - $.datepicker.setDefaults({showOn: 'button'}); - equal($.datepicker._defaults.showOn, 'button', 'Change default showOn'); - $.datepicker.setDefaults({showOn: 'focus'}); - equal($.datepicker._defaults.showOn, 'focus', 'Restore showOn'); + TestHelpers.datepicker.init("#inp"); + equal($.datepicker._defaults.showOn, "focus", "Initial showOn"); + $.datepicker.setDefaults({showOn: "button"}); + equal($.datepicker._defaults.showOn, "button", "Change default showOn"); + $.datepicker.setDefaults({showOn: "focus"}); + equal($.datepicker._defaults.showOn, "focus", "Restore showOn"); }); -test('option', function() { +test("option", function() { expect( 17 ); - var inp = TestHelpers.datepicker.init('#inp'), + var inp = TestHelpers.datepicker.init("#inp"), inst = $.data(inp[0], TestHelpers.datepicker.PROP_NAME); // Set option - equal(inst.settings.showOn, null, 'Initial setting showOn'); - equal($.datepicker._get(inst, 'showOn'), 'focus', 'Initial instance showOn'); - equal($.datepicker._defaults.showOn, 'focus', 'Initial default showOn'); - inp.datepicker('option', 'showOn', 'button'); - equal(inst.settings.showOn, 'button', 'Change setting showOn'); - equal($.datepicker._get(inst, 'showOn'), 'button', 'Change instance showOn'); - equal($.datepicker._defaults.showOn, 'focus', 'Retain default showOn'); - inp.datepicker('option', {showOn: 'both'}); - equal(inst.settings.showOn, 'both', 'Change setting showOn'); - equal($.datepicker._get(inst, 'showOn'), 'both', 'Change instance showOn'); - equal($.datepicker._defaults.showOn, 'focus', 'Retain default showOn'); - inp.datepicker('option', 'showOn', undefined); - equal(inst.settings.showOn, null, 'Clear setting showOn'); - equal($.datepicker._get(inst, 'showOn'), 'focus', 'Restore instance showOn'); - equal($.datepicker._defaults.showOn, 'focus', 'Retain default showOn'); + equal(inst.settings.showOn, null, "Initial setting showOn"); + equal($.datepicker._get(inst, "showOn"), "focus", "Initial instance showOn"); + equal($.datepicker._defaults.showOn, "focus", "Initial default showOn"); + inp.datepicker("option", "showOn", "button"); + equal(inst.settings.showOn, "button", "Change setting showOn"); + equal($.datepicker._get(inst, "showOn"), "button", "Change instance showOn"); + equal($.datepicker._defaults.showOn, "focus", "Retain default showOn"); + inp.datepicker("option", {showOn: "both"}); + equal(inst.settings.showOn, "both", "Change setting showOn"); + equal($.datepicker._get(inst, "showOn"), "both", "Change instance showOn"); + equal($.datepicker._defaults.showOn, "focus", "Retain default showOn"); + inp.datepicker("option", "showOn", undefined); + equal(inst.settings.showOn, null, "Clear setting showOn"); + equal($.datepicker._get(inst, "showOn"), "focus", "Restore instance showOn"); + equal($.datepicker._defaults.showOn, "focus", "Retain default showOn"); // Get option - inp = TestHelpers.datepicker.init('#inp'); - equal(inp.datepicker('option', 'showOn'), 'focus', 'Initial setting showOn'); - inp.datepicker('option', 'showOn', 'button'); - equal(inp.datepicker('option', 'showOn'), 'button', 'Change instance showOn'); - inp.datepicker('option', 'showOn', undefined); - equal(inp.datepicker('option', 'showOn'), 'focus', 'Reset instance showOn'); - deepEqual(inp.datepicker('option', 'all'), {showAnim: ''}, 'Get instance settings'); - deepEqual(inp.datepicker('option', 'defaults'), $.datepicker._defaults, - 'Get default settings'); + inp = TestHelpers.datepicker.init("#inp"); + equal(inp.datepicker("option", "showOn"), "focus", "Initial setting showOn"); + inp.datepicker("option", "showOn", "button"); + equal(inp.datepicker("option", "showOn"), "button", "Change instance showOn"); + inp.datepicker("option", "showOn", undefined); + equal(inp.datepicker("option", "showOn"), "focus", "Reset instance showOn"); + deepEqual(inp.datepicker("option", "all"), {showAnim: ""}, "Get instance settings"); + deepEqual(inp.datepicker("option", "defaults"), $.datepicker._defaults, + "Get default settings"); }); test( "disabled", function() { expect(8); - var inp = TestHelpers.datepicker.init('#inp'); - ok(!inp.datepicker('isDisabled'), 'Initially marked as enabled'); - ok(!inp[0].disabled, 'Field initially enabled'); - inp.datepicker('option', 'disabled', true); - ok(inp.datepicker('isDisabled'), 'Marked as disabled'); - ok(inp[0].disabled, 'Field now disabled'); - inp.datepicker('option', 'disabled', false); - ok(!inp.datepicker('isDisabled'), 'Marked as enabled'); - ok(!inp[0].disabled, 'Field now enabled'); - inp.datepicker('destroy'); + var inp = TestHelpers.datepicker.init("#inp"); + ok(!inp.datepicker("isDisabled"), "Initially marked as enabled"); + ok(!inp[0].disabled, "Field initially enabled"); + inp.datepicker("option", "disabled", true); + ok(inp.datepicker("isDisabled"), "Marked as disabled"); + ok(inp[0].disabled, "Field now disabled"); + inp.datepicker("option", "disabled", false); + ok(!inp.datepicker("isDisabled"), "Marked as enabled"); + ok(!inp[0].disabled, "Field now enabled"); + inp.datepicker("destroy"); - inp = TestHelpers.datepicker.init('#inp', { disabled: true }); - ok(inp.datepicker('isDisabled'), 'Initially marked as disabled'); - ok(inp[0].disabled, 'Field initially disabled'); + inp = TestHelpers.datepicker.init("#inp", { disabled: true }); + ok(inp.datepicker("isDisabled"), "Initially marked as disabled"); + ok(inp[0].disabled, "Field initially disabled"); }); -test('change', function() { +test("change", function() { expect( 12 ); - var inp = TestHelpers.datepicker.init('#inp'), + var inp = TestHelpers.datepicker.init("#inp"), inst = $.data(inp[0], TestHelpers.datepicker.PROP_NAME); - equal(inst.settings.showOn, null, 'Initial setting showOn'); - equal($.datepicker._get(inst, 'showOn'), 'focus', 'Initial instance showOn'); - equal($.datepicker._defaults.showOn, 'focus', 'Initial default showOn'); - inp.datepicker('change', 'showOn', 'button'); - equal(inst.settings.showOn, 'button', 'Change setting showOn'); - equal($.datepicker._get(inst, 'showOn'), 'button', 'Change instance showOn'); - equal($.datepicker._defaults.showOn, 'focus', 'Retain default showOn'); - inp.datepicker('change', {showOn: 'both'}); - equal(inst.settings.showOn, 'both', 'Change setting showOn'); - equal($.datepicker._get(inst, 'showOn'), 'both', 'Change instance showOn'); - equal($.datepicker._defaults.showOn, 'focus', 'Retain default showOn'); - inp.datepicker('change', 'showOn', undefined); - equal(inst.settings.showOn, null, 'Clear setting showOn'); - equal($.datepicker._get(inst, 'showOn'), 'focus', 'Restore instance showOn'); - equal($.datepicker._defaults.showOn, 'focus', 'Retain default showOn'); + equal(inst.settings.showOn, null, "Initial setting showOn"); + equal($.datepicker._get(inst, "showOn"), "focus", "Initial instance showOn"); + equal($.datepicker._defaults.showOn, "focus", "Initial default showOn"); + inp.datepicker("change", "showOn", "button"); + equal(inst.settings.showOn, "button", "Change setting showOn"); + equal($.datepicker._get(inst, "showOn"), "button", "Change instance showOn"); + equal($.datepicker._defaults.showOn, "focus", "Retain default showOn"); + inp.datepicker("change", {showOn: "both"}); + equal(inst.settings.showOn, "both", "Change setting showOn"); + equal($.datepicker._get(inst, "showOn"), "both", "Change instance showOn"); + equal($.datepicker._defaults.showOn, "focus", "Retain default showOn"); + inp.datepicker("change", "showOn", undefined); + equal(inst.settings.showOn, null, "Clear setting showOn"); + equal($.datepicker._get(inst, "showOn"), "focus", "Restore instance showOn"); + equal($.datepicker._defaults.showOn, "focus", "Retain default showOn"); }); -asyncTest('invocation', function() { +asyncTest("invocation", function() { expect( 29 ); var button, image, - inp = TestHelpers.datepicker.init('#inp'), - dp = $('#ui-datepicker-div'), - body = $('body'); + inp = TestHelpers.datepicker.init("#inp"), + dp = $("#ui-datepicker-div"), + body = $("body"); function step1() { // On focus - button = inp.siblings('button'); - ok(button.length === 0, 'Focus - button absent'); - image = inp.siblings('img'); - ok(image.length === 0, 'Focus - image absent'); + button = inp.siblings("button"); + ok(button.length === 0, "Focus - button absent"); + image = inp.siblings("img"); + ok(image.length === 0, "Focus - image absent"); inp[0].focus(); setTimeout(function() { - ok(dp.is(':visible'), 'Focus - rendered on focus'); - inp.simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE}); - ok(!dp.is(':visible'), 'Focus - hidden on exit'); + ok(dp.is(":visible"), "Focus - rendered on focus"); + inp.simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE}); + ok(!dp.is(":visible"), "Focus - hidden on exit"); inp[0].blur(); setTimeout(function() { inp[0].focus(); setTimeout(function() { - ok(dp.is(':visible'), 'Focus - rendered on focus'); - body.simulate('mousedown', {}); - ok(!dp.is(':visible'), 'Focus - hidden on external click'); - inp.datepicker('hide').datepicker('destroy'); + ok(dp.is(":visible"), "Focus - rendered on focus"); + body.simulate("mousedown", {}); + ok(!dp.is(":visible"), "Focus - hidden on external click"); + inp.datepicker("hide").datepicker("destroy"); step2(); }); @@ -122,21 +122,21 @@ asyncTest('invocation', function() { function step2() { // On button - inp = TestHelpers.datepicker.init('#inp', {showOn: 'button', buttonText: 'Popup'}); - ok(!dp.is(':visible'), 'Button - initially hidden'); - button = inp.siblings('button'); - image = inp.siblings('img'); - ok(button.length === 1, 'Button - button present'); - ok(image.length === 0, 'Button - image absent'); - equal(button.text(), 'Popup', 'Button - button text'); + inp = TestHelpers.datepicker.init("#inp", {showOn: "button", buttonText: "Popup"}); + ok(!dp.is(":visible"), "Button - initially hidden"); + button = inp.siblings("button"); + image = inp.siblings("img"); + ok(button.length === 1, "Button - button present"); + ok(image.length === 0, "Button - image absent"); + equal(button.text(), "Popup", "Button - button text"); inp[0].focus(); setTimeout(function() { - ok(!dp.is(':visible'), 'Button - not rendered on focus'); + ok(!dp.is(":visible"), "Button - not rendered on focus"); button.click(); - ok(dp.is(':visible'), 'Button - rendered on button click'); + ok(dp.is(":visible"), "Button - rendered on button click"); button.click(); - ok(!dp.is(':visible'), 'Button - hidden on second button click'); - inp.datepicker('hide').datepicker('destroy'); + ok(!dp.is(":visible"), "Button - hidden on second button click"); + inp.datepicker("hide").datepicker("destroy"); step3(); }); @@ -144,23 +144,23 @@ asyncTest('invocation', function() { function step3() { // On image button - inp = TestHelpers.datepicker.init('#inp', {showOn: 'button', buttonImageOnly: true, - buttonImage: 'img/calendar.gif', buttonText: 'Cal'}); - ok(!dp.is(':visible'), 'Image button - initially hidden'); - button = inp.siblings('button'); - ok(button.length === 0, 'Image button - button absent'); - image = inp.siblings('img'); - ok(image.length === 1, 'Image button - image present'); - equal(image.attr('src'), 'img/calendar.gif', 'Image button - image source'); - equal(image.attr('title'), 'Cal', 'Image button - image text'); + inp = TestHelpers.datepicker.init("#inp", {showOn: "button", buttonImageOnly: true, + buttonImage: "img/calendar.gif", buttonText: "Cal"}); + ok(!dp.is(":visible"), "Image button - initially hidden"); + button = inp.siblings("button"); + ok(button.length === 0, "Image button - button absent"); + image = inp.siblings("img"); + ok(image.length === 1, "Image button - image present"); + equal(image.attr("src"), "img/calendar.gif", "Image button - image source"); + equal(image.attr("title"), "Cal", "Image button - image text"); inp[0].focus(); setTimeout(function() { - ok(!dp.is(':visible'), 'Image button - not rendered on focus'); + ok(!dp.is(":visible"), "Image button - not rendered on focus"); image.click(); - ok(dp.is(':visible'), 'Image button - rendered on image click'); + ok(dp.is(":visible"), "Image button - rendered on image click"); image.click(); - ok(!dp.is(':visible'), 'Image button - hidden on second image click'); - inp.datepicker('hide').datepicker('destroy'); + ok(!dp.is(":visible"), "Image button - hidden on second image click"); + inp.datepicker("hide").datepicker("destroy"); step4(); }); @@ -168,26 +168,26 @@ asyncTest('invocation', function() { function step4() { // On both - inp = TestHelpers.datepicker.init('#inp', {showOn: 'both', buttonImage: 'img/calendar.gif'}); - ok(!dp.is(':visible'), 'Both - initially hidden'); - button = inp.siblings('button'); - ok(button.length === 1, 'Both - button present'); - image = inp.siblings('img'); - ok(image.length === 0, 'Both - image absent'); - image = button.children('img'); - ok(image.length === 1, 'Both - button image present'); + inp = TestHelpers.datepicker.init("#inp", {showOn: "both", buttonImage: "img/calendar.gif"}); + ok(!dp.is(":visible"), "Both - initially hidden"); + button = inp.siblings("button"); + ok(button.length === 1, "Both - button present"); + image = inp.siblings("img"); + ok(image.length === 0, "Both - image absent"); + image = button.children("img"); + ok(image.length === 1, "Both - button image present"); inp[0].blur(); setTimeout(function() { inp[0].focus(); setTimeout(function() { - ok(dp.is(':visible'), 'Both - rendered on focus'); - body.simulate('mousedown', {}); - ok(!dp.is(':visible'), 'Both - hidden on external click'); + ok(dp.is(":visible"), "Both - rendered on focus"); + body.simulate("mousedown", {}); + ok(!dp.is(":visible"), "Both - hidden on external click"); button.click(); - ok(dp.is(':visible'), 'Both - rendered on button click'); + ok(dp.is(":visible"), "Both - rendered on button click"); button.click(); - ok(!dp.is(':visible'), 'Both - hidden on second button click'); - inp.datepicker('hide').datepicker('destroy'); + ok(!dp.is(":visible"), "Both - hidden on second button click"); + inp.datepicker("hide").datepicker("destroy"); start(); }); @@ -197,521 +197,521 @@ asyncTest('invocation', function() { step1(); }); -test('otherMonths', function() { +test("otherMonths", function() { expect( 8 ); - var inp = TestHelpers.datepicker.init('#inp'), - pop = $('#ui-datepicker-div'); - inp.val('06/01/2009').datepicker('show'); - equal(pop.find('tbody').text(), + var inp = TestHelpers.datepicker.init("#inp"), + pop = $("#ui-datepicker-div"); + inp.val("06/01/2009").datepicker("show"); + equal(pop.find("tbody").text(), // support: IE <9, jQuery <1.8 // In IE7/8 with jQuery <1.8, encoded spaces behave in strange ways $( "<span>\u00a0123456789101112131415161718192021222324252627282930\u00a0\u00a0\u00a0\u00a0</span>" ).text(), - 'Other months - none'); - ok(pop.find('td:last *').length === 0, 'Other months - no content'); - inp.datepicker('hide').datepicker('option', 'showOtherMonths', true).datepicker('show'); - equal(pop.find('tbody').text(), '311234567891011121314151617181920212223242526272829301234', - 'Other months - show'); - ok(pop.find('td:last span').length === 1, 'Other months - span content'); - inp.datepicker('hide').datepicker('option', 'selectOtherMonths', true).datepicker('show'); - equal(pop.find('tbody').text(), '311234567891011121314151617181920212223242526272829301234', - 'Other months - select'); - ok(pop.find('td:last a').length === 1, 'Other months - link content'); - inp.datepicker('hide').datepicker('option', 'showOtherMonths', false).datepicker('show'); - equal(pop.find('tbody').text(), + "Other months - none"); + ok(pop.find("td:last *").length === 0, "Other months - no content"); + inp.datepicker("hide").datepicker("option", "showOtherMonths", true).datepicker("show"); + equal(pop.find("tbody").text(), "311234567891011121314151617181920212223242526272829301234", + "Other months - show"); + ok(pop.find("td:last span").length === 1, "Other months - span content"); + inp.datepicker("hide").datepicker("option", "selectOtherMonths", true).datepicker("show"); + equal(pop.find("tbody").text(), "311234567891011121314151617181920212223242526272829301234", + "Other months - select"); + ok(pop.find("td:last a").length === 1, "Other months - link content"); + inp.datepicker("hide").datepicker("option", "showOtherMonths", false).datepicker("show"); + equal(pop.find("tbody").text(), // support: IE <9, jQuery <1.8 // In IE7/8 with jQuery <1.8, encoded spaces behave in strange ways $( "<span>\u00a0123456789101112131415161718192021222324252627282930\u00a0\u00a0\u00a0\u00a0</span>" ).text(), - 'Other months - none'); - ok(pop.find('td:last *').length === 0, 'Other months - no content'); + "Other months - none"); + ok(pop.find("td:last *").length === 0, "Other months - no content"); }); -test('defaultDate', function() { +test("defaultDate", function() { expect( 16 ); - var inp = TestHelpers.datepicker.init('#inp'), + var inp = TestHelpers.datepicker.init("#inp"), date = new Date(); - inp.val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date null'); + inp.val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date null"); // Numeric values - inp.datepicker('option', {defaultDate: -2}). - datepicker('hide').val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + inp.datepicker("option", {defaultDate: -2}). + datepicker("hide").val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() - 2); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date -2'); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date -2"); date = new Date(); - inp.datepicker('option', {defaultDate: 3}). - datepicker('hide').val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + inp.datepicker("option", {defaultDate: 3}). + datepicker("hide").val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() + 3); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date 3'); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date 3"); date = new Date(); - inp.datepicker('option', {defaultDate: 1 / 'a'}). - datepicker('hide').val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date NaN'); + inp.datepicker("option", {defaultDate: 1 / "a"}). + datepicker("hide").val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date NaN"); // String offset values - inp.datepicker('option', {defaultDate: '-1d'}). - datepicker('hide').val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + inp.datepicker("option", {defaultDate: "-1d"}). + datepicker("hide").val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() - 1); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date -1d'); - inp.datepicker('option', {defaultDate: '+3D'}). - datepicker('hide').val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date -1d"); + inp.datepicker("option", {defaultDate: "+3D"}). + datepicker("hide").val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() + 4); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date +3D'); - inp.datepicker('option', {defaultDate: ' -2 w '}). - datepicker('hide').val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date +3D"); + inp.datepicker("option", {defaultDate: " -2 w "}). + datepicker("hide").val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date = new Date(); date.setDate(date.getDate() - 14); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date -2 w'); - inp.datepicker('option', {defaultDate: '+1 W'}). - datepicker('hide').val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date -2 w"); + inp.datepicker("option", {defaultDate: "+1 W"}). + datepicker("hide").val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() + 21); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date +1 W'); - inp.datepicker('option', {defaultDate: ' -1 m '}). - datepicker('hide').val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date +1 W"); + inp.datepicker("option", {defaultDate: " -1 m "}). + datepicker("hide").val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date = TestHelpers.datepicker.addMonths(new Date(), -1); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date -1 m'); - inp.datepicker('option', {defaultDate: '+2M'}). - datepicker('hide').val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date -1 m"); + inp.datepicker("option", {defaultDate: "+2M"}). + datepicker("hide").val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date = TestHelpers.datepicker.addMonths(new Date(), 2); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date +2M'); - inp.datepicker('option', {defaultDate: '-2y'}). - datepicker('hide').val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date +2M"); + inp.datepicker("option", {defaultDate: "-2y"}). + datepicker("hide").val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date = new Date(); date.setFullYear(date.getFullYear() - 2); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date -2y'); - inp.datepicker('option', {defaultDate: '+1 Y '}). - datepicker('hide').val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date -2y"); + inp.datepicker("option", {defaultDate: "+1 Y "}). + datepicker("hide").val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setFullYear(date.getFullYear() + 3); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date +1 Y'); - inp.datepicker('option', {defaultDate: '+1M +10d'}). - datepicker('hide').val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date +1 Y"); + inp.datepicker("option", {defaultDate: "+1M +10d"}). + datepicker("hide").val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date = TestHelpers.datepicker.addMonths(new Date(), 1); date.setDate(date.getDate() + 10); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date +1M +10d'); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date +1M +10d"); // String date values - inp.datepicker('option', {defaultDate: '07/04/2007'}). - datepicker('hide').val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + inp.datepicker("option", {defaultDate: "07/04/2007"}). + datepicker("hide").val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date = new Date(2007, 7 - 1, 4); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date 07/04/2007'); - inp.datepicker('option', {dateFormat: 'yy-mm-dd', defaultDate: '2007-04-02'}). - datepicker('hide').val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date 07/04/2007"); + inp.datepicker("option", {dateFormat: "yy-mm-dd", defaultDate: "2007-04-02"}). + datepicker("hide").val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date = new Date(2007, 4 - 1, 2); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date 2007-04-02'); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date 2007-04-02"); // Date value date = new Date(2007, 1 - 1, 26); - inp.datepicker('option', {dateFormat: 'mm/dd/yy', defaultDate: date}). - datepicker('hide').val('').datepicker('show'). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date 01/26/2007'); + inp.datepicker("option", {dateFormat: "mm/dd/yy", defaultDate: date}). + datepicker("hide").val("").datepicker("show"). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date 01/26/2007"); }); -test('miscellaneous', function() { +test("miscellaneous", function() { expect( 19 ); var curYear, longNames, shortNames, date, - dp = $('#ui-datepicker-div'), - inp = TestHelpers.datepicker.init('#inp'); + dp = $("#ui-datepicker-div"), + inp = TestHelpers.datepicker.init("#inp"); // Year range function genRange(start, offset) { var i = start, - range = ''; + range = ""; for (; i < start + offset; i++) { range += i; } return range; } curYear = new Date().getFullYear(); - inp.val('02/04/2008').datepicker('show'); - equal(dp.find('.ui-datepicker-year').text(), '2008', 'Year range - read-only default'); - inp.datepicker('hide').datepicker('option', {changeYear: true}).datepicker('show'); - equal(dp.find('.ui-datepicker-year').text(), genRange(2008 - 10, 21), 'Year range - changeable default'); - inp.datepicker('hide').datepicker('option', {yearRange: 'c-6:c+2', changeYear: true}).datepicker('show'); - equal(dp.find('.ui-datepicker-year').text(), genRange(2008 - 6, 9), 'Year range - c-6:c+2'); - inp.datepicker('hide').datepicker('option', {yearRange: '2000:2010', changeYear: true}).datepicker('show'); - equal(dp.find('.ui-datepicker-year').text(), genRange(2000, 11), 'Year range - 2000:2010'); - inp.datepicker('hide').datepicker('option', {yearRange: '-5:+3', changeYear: true}).datepicker('show'); - equal(dp.find('.ui-datepicker-year').text(), genRange(curYear - 5, 9), 'Year range - -5:+3'); - inp.datepicker('hide').datepicker('option', {yearRange: '2000:-5', changeYear: true}).datepicker('show'); - equal(dp.find('.ui-datepicker-year').text(), genRange(2000, curYear - 2004), 'Year range - 2000:-5'); - inp.datepicker('hide').datepicker('option', {yearRange: '', changeYear: true}).datepicker('show'); - equal(dp.find('.ui-datepicker-year').text(), genRange(curYear, 1), 'Year range - -6:+2'); + inp.val("02/04/2008").datepicker("show"); + equal(dp.find(".ui-datepicker-year").text(), "2008", "Year range - read-only default"); + inp.datepicker("hide").datepicker("option", {changeYear: true}).datepicker("show"); + equal(dp.find(".ui-datepicker-year").text(), genRange(2008 - 10, 21), "Year range - changeable default"); + inp.datepicker("hide").datepicker("option", {yearRange: "c-6:c+2", changeYear: true}).datepicker("show"); + equal(dp.find(".ui-datepicker-year").text(), genRange(2008 - 6, 9), "Year range - c-6:c+2"); + inp.datepicker("hide").datepicker("option", {yearRange: "2000:2010", changeYear: true}).datepicker("show"); + equal(dp.find(".ui-datepicker-year").text(), genRange(2000, 11), "Year range - 2000:2010"); + inp.datepicker("hide").datepicker("option", {yearRange: "-5:+3", changeYear: true}).datepicker("show"); + equal(dp.find(".ui-datepicker-year").text(), genRange(curYear - 5, 9), "Year range - -5:+3"); + inp.datepicker("hide").datepicker("option", {yearRange: "2000:-5", changeYear: true}).datepicker("show"); + equal(dp.find(".ui-datepicker-year").text(), genRange(2000, curYear - 2004), "Year range - 2000:-5"); + inp.datepicker("hide").datepicker("option", {yearRange: "", changeYear: true}).datepicker("show"); + equal(dp.find(".ui-datepicker-year").text(), genRange(curYear, 1), "Year range - -6:+2"); // Navigation as date format - inp.datepicker('option', {showButtonPanel: true}); - equal(dp.find('.ui-datepicker-prev').text(), 'Prev', 'Navigation prev - default'); - equal(dp.find('.ui-datepicker-current').text(), 'Today', 'Navigation current - default'); - equal(dp.find('.ui-datepicker-next').text(), 'Next', 'Navigation next - default'); - inp.datepicker('hide').datepicker('option', {navigationAsDateFormat: true, prevText: '< M', currentText: 'MM', nextText: 'M >'}). - val('02/04/2008').datepicker('show'); - longNames = $.datepicker.regional[''].monthNames; - shortNames = $.datepicker.regional[''].monthNamesShort; + inp.datepicker("option", {showButtonPanel: true}); + equal(dp.find(".ui-datepicker-prev").text(), "Prev", "Navigation prev - default"); + equal(dp.find(".ui-datepicker-current").text(), "Today", "Navigation current - default"); + equal(dp.find(".ui-datepicker-next").text(), "Next", "Navigation next - default"); + inp.datepicker("hide").datepicker("option", {navigationAsDateFormat: true, prevText: "< M", currentText: "MM", nextText: "M >"}). + val("02/04/2008").datepicker("show"); + longNames = $.datepicker.regional[""].monthNames; + shortNames = $.datepicker.regional[""].monthNamesShort; date = new Date(); - equal(dp.find('.ui-datepicker-prev').text(), '< ' + shortNames[0], 'Navigation prev - as date format'); - equal(dp.find('.ui-datepicker-current').text(), - longNames[date.getMonth()], 'Navigation current - as date format'); - equal(dp.find('.ui-datepicker-next').text(), - shortNames[2] + ' >', 'Navigation next - as date format'); - inp.simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}); - equal(dp.find('.ui-datepicker-prev').text(), - '< ' + shortNames[1], 'Navigation prev - as date format + pgdn'); - equal(dp.find('.ui-datepicker-current').text(), - longNames[date.getMonth()], 'Navigation current - as date format + pgdn'); - equal(dp.find('.ui-datepicker-next').text(), - shortNames[3] + ' >', 'Navigation next - as date format + pgdn'); - inp.datepicker('hide').datepicker('option', {gotoCurrent: true}). - val('02/04/2008').datepicker('show'); - equal(dp.find('.ui-datepicker-prev').text(), - '< ' + shortNames[0], 'Navigation prev - as date format + goto current'); - equal(dp.find('.ui-datepicker-current').text(), - longNames[1], 'Navigation current - as date format + goto current'); - equal(dp.find('.ui-datepicker-next').text(), - shortNames[2] + ' >', 'Navigation next - as date format + goto current'); + equal(dp.find(".ui-datepicker-prev").text(), "< " + shortNames[0], "Navigation prev - as date format"); + equal(dp.find(".ui-datepicker-current").text(), + longNames[date.getMonth()], "Navigation current - as date format"); + equal(dp.find(".ui-datepicker-next").text(), + shortNames[2] + " >", "Navigation next - as date format"); + inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}); + equal(dp.find(".ui-datepicker-prev").text(), + "< " + shortNames[1], "Navigation prev - as date format + pgdn"); + equal(dp.find(".ui-datepicker-current").text(), + longNames[date.getMonth()], "Navigation current - as date format + pgdn"); + equal(dp.find(".ui-datepicker-next").text(), + shortNames[3] + " >", "Navigation next - as date format + pgdn"); + inp.datepicker("hide").datepicker("option", {gotoCurrent: true}). + val("02/04/2008").datepicker("show"); + equal(dp.find(".ui-datepicker-prev").text(), + "< " + shortNames[0], "Navigation prev - as date format + goto current"); + equal(dp.find(".ui-datepicker-current").text(), + longNames[1], "Navigation current - as date format + goto current"); + equal(dp.find(".ui-datepicker-next").text(), + shortNames[2] + " >", "Navigation next - as date format + goto current"); }); -test('minMax', function() { +test("minMax", function() { expect( 19 ); var date, - inp = TestHelpers.datepicker.init('#inp'), - dp = $('#ui-datepicker-div'), + inp = TestHelpers.datepicker.init("#inp"), + dp = $("#ui-datepicker-div"), lastYear = new Date(2007, 6 - 1, 4), nextYear = new Date(2009, 6 - 1, 4), minDate = new Date(2008, 2 - 1, 29), maxDate = new Date(2008, 12 - 1, 7); - inp.val('06/04/2008').datepicker('show'); - inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), lastYear, - 'Min/max - null, null - ctrl+pgup'); - inp.val('06/04/2008').datepicker('show'); - inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), nextYear, - 'Min/max - null, null - ctrl+pgdn'); - inp.datepicker('option', {minDate: minDate}). - datepicker('hide').val('06/04/2008').datepicker('show'); - inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), minDate, - 'Min/max - 02/29/2008, null - ctrl+pgup'); - inp.val('06/04/2008').datepicker('show'); - inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), nextYear, - 'Min/max - 02/29/2008, null - ctrl+pgdn'); - inp.datepicker('option', {maxDate: maxDate}). - datepicker('hide').val('06/04/2008').datepicker('show'); - inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), minDate, - 'Min/max - 02/29/2008, 12/07/2008 - ctrl+pgup'); - inp.val('06/04/2008').datepicker('show'); - inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), maxDate, - 'Min/max - 02/29/2008, 12/07/2008 - ctrl+pgdn'); - inp.datepicker('option', {minDate: null}). - datepicker('hide').val('06/04/2008').datepicker('show'); - inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), lastYear, - 'Min/max - null, 12/07/2008 - ctrl+pgup'); - inp.val('06/04/2008').datepicker('show'); - inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), maxDate, - 'Min/max - null, 12/07/2008 - ctrl+pgdn'); + inp.val("06/04/2008").datepicker("show"); + inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), lastYear, + "Min/max - null, null - ctrl+pgup"); + inp.val("06/04/2008").datepicker("show"); + inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), nextYear, + "Min/max - null, null - ctrl+pgdn"); + inp.datepicker("option", {minDate: minDate}). + datepicker("hide").val("06/04/2008").datepicker("show"); + inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), minDate, + "Min/max - 02/29/2008, null - ctrl+pgup"); + inp.val("06/04/2008").datepicker("show"); + inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), nextYear, + "Min/max - 02/29/2008, null - ctrl+pgdn"); + inp.datepicker("option", {maxDate: maxDate}). + datepicker("hide").val("06/04/2008").datepicker("show"); + inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), minDate, + "Min/max - 02/29/2008, 12/07/2008 - ctrl+pgup"); + inp.val("06/04/2008").datepicker("show"); + inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), maxDate, + "Min/max - 02/29/2008, 12/07/2008 - ctrl+pgdn"); + inp.datepicker("option", {minDate: null}). + datepicker("hide").val("06/04/2008").datepicker("show"); + inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), lastYear, + "Min/max - null, 12/07/2008 - ctrl+pgup"); + inp.val("06/04/2008").datepicker("show"); + inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), maxDate, + "Min/max - null, 12/07/2008 - ctrl+pgdn"); // Relative dates date = new Date(); date.setDate(date.getDate() - 7); - inp.datepicker('option', {minDate: '-1w', maxDate: '+1 M +10 D '}). - datepicker('hide').val('').datepicker('show'); - inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, - 'Min/max - -1w, +1 M +10 D - ctrl+pgup'); + inp.datepicker("option", {minDate: "-1w", maxDate: "+1 M +10 D "}). + datepicker("hide").val("").datepicker("show"); + inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, + "Min/max - -1w, +1 M +10 D - ctrl+pgup"); date = TestHelpers.datepicker.addMonths(new Date(), 1); date.setDate(date.getDate() + 10); - inp.val('').datepicker('show'); - inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, - 'Min/max - -1w, +1 M +10 D - ctrl+pgdn'); + inp.val("").datepicker("show"); + inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, + "Min/max - -1w, +1 M +10 D - ctrl+pgdn"); // With existing date - inp = TestHelpers.datepicker.init('#inp'); - inp.val('06/04/2008').datepicker('option', {minDate: minDate}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 6 - 1, 4), 'Min/max - setDate > min'); - inp.datepicker('option', {minDate: null}).val('01/04/2008').datepicker('option', {minDate: minDate}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), minDate, 'Min/max - setDate < min'); - inp.datepicker('option', {minDate: null}).val('06/04/2008').datepicker('option', {maxDate: maxDate}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 6 - 1, 4), 'Min/max - setDate < max'); - inp.datepicker('option', {maxDate: null}).val('01/04/2009').datepicker('option', {maxDate: maxDate}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), maxDate, 'Min/max - setDate > max'); - inp.datepicker('option', {maxDate: null}).val('01/04/2008').datepicker('option', {minDate: minDate, maxDate: maxDate}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), minDate, 'Min/max - setDate < min'); - inp.datepicker('option', {maxDate: null}).val('06/04/2008').datepicker('option', {minDate: minDate, maxDate: maxDate}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 6 - 1, 4), 'Min/max - setDate > min, < max'); - inp.datepicker('option', {maxDate: null}).val('01/04/2009').datepicker('option', {minDate: minDate, maxDate: maxDate}); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), maxDate, 'Min/max - setDate > max'); + inp = TestHelpers.datepicker.init("#inp"); + inp.val("06/04/2008").datepicker("option", {minDate: minDate}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 6 - 1, 4), "Min/max - setDate > min"); + inp.datepicker("option", {minDate: null}).val("01/04/2008").datepicker("option", {minDate: minDate}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), minDate, "Min/max - setDate < min"); + inp.datepicker("option", {minDate: null}).val("06/04/2008").datepicker("option", {maxDate: maxDate}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 6 - 1, 4), "Min/max - setDate < max"); + inp.datepicker("option", {maxDate: null}).val("01/04/2009").datepicker("option", {maxDate: maxDate}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), maxDate, "Min/max - setDate > max"); + inp.datepicker("option", {maxDate: null}).val("01/04/2008").datepicker("option", {minDate: minDate, maxDate: maxDate}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), minDate, "Min/max - setDate < min"); + inp.datepicker("option", {maxDate: null}).val("06/04/2008").datepicker("option", {minDate: minDate, maxDate: maxDate}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 6 - 1, 4), "Min/max - setDate > min, < max"); + inp.datepicker("option", {maxDate: null}).val("01/04/2009").datepicker("option", {minDate: minDate, maxDate: maxDate}); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), maxDate, "Min/max - setDate > max"); - inp.datepicker('option', {yearRange: '-0:+1'}).val('01/01/' + new Date().getFullYear()); + inp.datepicker("option", {yearRange: "-0:+1"}).val("01/01/" + new Date().getFullYear()); ok(dp.find(".ui-datepicker-prev").hasClass("ui-state-disabled"), "Year Range Test - previous button disabled at 1/1/minYear"); inp.datepicker("setDate", "12/30/" + new Date().getFullYear()); ok(dp.find(".ui-datepicker-next").hasClass("ui-state-disabled"), "Year Range Test - next button disabled at 12/30/maxYear"); }); -test('setDate', function() { +test("setDate", function() { expect( 24 ); var inl, alt, minDate, maxDate, dateAndTimeToSet, dateAndTimeClone, - inp = TestHelpers.datepicker.init('#inp'), + inp = TestHelpers.datepicker.init("#inp"), date1 = new Date(2008, 6 - 1, 4), date2 = new Date(); - ok(inp.datepicker('getDate') == null, 'Set date - default'); - inp.datepicker('setDate', date1); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date1, 'Set date - 2008-06-04'); + ok(inp.datepicker("getDate") == null, "Set date - default"); + inp.datepicker("setDate", date1); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date1, "Set date - 2008-06-04"); date1 = new Date(); date1.setDate(date1.getDate() + 7); - inp.datepicker('setDate', +7); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date1, 'Set date - +7'); + inp.datepicker("setDate", +7); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date1, "Set date - +7"); date2.setFullYear(date2.getFullYear() + 2); - inp.datepicker('setDate', '+2y'); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date2, 'Set date - +2y'); - inp.datepicker('setDate', date1, date2); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date1, 'Set date - two dates'); - inp.datepicker('setDate'); - ok(inp.datepicker('getDate') == null, 'Set date - null'); + inp.datepicker("setDate", "+2y"); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date2, "Set date - +2y"); + inp.datepicker("setDate", date1, date2); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date1, "Set date - two dates"); + inp.datepicker("setDate"); + ok(inp.datepicker("getDate") == null, "Set date - null"); // Relative to current date date1 = new Date(); date1.setDate(date1.getDate() + 7); - inp.datepicker('setDate', 'c +7'); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date1, 'Set date - c +7'); + inp.datepicker("setDate", "c +7"); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date1, "Set date - c +7"); date1.setDate(date1.getDate() + 7); - inp.datepicker('setDate', 'c+7'); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date1, 'Set date - c+7'); + inp.datepicker("setDate", "c+7"); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date1, "Set date - c+7"); date1.setDate(date1.getDate() - 21); - inp.datepicker('setDate', 'c -3 w'); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date1, 'Set date - c -3 w'); + inp.datepicker("setDate", "c -3 w"); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date1, "Set date - c -3 w"); // Inline - inl = TestHelpers.datepicker.init('#inl'); + inl = TestHelpers.datepicker.init("#inl"); date1 = new Date(2008, 6 - 1, 4); date2 = new Date(); - TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), date2, 'Set date inline - default'); - inl.datepicker('setDate', date1); - TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), date1, 'Set date inline - 2008-06-04'); + TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), date2, "Set date inline - default"); + inl.datepicker("setDate", date1); + TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), date1, "Set date inline - 2008-06-04"); date1 = new Date(); date1.setDate(date1.getDate() + 7); - inl.datepicker('setDate', +7); - TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), date1, 'Set date inline - +7'); + inl.datepicker("setDate", +7); + TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), date1, "Set date inline - +7"); date2.setFullYear(date2.getFullYear() + 2); - inl.datepicker('setDate', '+2y'); - TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), date2, 'Set date inline - +2y'); - inl.datepicker('setDate', date1, date2); - TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), date1, 'Set date inline - two dates'); - inl.datepicker('setDate'); - ok(inl.datepicker('getDate') == null, 'Set date inline - null'); + inl.datepicker("setDate", "+2y"); + TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), date2, "Set date inline - +2y"); + inl.datepicker("setDate", date1, date2); + TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), date1, "Set date inline - two dates"); + inl.datepicker("setDate"); + ok(inl.datepicker("getDate") == null, "Set date inline - null"); // Alternate field - alt = $('#alt'); - inp.datepicker('option', {altField: '#alt', altFormat: 'yy-mm-dd'}); + alt = $("#alt"); + inp.datepicker("option", {altField: "#alt", altFormat: "yy-mm-dd"}); date1 = new Date(2008, 6 - 1, 4); - inp.datepicker('setDate', date1); - equal(inp.val(), '06/04/2008', 'Set date alternate - 06/04/2008'); - equal(alt.val(), '2008-06-04', 'Set date alternate - 2008-06-04'); + inp.datepicker("setDate", date1); + equal(inp.val(), "06/04/2008", "Set date alternate - 06/04/2008"); + equal(alt.val(), "2008-06-04", "Set date alternate - 2008-06-04"); // With minimum/maximum - inp = TestHelpers.datepicker.init('#inp'); + inp = TestHelpers.datepicker.init("#inp"); date1 = new Date(2008, 1 - 1, 4); date2 = new Date(2008, 6 - 1, 4); minDate = new Date(2008, 2 - 1, 29); maxDate = new Date(2008, 3 - 1, 28); - inp.val('').datepicker('option', {minDate: minDate}).datepicker('setDate', date2); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date2, 'Set date min/max - setDate > min'); - inp.datepicker('setDate', date1); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), minDate, 'Set date min/max - setDate < min'); - inp.val('').datepicker('option', {maxDate: maxDate, minDate: null}).datepicker('setDate', date1); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date1, 'Set date min/max - setDate < max'); - inp.datepicker('setDate', date2); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), maxDate, 'Set date min/max - setDate > max'); - inp.val('').datepicker('option', {minDate: minDate}).datepicker('setDate', date1); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), minDate, 'Set date min/max - setDate < min'); - inp.datepicker('setDate', date2); - TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), maxDate, 'Set date min/max - setDate > max'); + inp.val("").datepicker("option", {minDate: minDate}).datepicker("setDate", date2); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date2, "Set date min/max - setDate > min"); + inp.datepicker("setDate", date1); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), minDate, "Set date min/max - setDate < min"); + inp.val("").datepicker("option", {maxDate: maxDate, minDate: null}).datepicker("setDate", date1); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date1, "Set date min/max - setDate < max"); + inp.datepicker("setDate", date2); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), maxDate, "Set date min/max - setDate > max"); + inp.val("").datepicker("option", {minDate: minDate}).datepicker("setDate", date1); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), minDate, "Set date min/max - setDate < min"); + inp.datepicker("setDate", date2); + TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), maxDate, "Set date min/max - setDate > max"); dateAndTimeToSet = new Date(2008, 3 - 1, 28, 1, 11, 0); dateAndTimeClone = new Date(2008, 3 - 1, 28, 1, 11, 0); - inp.datepicker('setDate', dateAndTimeToSet); - equal(dateAndTimeToSet.getTime(), dateAndTimeClone.getTime(), 'Date object passed should not be changed by setDate'); + inp.datepicker("setDate", dateAndTimeToSet); + equal(dateAndTimeToSet.getTime(), dateAndTimeClone.getTime(), "Date object passed should not be changed by setDate"); }); -test('altField', function() { +test("altField", function() { expect( 10 ); - var inp = TestHelpers.datepicker.init('#inp'), - alt = $('#alt'); + var inp = TestHelpers.datepicker.init("#inp"), + alt = $("#alt"); // No alternate field set - alt.val(''); - inp.val('06/04/2008').datepicker('show'); - inp.simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - equal(inp.val(), '06/04/2008', 'Alt field - dp - enter'); - equal(alt.val(), '', 'Alt field - alt not set'); + alt.val(""); + inp.val("06/04/2008").datepicker("show"); + inp.simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + equal(inp.val(), "06/04/2008", "Alt field - dp - enter"); + equal(alt.val(), "", "Alt field - alt not set"); // Alternate field set - alt.val(''); - inp.datepicker('option', {altField: '#alt', altFormat: 'yy-mm-dd'}). - val('06/04/2008').datepicker('show'); - inp.simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - equal(inp.val(), '06/04/2008', 'Alt field - dp - enter'); - equal(alt.val(), '2008-06-04', 'Alt field - alt - enter'); + alt.val(""); + inp.datepicker("option", {altField: "#alt", altFormat: "yy-mm-dd"}). + val("06/04/2008").datepicker("show"); + inp.simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + equal(inp.val(), "06/04/2008", "Alt field - dp - enter"); + equal(alt.val(), "2008-06-04", "Alt field - alt - enter"); // Move from initial date - alt.val(''); - inp.val('06/04/2008').datepicker('show'); - inp.simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}). - simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - equal(inp.val(), '07/04/2008', 'Alt field - dp - pgdn'); - equal(alt.val(), '2008-07-04', 'Alt field - alt - pgdn'); + alt.val(""); + inp.val("06/04/2008").datepicker("show"); + inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}). + simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); + equal(inp.val(), "07/04/2008", "Alt field - dp - pgdn"); + equal(alt.val(), "2008-07-04", "Alt field - alt - pgdn"); // Alternate field set - closed - alt.val(''); - inp.val('06/04/2008').datepicker('show'); - inp.simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}). - simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE}); - equal(inp.val(), '06/04/2008', 'Alt field - dp - pgdn/esc'); - equal(alt.val(), '', 'Alt field - alt - pgdn/esc'); + alt.val(""); + inp.val("06/04/2008").datepicker("show"); + inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}). + simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE}); + equal(inp.val(), "06/04/2008", "Alt field - dp - pgdn/esc"); + equal(alt.val(), "", "Alt field - alt - pgdn/esc"); // Clear date and alternate - alt.val(''); - inp.val('06/04/2008').datepicker('show'); - inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.END}); - equal(inp.val(), '', 'Alt field - dp - ctrl+end'); - equal(alt.val(), '', 'Alt field - alt - ctrl+end'); + alt.val(""); + inp.val("06/04/2008").datepicker("show"); + inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.END}); + equal(inp.val(), "", "Alt field - dp - ctrl+end"); + equal(alt.val(), "", "Alt field - alt - ctrl+end"); }); -test('autoSize', function() { +test("autoSize", function() { expect( 15 ); - var inp = TestHelpers.datepicker.init('#inp'); - equal(inp.prop('size'), 20, 'Auto size - default'); - inp.datepicker('option', 'autoSize', true); - equal(inp.prop('size'), 10, 'Auto size - mm/dd/yy'); - inp.datepicker('option', 'dateFormat', 'm/d/yy'); - equal(inp.prop('size'), 10, 'Auto size - m/d/yy'); - inp.datepicker('option', 'dateFormat', 'D M d yy'); - equal(inp.prop('size'), 15, 'Auto size - D M d yy'); - inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy'); - equal(inp.prop('size'), 29, 'Auto size - DD, MM dd, yy'); + var inp = TestHelpers.datepicker.init("#inp"); + equal(inp.prop("size"), 20, "Auto size - default"); + inp.datepicker("option", "autoSize", true); + equal(inp.prop("size"), 10, "Auto size - mm/dd/yy"); + inp.datepicker("option", "dateFormat", "m/d/yy"); + equal(inp.prop("size"), 10, "Auto size - m/d/yy"); + inp.datepicker("option", "dateFormat", "D M d yy"); + equal(inp.prop("size"), 15, "Auto size - D M d yy"); + inp.datepicker("option", "dateFormat", "DD, MM dd, yy"); + equal(inp.prop("size"), 29, "Auto size - DD, MM dd, yy"); // French - inp.datepicker('option', $.extend({autoSize: false}, $.datepicker.regional.fr)); - equal(inp.prop('size'), 29, 'Auto size - fr - default'); - inp.datepicker('option', 'autoSize', true); - equal(inp.prop('size'), 10, 'Auto size - fr - dd/mm/yy'); - inp.datepicker('option', 'dateFormat', 'm/d/yy'); - equal(inp.prop('size'), 10, 'Auto size - fr - m/d/yy'); - inp.datepicker('option', 'dateFormat', 'D M d yy'); - equal(inp.prop('size'), 18, 'Auto size - fr - D M d yy'); - inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy'); - equal(inp.prop('size'), 28, 'Auto size - fr - DD, MM dd, yy'); + inp.datepicker("option", $.extend({autoSize: false}, $.datepicker.regional.fr)); + equal(inp.prop("size"), 29, "Auto size - fr - default"); + inp.datepicker("option", "autoSize", true); + equal(inp.prop("size"), 10, "Auto size - fr - dd/mm/yy"); + inp.datepicker("option", "dateFormat", "m/d/yy"); + equal(inp.prop("size"), 10, "Auto size - fr - m/d/yy"); + inp.datepicker("option", "dateFormat", "D M d yy"); + equal(inp.prop("size"), 18, "Auto size - fr - D M d yy"); + inp.datepicker("option", "dateFormat", "DD, MM dd, yy"); + equal(inp.prop("size"), 28, "Auto size - fr - DD, MM dd, yy"); // Hebrew - inp.datepicker('option', $.extend({autoSize: false}, $.datepicker.regional.he)); - equal(inp.prop('size'), 28, 'Auto size - he - default'); - inp.datepicker('option', 'autoSize', true); - equal(inp.prop('size'), 10, 'Auto size - he - dd/mm/yy'); - inp.datepicker('option', 'dateFormat', 'm/d/yy'); - equal(inp.prop('size'), 10, 'Auto size - he - m/d/yy'); - inp.datepicker('option', 'dateFormat', 'D M d yy'); - equal(inp.prop('size'), 16, 'Auto size - he - D M d yy'); - inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy'); - equal(inp.prop('size'), 23, 'Auto size - he - DD, MM dd, yy'); + inp.datepicker("option", $.extend({autoSize: false}, $.datepicker.regional.he)); + equal(inp.prop("size"), 28, "Auto size - he - default"); + inp.datepicker("option", "autoSize", true); + equal(inp.prop("size"), 10, "Auto size - he - dd/mm/yy"); + inp.datepicker("option", "dateFormat", "m/d/yy"); + equal(inp.prop("size"), 10, "Auto size - he - m/d/yy"); + inp.datepicker("option", "dateFormat", "D M d yy"); + equal(inp.prop("size"), 16, "Auto size - he - D M d yy"); + inp.datepicker("option", "dateFormat", "DD, MM dd, yy"); + equal(inp.prop("size"), 23, "Auto size - he - DD, MM dd, yy"); }); -test('daylightSaving', function() { +test("daylightSaving", function() { expect( 25 ); - var inp = TestHelpers.datepicker.init('#inp'), - dp = $('#ui-datepicker-div'); - ok(true, 'Daylight saving - ' + new Date()); + var inp = TestHelpers.datepicker.init("#inp"), + dp = $("#ui-datepicker-div"); + ok(true, "Daylight saving - " + new Date()); // Australia, Sydney - AM change, southern hemisphere - inp.val('04/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(6) a', dp).simulate('click'); - equal(inp.val(), '04/05/2008', 'Daylight saving - Australia 04/05/2008'); - inp.val('04/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(7) a', dp).simulate('click'); - equal(inp.val(), '04/06/2008', 'Daylight saving - Australia 04/06/2008'); - inp.val('04/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(8) a', dp).simulate('click'); - equal(inp.val(), '04/07/2008', 'Daylight saving - Australia 04/07/2008'); - inp.val('10/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(6) a', dp).simulate('click'); - equal(inp.val(), '10/04/2008', 'Daylight saving - Australia 10/04/2008'); - inp.val('10/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(7) a', dp).simulate('click'); - equal(inp.val(), '10/05/2008', 'Daylight saving - Australia 10/05/2008'); - inp.val('10/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(8) a', dp).simulate('click'); - equal(inp.val(), '10/06/2008', 'Daylight saving - Australia 10/06/2008'); + inp.val("04/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(6) a", dp).simulate("click"); + equal(inp.val(), "04/05/2008", "Daylight saving - Australia 04/05/2008"); + inp.val("04/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(7) a", dp).simulate("click"); + equal(inp.val(), "04/06/2008", "Daylight saving - Australia 04/06/2008"); + inp.val("04/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(8) a", dp).simulate("click"); + equal(inp.val(), "04/07/2008", "Daylight saving - Australia 04/07/2008"); + inp.val("10/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(6) a", dp).simulate("click"); + equal(inp.val(), "10/04/2008", "Daylight saving - Australia 10/04/2008"); + inp.val("10/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(7) a", dp).simulate("click"); + equal(inp.val(), "10/05/2008", "Daylight saving - Australia 10/05/2008"); + inp.val("10/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(8) a", dp).simulate("click"); + equal(inp.val(), "10/06/2008", "Daylight saving - Australia 10/06/2008"); // Brasil, Brasilia - midnight change, southern hemisphere - inp.val('02/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(20) a', dp).simulate('click'); - equal(inp.val(), '02/16/2008', 'Daylight saving - Brasil 02/16/2008'); - inp.val('02/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(21) a', dp).simulate('click'); - equal(inp.val(), '02/17/2008', 'Daylight saving - Brasil 02/17/2008'); - inp.val('02/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(22) a', dp).simulate('click'); - equal(inp.val(), '02/18/2008', 'Daylight saving - Brasil 02/18/2008'); - inp.val('10/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(13) a', dp).simulate('click'); - equal(inp.val(), '10/11/2008', 'Daylight saving - Brasil 10/11/2008'); - inp.val('10/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(14) a', dp).simulate('click'); - equal(inp.val(), '10/12/2008', 'Daylight saving - Brasil 10/12/2008'); - inp.val('10/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(15) a', dp).simulate('click'); - equal(inp.val(), '10/13/2008', 'Daylight saving - Brasil 10/13/2008'); + inp.val("02/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(20) a", dp).simulate("click"); + equal(inp.val(), "02/16/2008", "Daylight saving - Brasil 02/16/2008"); + inp.val("02/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(21) a", dp).simulate("click"); + equal(inp.val(), "02/17/2008", "Daylight saving - Brasil 02/17/2008"); + inp.val("02/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(22) a", dp).simulate("click"); + equal(inp.val(), "02/18/2008", "Daylight saving - Brasil 02/18/2008"); + inp.val("10/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(13) a", dp).simulate("click"); + equal(inp.val(), "10/11/2008", "Daylight saving - Brasil 10/11/2008"); + inp.val("10/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(14) a", dp).simulate("click"); + equal(inp.val(), "10/12/2008", "Daylight saving - Brasil 10/12/2008"); + inp.val("10/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(15) a", dp).simulate("click"); + equal(inp.val(), "10/13/2008", "Daylight saving - Brasil 10/13/2008"); // Lebanon, Beirut - midnight change, northern hemisphere - inp.val('03/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(34) a', dp).simulate('click'); - equal(inp.val(), '03/29/2008', 'Daylight saving - Lebanon 03/29/2008'); - inp.val('03/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(35) a', dp).simulate('click'); - equal(inp.val(), '03/30/2008', 'Daylight saving - Lebanon 03/30/2008'); - inp.val('03/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(36) a', dp).simulate('click'); - equal(inp.val(), '03/31/2008', 'Daylight saving - Lebanon 03/31/2008'); - inp.val('10/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(27) a', dp).simulate('click'); - equal(inp.val(), '10/25/2008', 'Daylight saving - Lebanon 10/25/2008'); - inp.val('10/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(28) a', dp).simulate('click'); - equal(inp.val(), '10/26/2008', 'Daylight saving - Lebanon 10/26/2008'); - inp.val('10/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(29) a', dp).simulate('click'); - equal(inp.val(), '10/27/2008', 'Daylight saving - Lebanon 10/27/2008'); + inp.val("03/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(34) a", dp).simulate("click"); + equal(inp.val(), "03/29/2008", "Daylight saving - Lebanon 03/29/2008"); + inp.val("03/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(35) a", dp).simulate("click"); + equal(inp.val(), "03/30/2008", "Daylight saving - Lebanon 03/30/2008"); + inp.val("03/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(36) a", dp).simulate("click"); + equal(inp.val(), "03/31/2008", "Daylight saving - Lebanon 03/31/2008"); + inp.val("10/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(27) a", dp).simulate("click"); + equal(inp.val(), "10/25/2008", "Daylight saving - Lebanon 10/25/2008"); + inp.val("10/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(28) a", dp).simulate("click"); + equal(inp.val(), "10/26/2008", "Daylight saving - Lebanon 10/26/2008"); + inp.val("10/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(29) a", dp).simulate("click"); + equal(inp.val(), "10/27/2008", "Daylight saving - Lebanon 10/27/2008"); // US, Eastern - AM change, northern hemisphere - inp.val('03/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(13) a', dp).simulate('click'); - equal(inp.val(), '03/08/2008', 'Daylight saving - US 03/08/2008'); - inp.val('03/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(14) a', dp).simulate('click'); - equal(inp.val(), '03/09/2008', 'Daylight saving - US 03/09/2008'); - inp.val('03/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(15) a', dp).simulate('click'); - equal(inp.val(), '03/10/2008', 'Daylight saving - US 03/10/2008'); - inp.val('11/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(6) a', dp).simulate('click'); - equal(inp.val(), '11/01/2008', 'Daylight saving - US 11/01/2008'); - inp.val('11/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(7) a', dp).simulate('click'); - equal(inp.val(), '11/02/2008', 'Daylight saving - US 11/02/2008'); - inp.val('11/01/2008').datepicker('show'); - $('.ui-datepicker-calendar td:eq(8) a', dp).simulate('click'); - equal(inp.val(), '11/03/2008', 'Daylight saving - US 11/03/2008'); + inp.val("03/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(13) a", dp).simulate("click"); + equal(inp.val(), "03/08/2008", "Daylight saving - US 03/08/2008"); + inp.val("03/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(14) a", dp).simulate("click"); + equal(inp.val(), "03/09/2008", "Daylight saving - US 03/09/2008"); + inp.val("03/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(15) a", dp).simulate("click"); + equal(inp.val(), "03/10/2008", "Daylight saving - US 03/10/2008"); + inp.val("11/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(6) a", dp).simulate("click"); + equal(inp.val(), "11/01/2008", "Daylight saving - US 11/01/2008"); + inp.val("11/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(7) a", dp).simulate("click"); + equal(inp.val(), "11/02/2008", "Daylight saving - US 11/02/2008"); + inp.val("11/01/2008").datepicker("show"); + $(".ui-datepicker-calendar td:eq(8) a", dp).simulate("click"); + equal(inp.val(), "11/03/2008", "Daylight saving - US 11/03/2008"); }); var beforeShowThis = null, @@ -725,245 +725,245 @@ function beforeAll(input, inst) { beforeShowThis = this; beforeShowInput = input; beforeShowInst = inst; - return {currentText: 'Current'}; + return {currentText: "Current"}; } function beforeDay(date) { beforeShowDayThis = this; beforeShowDayOK &= (date > new Date(2008, 1 - 1, 26) && date < new Date(2008, 3 - 1, 6)); - return [(date.getDate() % 2 === 0), (date.getDate() % 10 === 0 ? 'day10' : ''), - (date.getDate() % 3 === 0 ? 'Divisble by 3' : '')]; + return [(date.getDate() % 2 === 0), (date.getDate() % 10 === 0 ? "day10" : ""), + (date.getDate() % 3 === 0 ? "Divisble by 3" : "")]; } -test('callbacks', function() { +test("callbacks", function() { expect( 13 ); // Before show var dp, day20, day21, - inp = TestHelpers.datepicker.init('#inp', {beforeShow: beforeAll}), - inst = $.data(inp[0], 'datepicker'); - equal($.datepicker._get(inst, 'currentText'), 'Today', 'Before show - initial'); - inp.val('02/04/2008').datepicker('show'); - equal($.datepicker._get(inst, 'currentText'), 'Current', 'Before show - changed'); - ok(beforeShowThis.id === inp[0].id, 'Before show - this OK'); - ok(beforeShowInput.id === inp[0].id, 'Before show - input OK'); - deepEqual(beforeShowInst, inst, 'Before show - inst OK'); - inp.datepicker('hide').datepicker('destroy'); + inp = TestHelpers.datepicker.init("#inp", {beforeShow: beforeAll}), + inst = $.data(inp[0], "datepicker"); + equal($.datepicker._get(inst, "currentText"), "Today", "Before show - initial"); + inp.val("02/04/2008").datepicker("show"); + equal($.datepicker._get(inst, "currentText"), "Current", "Before show - changed"); + ok(beforeShowThis.id === inp[0].id, "Before show - this OK"); + ok(beforeShowInput.id === inp[0].id, "Before show - input OK"); + deepEqual(beforeShowInst, inst, "Before show - inst OK"); + inp.datepicker("hide").datepicker("destroy"); // Before show day - inp = TestHelpers.datepicker.init('#inp', {beforeShowDay: beforeDay}); - dp = $('#ui-datepicker-div'); - inp.val('02/04/2008').datepicker('show'); - ok(beforeShowDayThis.id === inp[0].id, 'Before show day - this OK'); - ok(beforeShowDayOK, 'Before show day - dates OK'); - day20 = dp.find('.ui-datepicker-calendar td:contains("20")'); - day21 = dp.find('.ui-datepicker-calendar td:contains("21")'); - ok(!day20.is('.ui-datepicker-unselectable'), 'Before show day - unselectable 20'); - ok(day21.is('.ui-datepicker-unselectable'), 'Before show day - unselectable 21'); - ok(day20.is('.day10'), 'Before show day - CSS 20'); - ok(!day21.is('.day10'), 'Before show day - CSS 21'); - ok(!day20.attr('title'), 'Before show day - title 20'); - ok(day21.attr('title') === 'Divisble by 3', 'Before show day - title 21'); - inp.datepicker('hide').datepicker('destroy'); + inp = TestHelpers.datepicker.init("#inp", {beforeShowDay: beforeDay}); + dp = $("#ui-datepicker-div"); + inp.val("02/04/2008").datepicker("show"); + ok(beforeShowDayThis.id === inp[0].id, "Before show day - this OK"); + ok(beforeShowDayOK, "Before show day - dates OK"); + day20 = dp.find(".ui-datepicker-calendar td:contains('20')"); + day21 = dp.find(".ui-datepicker-calendar td:contains('21')"); + ok(!day20.is(".ui-datepicker-unselectable"), "Before show day - unselectable 20"); + ok(day21.is(".ui-datepicker-unselectable"), "Before show day - unselectable 21"); + ok(day20.is(".day10"), "Before show day - CSS 20"); + ok(!day21.is(".day10"), "Before show day - CSS 21"); + ok(!day20.attr("title"), "Before show day - title 20"); + ok(day21.attr("title") === "Divisble by 3", "Before show day - title 21"); + inp.datepicker("hide").datepicker("destroy"); }); -test('localisation', function() { +test("localisation", function() { expect( 24 ); var dp, month, day, date, - inp = TestHelpers.datepicker.init('#inp', $.datepicker.regional.fr); - inp.datepicker('option', {dateFormat: 'DD, d MM yy', showButtonPanel:true, changeMonth:true, changeYear:true}).val('').datepicker('show'); - dp = $('#ui-datepicker-div'); - equal($('.ui-datepicker-close', dp).text(), 'Fermer', 'Localisation - close'); - $('.ui-datepicker-close', dp).simulate('mouseover'); - equal($('.ui-datepicker-prev', dp).text(), 'Précédent', 'Localisation - previous'); - equal($('.ui-datepicker-current', dp).text(), 'Aujourd\'hui', 'Localisation - current'); - equal($('.ui-datepicker-next', dp).text(), 'Suivant', 'Localisation - next'); + inp = TestHelpers.datepicker.init("#inp", $.datepicker.regional.fr); + inp.datepicker("option", {dateFormat: "DD, d MM yy", showButtonPanel:true, changeMonth:true, changeYear:true}).val("").datepicker("show"); + dp = $("#ui-datepicker-div"); + equal($(".ui-datepicker-close", dp).text(), "Fermer", "Localisation - close"); + $(".ui-datepicker-close", dp).simulate("mouseover"); + equal($(".ui-datepicker-prev", dp).text(), "Précédent", "Localisation - previous"); + equal($(".ui-datepicker-current", dp).text(), "Aujourd'hui", "Localisation - current"); + equal($(".ui-datepicker-next", dp).text(), "Suivant", "Localisation - next"); month = 0; - $('.ui-datepicker-month option', dp).each(function() { + $(".ui-datepicker-month option", dp).each(function() { equal($(this).text(), $.datepicker.regional.fr.monthNamesShort[month], - 'Localisation - month ' + month); + "Localisation - month " + month); month++; }); day = 1; - $('.ui-datepicker-calendar th', dp).each(function() { + $(".ui-datepicker-calendar th", dp).each(function() { equal($(this).text(), $.datepicker.regional.fr.dayNamesMin[day], - 'Localisation - day ' + day); + "Localisation - day " + day); day = (day + 1) % 7; }); - inp.simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); + inp.simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date = new Date(); - equal(inp.val(), $.datepicker.regional.fr.dayNames[date.getDay()] + ', ' + - date.getDate() + ' ' + $.datepicker.regional.fr.monthNames[date.getMonth()] + - ' ' + date.getFullYear(), 'Localisation - formatting'); + equal(inp.val(), $.datepicker.regional.fr.dayNames[date.getDay()] + ", " + + date.getDate() + " " + $.datepicker.regional.fr.monthNames[date.getMonth()] + + " " + date.getFullYear(), "Localisation - formatting"); }); -test('noWeekends', function() { +test("noWeekends", function() { expect( 31 ); var i, date; for (i = 1; i <= 31; i++) { date = new Date(2001, 1 - 1, i); - deepEqual($.datepicker.noWeekends(date), [(i + 1) % 7 >= 2, ''], - 'No weekends ' + date); + deepEqual($.datepicker.noWeekends(date), [(i + 1) % 7 >= 2, ""], + "No weekends " + date); } }); -test('iso8601Week', function() { +test("iso8601Week", function() { expect( 12 ); var date = new Date(2000, 12 - 1, 31); - equal($.datepicker.iso8601Week(date), 52, 'ISO 8601 week ' + date); + equal($.datepicker.iso8601Week(date), 52, "ISO 8601 week " + date); date = new Date(2001, 1 - 1, 1); - equal($.datepicker.iso8601Week(date), 1, 'ISO 8601 week ' + date); + equal($.datepicker.iso8601Week(date), 1, "ISO 8601 week " + date); date = new Date(2001, 1 - 1, 7); - equal($.datepicker.iso8601Week(date), 1, 'ISO 8601 week ' + date); + equal($.datepicker.iso8601Week(date), 1, "ISO 8601 week " + date); date = new Date(2001, 1 - 1, 8); - equal($.datepicker.iso8601Week(date), 2, 'ISO 8601 week ' + date); + equal($.datepicker.iso8601Week(date), 2, "ISO 8601 week " + date); date = new Date(2003, 12 - 1, 28); - equal($.datepicker.iso8601Week(date), 52, 'ISO 8601 week ' + date); + equal($.datepicker.iso8601Week(date), 52, "ISO 8601 week " + date); date = new Date(2003, 12 - 1, 29); - equal($.datepicker.iso8601Week(date), 1, 'ISO 8601 week ' + date); + equal($.datepicker.iso8601Week(date), 1, "ISO 8601 week " + date); date = new Date(2004, 1 - 1, 4); - equal($.datepicker.iso8601Week(date), 1, 'ISO 8601 week ' + date); + equal($.datepicker.iso8601Week(date), 1, "ISO 8601 week " + date); date = new Date(2004, 1 - 1, 5); - equal($.datepicker.iso8601Week(date), 2, 'ISO 8601 week ' + date); + equal($.datepicker.iso8601Week(date), 2, "ISO 8601 week " + date); date = new Date(2009, 12 - 1, 28); - equal($.datepicker.iso8601Week(date), 53, 'ISO 8601 week ' + date); + equal($.datepicker.iso8601Week(date), 53, "ISO 8601 week " + date); date = new Date(2010, 1 - 1, 3); - equal($.datepicker.iso8601Week(date), 53, 'ISO 8601 week ' + date); + equal($.datepicker.iso8601Week(date), 53, "ISO 8601 week " + date); date = new Date(2010, 1 - 1, 4); - equal($.datepicker.iso8601Week(date), 1, 'ISO 8601 week ' + date); + equal($.datepicker.iso8601Week(date), 1, "ISO 8601 week " + date); date = new Date(2010, 1 - 1, 10); - equal($.datepicker.iso8601Week(date), 1, 'ISO 8601 week ' + date); + equal($.datepicker.iso8601Week(date), 1, "ISO 8601 week " + date); }); -test('parseDate', function() { +test("parseDate", function() { expect( 26 ); - TestHelpers.datepicker.init('#inp'); + TestHelpers.datepicker.init("#inp"); var currentYear, gmtDate, fr, settings, zh; - ok($.datepicker.parseDate('d m y', '') == null, 'Parse date empty'); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('d m y', '3 2 01'), - new Date(2001, 2 - 1, 3), 'Parse date d m y'); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('dd mm yy', '03 02 2001'), - new Date(2001, 2 - 1, 3), 'Parse date dd mm yy'); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('d m y', '13 12 01'), - new Date(2001, 12 - 1, 13), 'Parse date d m y'); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('dd mm yy', '13 12 2001'), - new Date(2001, 12 - 1, 13), 'Parse date dd mm yy'); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('y-o', '01-34'), - new Date(2001, 2 - 1, 3), 'Parse date y-o'); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('yy-oo', '2001-347'), - new Date(2001, 12 - 1, 13), 'Parse date yy-oo'); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('oo yy', '348 2004'), - new Date(2004, 12 - 1, 13), 'Parse date oo yy'); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('D d M y', 'Sat 3 Feb 01'), - new Date(2001, 2 - 1, 3), 'Parse date D d M y'); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('d MM DD yy', '3 February Saturday 2001'), - new Date(2001, 2 - 1, 3), 'Parse date dd MM DD yy'); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('DD, MM d, yy', 'Saturday, February 3, 2001'), - new Date(2001, 2 - 1, 3), 'Parse date DD, MM d, yy'); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('\'day\' d \'of\' MM (\'\'DD\'\'), yy', - 'day 3 of February (\'Saturday\'), 2001'), new Date(2001, 2 - 1, 3), - 'Parse date \'day\' d \'of\' MM (\'\'DD\'\'), yy'); + ok($.datepicker.parseDate("d m y", "") == null, "Parse date empty"); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("d m y", "3 2 01"), + new Date(2001, 2 - 1, 3), "Parse date d m y"); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("dd mm yy", "03 02 2001"), + new Date(2001, 2 - 1, 3), "Parse date dd mm yy"); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("d m y", "13 12 01"), + new Date(2001, 12 - 1, 13), "Parse date d m y"); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("dd mm yy", "13 12 2001"), + new Date(2001, 12 - 1, 13), "Parse date dd mm yy"); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("y-o", "01-34"), + new Date(2001, 2 - 1, 3), "Parse date y-o"); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("yy-oo", "2001-347"), + new Date(2001, 12 - 1, 13), "Parse date yy-oo"); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("oo yy", "348 2004"), + new Date(2004, 12 - 1, 13), "Parse date oo yy"); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("D d M y", "Sat 3 Feb 01"), + new Date(2001, 2 - 1, 3), "Parse date D d M y"); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("d MM DD yy", "3 February Saturday 2001"), + new Date(2001, 2 - 1, 3), "Parse date dd MM DD yy"); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("DD, MM d, yy", "Saturday, February 3, 2001"), + new Date(2001, 2 - 1, 3), "Parse date DD, MM d, yy"); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("'day' d 'of' MM (''DD''), yy", + "day 3 of February ('Saturday'), 2001"), new Date(2001, 2 - 1, 3), + "Parse date 'day' d 'of' MM (''DD''), yy"); currentYear = new Date().getFullYear(); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000) + '-02-03'), - new Date(currentYear, 2 - 1, 3), 'Parse date y-m-d - default cutuff'); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 10) + '-02-03'), - new Date(currentYear+10, 2 - 1, 3), 'Parse date y-m-d - default cutuff'); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 11) + '-02-03'), - new Date(currentYear-89, 2 - 1, 3), 'Parse date y-m-d - default cutuff'); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('y-m-d', '80-02-03', {shortYearCutoff: 80}), - new Date(2080, 2 - 1, 3), 'Parse date y-m-d - cutoff 80'); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('y-m-d', '81-02-03', {shortYearCutoff: 80}), - new Date(1981, 2 - 1, 3), 'Parse date y-m-d - cutoff 80'); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 60) + '-02-03', {shortYearCutoff: '+60'}), - new Date(currentYear + 60, 2 - 1, 3), 'Parse date y-m-d - cutoff +60'); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 61) + '-02-03', {shortYearCutoff: '+60'}), - new Date(currentYear - 39, 2 - 1, 3), 'Parse date y-m-d - cutoff +60'); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000) + "-02-03"), + new Date(currentYear, 2 - 1, 3), "Parse date y-m-d - default cutuff"); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000 + 10) + "-02-03"), + new Date(currentYear+10, 2 - 1, 3), "Parse date y-m-d - default cutuff"); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000 + 11) + "-02-03"), + new Date(currentYear-89, 2 - 1, 3), "Parse date y-m-d - default cutuff"); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("y-m-d", "80-02-03", {shortYearCutoff: 80}), + new Date(2080, 2 - 1, 3), "Parse date y-m-d - cutoff 80"); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("y-m-d", "81-02-03", {shortYearCutoff: 80}), + new Date(1981, 2 - 1, 3), "Parse date y-m-d - cutoff 80"); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000 + 60) + "-02-03", {shortYearCutoff: "+60"}), + new Date(currentYear + 60, 2 - 1, 3), "Parse date y-m-d - cutoff +60"); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000 + 61) + "-02-03", {shortYearCutoff: "+60"}), + new Date(currentYear - 39, 2 - 1, 3), "Parse date y-m-d - cutoff +60"); gmtDate = new Date(2001, 2 - 1, 3); gmtDate.setMinutes(gmtDate.getMinutes() - gmtDate.getTimezoneOffset()); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('@', '981158400000'), gmtDate, 'Parse date @'); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('!', '631167552000000000'), gmtDate, 'Parse date !'); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("@", "981158400000"), gmtDate, "Parse date @"); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("!", "631167552000000000"), gmtDate, "Parse date !"); fr = $.datepicker.regional.fr; settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames, monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames}; - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('D d M y', 'Lun. 9 Avril 01', settings), - new Date(2001, 4 - 1, 9), 'Parse date D M y with settings'); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('d MM DD yy', '9 Avril Lundi 2001', settings), - new Date(2001, 4 - 1, 9), 'Parse date d MM DD yy with settings'); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('DD, MM d, yy', 'Lundi, Avril 9, 2001', settings), - new Date(2001, 4 - 1, 9), 'Parse date DD, MM d, yy with settings'); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("D d M y", "Lun. 9 Avril 01", settings), + new Date(2001, 4 - 1, 9), "Parse date D M y with settings"); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("d MM DD yy", "9 Avril Lundi 2001", settings), + new Date(2001, 4 - 1, 9), "Parse date d MM DD yy with settings"); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("DD, MM d, yy", "Lundi, Avril 9, 2001", settings), + new Date(2001, 4 - 1, 9), "Parse date DD, MM d, yy with settings"); TestHelpers.datepicker.equalsDate($.datepicker.parseDate("'jour' d 'de' MM (''DD''), yy", "jour 9 de Avril ('Lundi'), 2001", settings), new Date(2001, 4 - 1, 9), "Parse date 'jour' d 'de' MM (''DD''), yy with settings"); - zh = $.datepicker.regional['zh-CN']; - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('yy M d', '2011 十一月 22', zh), - new Date(2011, 11 - 1, 22), 'Parse date yy M d with zh-CN'); + zh = $.datepicker.regional["zh-CN"]; + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("yy M d", "2011 十一月 22", zh), + new Date(2011, 11 - 1, 22), "Parse date yy M d with zh-CN"); }); -test('parseDateErrors', function() { +test("parseDateErrors", function() { expect( 17 ); - TestHelpers.datepicker.init('#inp'); + TestHelpers.datepicker.init("#inp"); var fr, settings; function expectError(expr, value, error) { try { expr(); - ok(false, 'Parsed error ' + value); + ok(false, "Parsed error " + value); } catch (e) { - equal(e, error, 'Parsed error ' + value); + equal(e, error, "Parsed error " + value); } } - expectError(function() { $.datepicker.parseDate(null, 'Sat 2 01'); }, - 'Sat 2 01', 'Invalid arguments'); - expectError(function() { $.datepicker.parseDate('d m y', null); }, - 'null', 'Invalid arguments'); - expectError(function() { $.datepicker.parseDate('d m y', 'Sat 2 01'); }, - 'Sat 2 01 - d m y', 'Missing number at position 0'); - expectError(function() { $.datepicker.parseDate('dd mm yy', 'Sat 2 01'); }, - 'Sat 2 01 - dd mm yy', 'Missing number at position 0'); - expectError(function() { $.datepicker.parseDate('d m y', '3 Feb 01'); }, - '3 Feb 01 - d m y', 'Missing number at position 2'); - expectError(function() { $.datepicker.parseDate('dd mm yy', '3 Feb 01'); }, - '3 Feb 01 - dd mm yy', 'Missing number at position 2'); - expectError(function() { $.datepicker.parseDate('d m y', '3 2 AD01'); }, - '3 2 AD01 - d m y', 'Missing number at position 4'); - expectError(function() { $.datepicker.parseDate('d m yy', '3 2 AD01'); }, - '3 2 AD01 - dd mm yy', 'Missing number at position 4'); - expectError(function() { $.datepicker.parseDate('y-o', '01-D01'); }, - '2001-D01 - y-o', 'Missing number at position 3'); - expectError(function() { $.datepicker.parseDate('yy-oo', '2001-D01'); }, - '2001-D01 - yy-oo', 'Missing number at position 5'); - expectError(function() { $.datepicker.parseDate('D d M y', 'D7 3 Feb 01'); }, - 'D7 3 Feb 01 - D d M y', 'Unknown name at position 0'); - expectError(function() { $.datepicker.parseDate('D d M y', 'Sat 3 M2 01'); }, - 'Sat 3 M2 01 - D d M y', 'Unknown name at position 6'); - expectError(function() { $.datepicker.parseDate('DD, MM d, yy', 'Saturday- Feb 3, 2001'); }, - 'Saturday- Feb 3, 2001 - DD, MM d, yy', 'Unexpected literal at position 8'); - expectError(function() { $.datepicker.parseDate('\'day\' d \'of\' MM (\'\'DD\'\'), yy', - 'day 3 of February ("Saturday"), 2001'); }, - 'day 3 of Mon2 ("Day7"), 2001', 'Unexpected literal at position 19'); - expectError(function() { $.datepicker.parseDate('d m y', '29 2 01'); }, - '29 2 01 - d m y', 'Invalid date'); + expectError(function() { $.datepicker.parseDate(null, "Sat 2 01"); }, + "Sat 2 01", "Invalid arguments"); + expectError(function() { $.datepicker.parseDate("d m y", null); }, + "null", "Invalid arguments"); + expectError(function() { $.datepicker.parseDate("d m y", "Sat 2 01"); }, + "Sat 2 01 - d m y", "Missing number at position 0"); + expectError(function() { $.datepicker.parseDate("dd mm yy", "Sat 2 01"); }, + "Sat 2 01 - dd mm yy", "Missing number at position 0"); + expectError(function() { $.datepicker.parseDate("d m y", "3 Feb 01"); }, + "3 Feb 01 - d m y", "Missing number at position 2"); + expectError(function() { $.datepicker.parseDate("dd mm yy", "3 Feb 01"); }, + "3 Feb 01 - dd mm yy", "Missing number at position 2"); + expectError(function() { $.datepicker.parseDate("d m y", "3 2 AD01"); }, + "3 2 AD01 - d m y", "Missing number at position 4"); + expectError(function() { $.datepicker.parseDate("d m yy", "3 2 AD01"); }, + "3 2 AD01 - dd mm yy", "Missing number at position 4"); + expectError(function() { $.datepicker.parseDate("y-o", "01-D01"); }, + "2001-D01 - y-o", "Missing number at position 3"); + expectError(function() { $.datepicker.parseDate("yy-oo", "2001-D01"); }, + "2001-D01 - yy-oo", "Missing number at position 5"); + expectError(function() { $.datepicker.parseDate("D d M y", "D7 3 Feb 01"); }, + "D7 3 Feb 01 - D d M y", "Unknown name at position 0"); + expectError(function() { $.datepicker.parseDate("D d M y", "Sat 3 M2 01"); }, + "Sat 3 M2 01 - D d M y", "Unknown name at position 6"); + expectError(function() { $.datepicker.parseDate("DD, MM d, yy", "Saturday- Feb 3, 2001"); }, + "Saturday- Feb 3, 2001 - DD, MM d, yy", "Unexpected literal at position 8"); + expectError(function() { $.datepicker.parseDate("'day' d 'of' MM (''DD''), yy", + "day 3 of February (\"Saturday\"), 2001"); }, + "day 3 of Mon2 ('Day7'), 2001", "Unexpected literal at position 19"); + expectError(function() { $.datepicker.parseDate("d m y", "29 2 01"); }, + "29 2 01 - d m y", "Invalid date"); fr = $.datepicker.regional.fr; settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames, monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames}; - expectError(function() { $.datepicker.parseDate('D d M y', 'Mon 9 Avr 01', settings); }, - 'Mon 9 Avr 01 - D d M y', 'Unknown name at position 0'); - expectError(function() { $.datepicker.parseDate('D d M y', 'Lun. 9 Apr 01', settings); }, - 'Lun. 9 Apr 01 - D d M y', 'Unknown name at position 7'); + expectError(function() { $.datepicker.parseDate("D d M y", "Mon 9 Avr 01", settings); }, + "Mon 9 Avr 01 - D d M y", "Unknown name at position 0"); + expectError(function() { $.datepicker.parseDate("D d M y", "Lun. 9 Apr 01", settings); }, + "Lun. 9 Apr 01 - D d M y", "Unknown name at position 7"); }); -test('Ticket #7244: date parser does not fail when too many numbers are passed into the date function', function() { +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'); + date = $.datepicker.parseDate("dd/mm/yy", "18/04/19881"); ok(false, "Did not properly detect an invalid date"); }catch(e){ ok("invalid date detected"); } try { - date = $.datepicker.parseDate('dd/mm/yy', '18/04/1988 @ 2:43 pm'); + date = $.datepicker.parseDate("dd/mm/yy", "18/04/1988 @ 2:43 pm"); equal(date.getDate(), 18); equal(date.getMonth(), 3); equal(date.getFullYear(), 1988); @@ -972,87 +972,87 @@ test('Ticket #7244: date parser does not fail when too many numbers are passed i } }); -test('formatDate', function() { +test("formatDate", function() { expect( 16 ); - TestHelpers.datepicker.init('#inp'); + TestHelpers.datepicker.init("#inp"); var gmtDate, fr, settings; - equal($.datepicker.formatDate('d m y', new Date(2001, 2 - 1, 3)), - '3 2 01', 'Format date d m y'); - equal($.datepicker.formatDate('dd mm yy', new Date(2001, 2 - 1, 3)), - '03 02 2001', 'Format date dd mm yy'); - equal($.datepicker.formatDate('d m y', new Date(2001, 12 - 1, 13)), - '13 12 01', 'Format date d m y'); - equal($.datepicker.formatDate('dd mm yy', new Date(2001, 12 - 1, 13)), - '13 12 2001', 'Format date dd mm yy'); - equal($.datepicker.formatDate('yy-o', new Date(2001, 2 - 1, 3)), - '2001-34', 'Format date yy-o'); - equal($.datepicker.formatDate('yy-oo', new Date(2001, 2 - 1, 3)), - '2001-034', 'Format date yy-oo'); - equal($.datepicker.formatDate('D M y', new Date(2001, 2 - 1, 3)), - 'Sat Feb 01', 'Format date D M y'); - equal($.datepicker.formatDate('DD MM yy', new Date(2001, 2 - 1, 3)), - 'Saturday February 2001', 'Format date DD MM yy'); - equal($.datepicker.formatDate('DD, MM d, yy', new Date(2001, 2 - 1, 3)), - 'Saturday, February 3, 2001', 'Format date DD, MM d, yy'); - equal($.datepicker.formatDate('\'day\' d \'of\' MM (\'\'DD\'\'), yy', - new Date(2001, 2 - 1, 3)), 'day 3 of February (\'Saturday\'), 2001', - 'Format date \'day\' d \'of\' MM (\'\'DD\'\'), yy'); + equal($.datepicker.formatDate("d m y", new Date(2001, 2 - 1, 3)), + "3 2 01", "Format date d m y"); + equal($.datepicker.formatDate("dd mm yy", new Date(2001, 2 - 1, 3)), + "03 02 2001", "Format date dd mm yy"); + equal($.datepicker.formatDate("d m y", new Date(2001, 12 - 1, 13)), + "13 12 01", "Format date d m y"); + equal($.datepicker.formatDate("dd mm yy", new Date(2001, 12 - 1, 13)), + "13 12 2001", "Format date dd mm yy"); + equal($.datepicker.formatDate("yy-o", new Date(2001, 2 - 1, 3)), + "2001-34", "Format date yy-o"); + equal($.datepicker.formatDate("yy-oo", new Date(2001, 2 - 1, 3)), + "2001-034", "Format date yy-oo"); + equal($.datepicker.formatDate("D M y", new Date(2001, 2 - 1, 3)), + "Sat Feb 01", "Format date D M y"); + equal($.datepicker.formatDate("DD MM yy", new Date(2001, 2 - 1, 3)), + "Saturday February 2001", "Format date DD MM yy"); + equal($.datepicker.formatDate("DD, MM d, yy", new Date(2001, 2 - 1, 3)), + "Saturday, February 3, 2001", "Format date DD, MM d, yy"); + equal($.datepicker.formatDate("'day' d 'of' MM (''DD''), yy", + new Date(2001, 2 - 1, 3)), "day 3 of February ('Saturday'), 2001", + "Format date 'day' d 'of' MM ('DD'), yy"); gmtDate = new Date(2001, 2 - 1, 3); gmtDate.setMinutes(gmtDate.getMinutes() - gmtDate.getTimezoneOffset()); - equal($.datepicker.formatDate('@', gmtDate), '981158400000', 'Format date @'); - equal($.datepicker.formatDate('!', gmtDate), '631167552000000000', 'Format date !'); + equal($.datepicker.formatDate("@", gmtDate), "981158400000", "Format date @"); + equal($.datepicker.formatDate("!", gmtDate), "631167552000000000", "Format date !"); fr = $.datepicker.regional.fr; settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames, monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames}; - equal($.datepicker.formatDate('D M y', new Date(2001, 4 - 1, 9), settings), - 'Lun. Avril 01', 'Format date D M y with settings'); - equal($.datepicker.formatDate('DD MM yy', new Date(2001, 4 - 1, 9), settings), - 'Lundi Avril 2001', 'Format date DD MM yy with settings'); - equal($.datepicker.formatDate('DD, MM d, yy', new Date(2001, 4 - 1, 9), settings), - 'Lundi, Avril 9, 2001', 'Format date DD, MM d, yy with settings'); - equal($.datepicker.formatDate('\'jour\' d \'de\' MM (\'\'DD\'\'), yy', - new Date(2001, 4 - 1, 9), settings), 'jour 9 de Avril (\'Lundi\'), 2001', - 'Format date \'jour\' d \'de\' MM (\'\'DD\'\'), yy with settings'); + equal($.datepicker.formatDate("D M y", new Date(2001, 4 - 1, 9), settings), + "Lun. Avril 01", "Format date D M y with settings"); + equal($.datepicker.formatDate("DD MM yy", new Date(2001, 4 - 1, 9), settings), + "Lundi Avril 2001", "Format date DD MM yy with settings"); + equal($.datepicker.formatDate("DD, MM d, yy", new Date(2001, 4 - 1, 9), settings), + "Lundi, Avril 9, 2001", "Format date DD, MM d, yy with settings"); + equal($.datepicker.formatDate("'jour' d 'de' MM (''DD''), yy", + new Date(2001, 4 - 1, 9), settings), "jour 9 de Avril ('Lundi'), 2001", + "Format date 'jour' d 'de' MM (''DD''), yy with settings"); }); -test('Ticket 6827: formatDate day of year calculation is wrong during day lights savings time', function(){ +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 7602: Stop datepicker from appearing with beforeShow event handler', function(){ +test("Ticket 7602: Stop datepicker from appearing with beforeShow event handler", function(){ expect( 3 ); - var inp = TestHelpers.datepicker.init('#inp',{ + var inp = TestHelpers.datepicker.init("#inp",{ beforeShow: function(){ return false; } }), - dp = $('#ui-datepicker-div'); - inp.datepicker('show'); - equal(dp.css('display'), 'none',"beforeShow returns false"); - inp.datepicker('destroy'); + dp = $("#ui-datepicker-div"); + inp.datepicker("show"); + equal(dp.css("display"), "none","beforeShow returns false"); + inp.datepicker("destroy"); - inp = TestHelpers.datepicker.init('#inp',{ + inp = TestHelpers.datepicker.init("#inp",{ beforeShow: function(){ } }); - dp = $('#ui-datepicker-div'); - inp.datepicker('show'); - equal(dp.css('display'), 'block',"beforeShow returns nothing"); - inp.datepicker('hide'); - inp.datepicker('destroy'); + dp = $("#ui-datepicker-div"); + inp.datepicker("show"); + equal(dp.css("display"), "block","beforeShow returns nothing"); + inp.datepicker("hide"); + inp.datepicker("destroy"); - inp = TestHelpers.datepicker.init('#inp',{ + inp = TestHelpers.datepicker.init("#inp",{ beforeShow: function(){ return true; } }); - dp = $('#ui-datepicker-div'); - inp.datepicker('show'); - equal(dp.css('display'), 'block',"beforeShow returns true"); - inp.datepicker('hide'); - inp.datepicker('destroy'); + dp = $("#ui-datepicker-div"); + inp.datepicker("show"); + equal(dp.css("display"), "block","beforeShow returns true"); + inp.datepicker("hide"); + inp.datepicker("destroy"); }); })(jQuery); diff --git a/tests/unit/datepicker/datepicker_test_helpers.js b/tests/unit/datepicker/datepicker_test_helpers.js index 2d374f561..a9605edff 100644 --- a/tests/unit/datepicker/datepicker_test_helpers.js +++ b/tests/unit/datepicker/datepicker_test_helpers.js @@ -7,7 +7,7 @@ TestHelpers.datepicker = { }, equalsDate: function(d1, d2, message) { if (!d1 || !d2) { - ok(false, message + ' - missing date'); + ok(false, message + " - missing date"); return; } d1 = new Date(d1.getFullYear(), d1.getMonth(), d1.getDate()); @@ -15,8 +15,8 @@ TestHelpers.datepicker = { equal(d1.toString(), d2.toString(), message); }, init: function(id, options) { - $.datepicker.setDefaults($.datepicker.regional['']); - return $(id).datepicker($.extend({showAnim: ''}, options || {})); + $.datepicker.setDefaults($.datepicker.regional[""]); + return $(id).datepicker($.extend({showAnim: ""}, options || {})); }, - PROP_NAME: 'datepicker' + PROP_NAME: "datepicker" };
\ No newline at end of file diff --git a/tests/unit/dialog/dialog_common.js b/tests/unit/dialog/dialog_common.js index 57d7aa0aa..ea4c91767 100644 --- a/tests/unit/dialog/dialog_common.js +++ b/tests/unit/dialog/dialog_common.js @@ -4,11 +4,11 @@ TestHelpers.commonWidgetTests( "dialog", { autoOpen: true, buttons: [], closeOnEscape: true, - closeText: 'close', + closeText: "close", disabled: false, - dialogClass: '', + dialogClass: "", draggable: true, - height: 'auto', + height: "auto", hide: null, maxHeight: null, maxWidth: null, @@ -16,10 +16,10 @@ TestHelpers.commonWidgetTests( "dialog", { minWidth: 150, modal: false, position: { - my: 'center', - at: 'center', + my: "center", + at: "center", of: window, - collision: 'fit', + collision: "fit", using: $.ui.dialog.prototype.options.position.using }, resizable: true, diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js index 817f76ea9..b488bd112 100644 --- a/tests/unit/dialog/dialog_core.js +++ b/tests/unit/dialog/dialog_core.js @@ -10,10 +10,10 @@ test("title id", function() { expect(1); var titleId, - el = $('<div></div>').dialog(); + el = $("<div></div>").dialog(); - titleId = el.dialog('widget').find('.ui-dialog-title').attr('id'); - ok( /ui-id-\d+$/.test( titleId ), 'auto-numbered title id'); + titleId = el.dialog("widget").find(".ui-dialog-title").attr("id"); + ok( /ui-id-\d+$/.test( titleId ), "auto-numbered title id"); el.remove(); }); @@ -27,7 +27,7 @@ test( "ARIA", function() { equal( wrapper.attr( "aria-describedby" ), el.attr( "id" ), "aria-describedby added" ); el.remove(); - el = $( '<div><div aria-describedby="section2"><p id="section2">descriotion</p></div></div>' ).dialog(); + el = $("<div><div aria-describedby='section2'><p id='section2'>descriotion</p></div></div>").dialog(); strictEqual( el.dialog( "widget" ).attr( "aria-describedby" ), undefined, "no aria-describedby added, as already present in markup" ); el.remove(); }); diff --git a/tests/unit/dialog/dialog_deprecated.js b/tests/unit/dialog/dialog_deprecated.js index 918190791..57f360544 100644 --- a/tests/unit/dialog/dialog_deprecated.js +++ b/tests/unit/dialog/dialog_deprecated.js @@ -34,8 +34,8 @@ test( "position, right bottom on window", function() { test("position, offset from top left w/array", function() { expect( 2 ); - var el = $('<div></div>').dialog({ position: [10, 10] }), - dialog = el.dialog('widget'), + var el = $("<div></div>").dialog({ position: [10, 10] }), + dialog = el.dialog("widget"), offset = dialog.offset(); closeEnough(offset.left, 10 + $(window).scrollLeft(), 1); closeEnough(offset.top, 10 + $(window).scrollTop(), 1); @@ -44,8 +44,8 @@ test("position, offset from top left w/array", function() { test("position, top on window", function() { expect( 2 ); - var el = $('<div></div>').dialog({ position: "top" }), - dialog = el.dialog('widget'), + var el = $("<div></div>").dialog({ position: "top" }), + dialog = el.dialog("widget"), offset = dialog.offset(); closeEnough(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft(), 1); closeEnough(offset.top, $(window).scrollTop(), 1); @@ -54,8 +54,8 @@ test("position, top on window", function() { test("position, left on window", function() { expect( 2 ); - var el = $('<div></div>').dialog({ position: "left" }), - dialog = el.dialog('widget'), + var el = $("<div></div>").dialog({ position: "left" }), + dialog = el.dialog("widget"), offset = dialog.offset(); closeEnough(offset.left, 0, 1); closeEnough(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop(), 1); diff --git a/tests/unit/dialog/dialog_events.js b/tests/unit/dialog/dialog_events.js index 19337ad5d..254158ef4 100644 --- a/tests/unit/dialog/dialog_events.js +++ b/tests/unit/dialog/dialog_events.js @@ -12,10 +12,10 @@ test("open", function() { el.dialog({ open: function(ev, ui) { ok(el.data("ui-dialog")._isOpen, "interal _isOpen flag is set"); - ok(true, 'autoOpen: true fires open callback'); + ok(true, "autoOpen: true fires open callback"); equal(this, el[0], "context of callback"); - equal(ev.type, 'dialogopen', 'event type in callback'); - deepEqual(ui, {}, 'ui hash in callback'); + equal(ev.type, "dialogopen", "event type in callback"); + deepEqual(ui, {}, "ui hash in callback"); } }); el.remove(); @@ -24,16 +24,16 @@ test("open", function() { el.dialog({ autoOpen: false, open: function(ev, ui) { - ok(true, '.dialog("open") fires open callback'); + ok(true, ".dialog('open') fires open callback"); equal(this, el[0], "context of callback"); - equal(ev.type, 'dialogopen', 'event type in callback'); - deepEqual(ui, {}, 'ui hash in callback'); + equal(ev.type, "dialogopen", "event type in callback"); + deepEqual(ui, {}, "ui hash in callback"); } - }).bind('dialogopen', function(ev, ui) { + }).bind("dialogopen", function(ev, ui) { ok(el.data("ui-dialog")._isOpen, "interal _isOpen flag is set"); - ok(true, 'dialog("open") fires open event'); - equal(this, el[0], 'context of event'); - deepEqual(ui, {}, 'ui hash in event'); + ok(true, "dialog('open') fires open event"); + equal(this, el[0], "context of event"); + deepEqual(ui, {}, "ui hash in event"); }); el.dialog("open"); el.remove(); @@ -88,22 +88,22 @@ test("dragStart", function() { expect(9); var handle, - el = $('<div></div>').dialog({ + el = $("<div></div>").dialog({ dragStart: function(ev, ui) { - ok(true, 'dragging fires dragStart callback'); + ok(true, "dragging fires dragStart callback"); equal(this, el[0], "context of callback"); - equal(ev.type, 'dialogdragstart', 'event type in callback'); + equal(ev.type, "dialogdragstart", "event type in callback"); ok(ui.position !== undefined, "ui.position in callback"); ok(ui.offset !== undefined, "ui.offset in callback"); } - }).bind('dialogdragstart', function(ev, ui) { - ok(true, 'dragging fires dialogdragstart event'); - equal(this, el[0], 'context of event'); + }).bind("dialogdragstart", function(ev, ui) { + ok(true, "dragging fires dialogdragstart event"); + equal(this, el[0], "context of event"); ok(ui.position !== undefined, "ui.position in callback"); ok(ui.offset !== undefined, "ui.offset in callback"); }); - handle = $(".ui-dialog-titlebar", el.dialog('widget')); + handle = $(".ui-dialog-titlebar", el.dialog("widget")); TestHelpers.dialog.drag(el, handle, 50, 50); el.remove(); }); @@ -112,26 +112,26 @@ test("drag", function() { expect(9); var handle, hasDragged = false, - el = $('<div></div>').dialog({ + el = $("<div></div>").dialog({ drag: function(ev, ui) { if (!hasDragged) { - ok(true, 'dragging fires drag callback'); + ok(true, "dragging fires drag callback"); equal(this, el[0], "context of callback"); - equal(ev.type, 'dialogdrag', 'event type in callback'); + equal(ev.type, "dialogdrag", "event type in callback"); ok(ui.position !== undefined, "ui.position in callback"); ok(ui.offset !== undefined, "ui.offset in callback"); hasDragged = true; } } - }).one('dialogdrag', function(ev, ui) { - ok(true, 'dragging fires dialogdrag event'); - equal(this, el[0], 'context of event'); + }).one("dialogdrag", function(ev, ui) { + ok(true, "dragging fires dialogdrag event"); + equal(this, el[0], "context of event"); ok(ui.position !== undefined, "ui.position in callback"); ok(ui.offset !== undefined, "ui.offset in callback"); }); - handle = $(".ui-dialog-titlebar", el.dialog('widget')); + handle = $(".ui-dialog-titlebar", el.dialog("widget")); TestHelpers.dialog.drag(el, handle, 50, 50); el.remove(); }); @@ -140,22 +140,22 @@ test("dragStop", function() { expect(9); var handle, - el = $('<div></div>').dialog({ + el = $("<div></div>").dialog({ dragStop: function(ev, ui) { - ok(true, 'dragging fires dragStop callback'); + ok(true, "dragging fires dragStop callback"); equal(this, el[0], "context of callback"); - equal(ev.type, 'dialogdragstop', 'event type in callback'); + equal(ev.type, "dialogdragstop", "event type in callback"); ok(ui.position !== undefined, "ui.position in callback"); ok(ui.offset !== undefined, "ui.offset in callback"); } - }).bind('dialogdragstop', function(ev, ui) { - ok(true, 'dragging fires dialogdragstop event'); - equal(this, el[0], 'context of event'); + }).bind("dialogdragstop", function(ev, ui) { + ok(true, "dragging fires dialogdragstop event"); + equal(this, el[0], "context of event"); ok(ui.position !== undefined, "ui.position in callback"); ok(ui.offset !== undefined, "ui.offset in callback"); }); - handle = $(".ui-dialog-titlebar", el.dialog('widget')); + handle = $(".ui-dialog-titlebar", el.dialog("widget")); TestHelpers.dialog.drag(el, handle, 50, 50); el.remove(); }); @@ -164,26 +164,26 @@ test("resizeStart", function() { expect(13); var handle, - el = $('<div></div>').dialog({ + el = $("<div></div>").dialog({ resizeStart: function(ev, ui) { - ok(true, 'resizing fires resizeStart callback'); + ok(true, "resizing fires resizeStart callback"); equal(this, el[0], "context of callback"); - equal(ev.type, 'dialogresizestart', 'event type in callback'); + equal(ev.type, "dialogresizestart", "event type in callback"); ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); ok(ui.originalSize !== undefined, "ui.originalSize in callback"); ok(ui.position !== undefined, "ui.position in callback"); ok(ui.size !== undefined, "ui.size in callback"); } - }).bind('dialogresizestart', function(ev, ui) { - ok(true, 'resizing fires dialogresizestart event'); - equal(this, el[0], 'context of event'); + }).bind("dialogresizestart", function(ev, ui) { + ok(true, "resizing fires dialogresizestart event"); + equal(this, el[0], "context of event"); ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); ok(ui.originalSize !== undefined, "ui.originalSize in callback"); ok(ui.position !== undefined, "ui.position in callback"); ok(ui.size !== undefined, "ui.size in callback"); }); - handle = $(".ui-resizable-se", el.dialog('widget')); + handle = $(".ui-resizable-se", el.dialog("widget")); TestHelpers.dialog.drag(el, handle, 50, 50); el.remove(); }); @@ -192,12 +192,12 @@ test("resize", function() { expect(13); var handle, hasResized = false, - el = $('<div></div>').dialog({ + el = $("<div></div>").dialog({ resize: function(ev, ui) { if (!hasResized) { - ok(true, 'resizing fires resize callback'); + ok(true, "resizing fires resize callback"); equal(this, el[0], "context of callback"); - equal(ev.type, 'dialogresize', 'event type in callback'); + equal(ev.type, "dialogresize", "event type in callback"); ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); ok(ui.originalSize !== undefined, "ui.originalSize in callback"); ok(ui.position !== undefined, "ui.position in callback"); @@ -206,16 +206,16 @@ test("resize", function() { hasResized = true; } } - }).one('dialogresize', function(ev, ui) { - ok(true, 'resizing fires dialogresize event'); - equal(this, el[0], 'context of event'); + }).one("dialogresize", function(ev, ui) { + ok(true, "resizing fires dialogresize event"); + equal(this, el[0], "context of event"); ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); ok(ui.originalSize !== undefined, "ui.originalSize in callback"); ok(ui.position !== undefined, "ui.position in callback"); ok(ui.size !== undefined, "ui.size in callback"); }); - handle = $(".ui-resizable-se", el.dialog('widget')); + handle = $(".ui-resizable-se", el.dialog("widget")); TestHelpers.dialog.drag(el, handle, 50, 50); el.remove(); }); @@ -224,26 +224,26 @@ test("resizeStop", function() { expect(13); var handle, - el = $('<div></div>').dialog({ + el = $("<div></div>").dialog({ resizeStop: function(ev, ui) { - ok(true, 'resizing fires resizeStop callback'); + ok(true, "resizing fires resizeStop callback"); equal(this, el[0], "context of callback"); - equal(ev.type, 'dialogresizestop', 'event type in callback'); + equal(ev.type, "dialogresizestop", "event type in callback"); ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); ok(ui.originalSize !== undefined, "ui.originalSize in callback"); ok(ui.position !== undefined, "ui.position in callback"); ok(ui.size !== undefined, "ui.size in callback"); } - }).bind('dialogresizestop', function(ev, ui) { - ok(true, 'resizing fires dialogresizestop event'); - equal(this, el[0], 'context of event'); + }).bind("dialogresizestop", function(ev, ui) { + ok(true, "resizing fires dialogresizestop event"); + equal(this, el[0], "context of event"); ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); ok(ui.originalSize !== undefined, "ui.originalSize in callback"); ok(ui.position !== undefined, "ui.position in callback"); ok(ui.size !== undefined, "ui.size in callback"); }); - handle = $(".ui-resizable-se", el.dialog('widget')); + handle = $(".ui-resizable-se", el.dialog("widget")); TestHelpers.dialog.drag(el, handle, 50, 50); el.remove(); }); @@ -251,77 +251,77 @@ test("resizeStop", function() { asyncTest("close", function() { expect(14); - var el = $('<div></div>').dialog({ + var el = $("<div></div>").dialog({ close: function(ev, ui) { - ok(true, '.dialog("close") fires close callback'); + ok(true, ".dialog('close') fires close callback"); equal(this, el[0], "context of callback"); - equal(ev.type, 'dialogclose', 'event type in callback'); - deepEqual(ui, {}, 'ui hash in callback'); + equal(ev.type, "dialogclose", "event type in callback"); + deepEqual(ui, {}, "ui hash in callback"); } - }).bind('dialogclose', function(ev, ui) { - ok(true, '.dialog("close") fires dialogclose event'); - equal(this, el[0], 'context of event'); - deepEqual(ui, {}, 'ui hash in event'); + }).bind("dialogclose", function(ev, ui) { + ok(true, ".dialog('close') fires dialogclose event"); + equal(this, el[0], "context of event"); + deepEqual(ui, {}, "ui hash in event"); }); - el.dialog('close'); + el.dialog("close"); el.remove(); // Close event with an effect - el = $('<div></div>').dialog({ + el = $("<div></div>").dialog({ hide: 10, close: function(ev, ui) { - ok(true, '.dialog("close") fires close callback'); + ok(true, ".dialog('close') fires close callback"); equal(this, el[0], "context of callback"); - equal(ev.type, 'dialogclose', 'event type in callback'); - deepEqual(ui, {}, 'ui hash in callback'); + equal(ev.type, "dialogclose", "event type in callback"); + deepEqual(ui, {}, "ui hash in callback"); start(); } - }).bind('dialogclose', function(ev, ui) { - ok(true, '.dialog("close") fires dialogclose event'); - equal(this, el[0], 'context of event'); - deepEqual(ui, {}, 'ui hash in event'); + }).bind("dialogclose", function(ev, ui) { + ok(true, ".dialog('close') fires dialogclose event"); + equal(this, el[0], "context of event"); + deepEqual(ui, {}, "ui hash in event"); }); - el.dialog('close'); + el.dialog("close"); }); test("beforeClose", function() { expect(14); - var el = $('<div></div>').dialog({ + var el = $("<div></div>").dialog({ beforeClose: function(ev, ui) { - ok(true, '.dialog("close") fires beforeClose callback'); + ok(true, ".dialog('close') fires beforeClose callback"); equal(this, el[0], "context of callback"); - equal(ev.type, 'dialogbeforeclose', 'event type in callback'); - deepEqual(ui, {}, 'ui hash in callback'); + equal(ev.type, "dialogbeforeclose", "event type in callback"); + deepEqual(ui, {}, "ui hash in callback"); return false; } }); - el.dialog('close'); - ok( el.dialog("widget").is(":visible"), 'beforeClose callback should prevent dialog from closing'); + el.dialog("close"); + ok( el.dialog("widget").is(":visible"), "beforeClose callback should prevent dialog from closing"); el.remove(); - el = $('<div></div>').dialog(); - el.dialog('option', 'beforeClose', function(ev, ui) { - ok(true, '.dialog("close") fires beforeClose callback'); + el = $("<div></div>").dialog(); + el.dialog("option", "beforeClose", function(ev, ui) { + ok(true, ".dialog('close') fires beforeClose callback"); equal(this, el[0], "context of callback"); - equal(ev.type, 'dialogbeforeclose', 'event type in callback'); - deepEqual(ui, {}, 'ui hash in callback'); + equal(ev.type, "dialogbeforeclose", "event type in callback"); + deepEqual(ui, {}, "ui hash in callback"); return false; }); - el.dialog('close'); + el.dialog("close"); - ok( el.dialog("widget").is(":visible"), 'beforeClose callback should prevent dialog from closing'); + ok( el.dialog("widget").is(":visible"), "beforeClose callback should prevent dialog from closing"); el.remove(); - el = $('<div></div>').dialog().bind('dialogbeforeclose', function(ev, ui) { - ok(true, '.dialog("close") triggers dialogbeforeclose event'); + el = $("<div></div>").dialog().bind("dialogbeforeclose", function(ev, ui) { + ok(true, ".dialog('close') triggers dialogbeforeclose event"); equal(this, el[0], "context of event"); - deepEqual(ui, {}, 'ui hash in event'); + deepEqual(ui, {}, "ui hash in event"); return false; }); - el.dialog('close'); - ok( el.dialog("widget").is(":visible"), 'dialogbeforeclose event should prevent dialog from closing'); + el.dialog("close"); + ok( el.dialog("widget").is(":visible"), "dialogbeforeclose event should prevent dialog from closing"); el.remove(); }); @@ -329,14 +329,14 @@ test("beforeClose", function() { asyncTest("ensure dialog's container doesn't scroll on resize and focus", function() { expect(2); - var el = $('#dialog1').dialog(), + var el = $("#dialog1").dialog(), initialScroll = $(window).scrollTop(); - el.dialog('option', 'height', 600); + el.dialog("option", "height", 600); equal($(window).scrollTop(), initialScroll, "scroll hasn't moved after height change"); setTimeout( function(){ - $(".ui-dialog-titlebar-close").simulate('mousedown'); + $(".ui-dialog-titlebar-close").simulate("mousedown"); equal($(window).scrollTop(), initialScroll, "scroll hasn't moved after focus moved to dialog"); - el.dialog('destroy'); + el.dialog("destroy"); start(); }, 500); }); diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index 85d13d157..b4c58c31e 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -12,25 +12,25 @@ module("dialog: methods", { test("init", function() { expect(6); - $("<div></div>").appendTo('body').dialog().remove(); - ok(true, '.dialog() called on element'); + $("<div></div>").appendTo("body").dialog().remove(); + ok(true, ".dialog() called on element"); $([]).dialog().remove(); - ok(true, '.dialog() called on empty collection'); + ok(true, ".dialog() called on empty collection"); - $('<div></div>').dialog().remove(); - ok(true, '.dialog() called on disconnected DOMElement - never connected'); + $("<div></div>").dialog().remove(); + ok(true, ".dialog() called on disconnected DOMElement - never connected"); - $('<div></div>').appendTo('body').remove().dialog().remove(); - ok(true, '.dialog() called on disconnected DOMElement - removed'); + $("<div></div>").appendTo("body").remove().dialog().remove(); + ok(true, ".dialog() called on disconnected DOMElement - removed"); - var el = $('<div></div>').dialog(); + var el = $("<div></div>").dialog(); el.dialog("option", "foo"); el.remove(); - ok(true, 'arbitrary option getter after init'); + ok(true, "arbitrary option getter after init"); - $('<div></div>').dialog().dialog("option", "foo", "bar").remove(); - ok(true, 'arbitrary option setter after init'); + $("<div></div>").dialog().dialog("option", "foo", "bar").remove(); + ok(true, "arbitrary option setter after init"); }); test("destroy", function() { @@ -61,12 +61,12 @@ test("destroy", function() { test("#4980: Destroy should place element back in original DOM position", function(){ expect( 2 ); - var container = $('<div id="container"><div id="modal">Content</div></div>'), - modal = container.find('#modal'); + var container = $("<div id='container'><div id='modal'>Content</div></div>"), + modal = container.find("#modal"); modal.dialog(); - ok(!$.contains(container[0], modal[0]), 'dialog should move modal element to outside container element'); - modal.dialog('destroy'); - ok($.contains(container[0], modal[0]), 'dialog(destroy) should place element back in original DOM position'); + ok(!$.contains(container[0], modal[0]), "dialog should move modal element to outside container element"); + modal.dialog("destroy"); + ok($.contains(container[0], modal[0]), "dialog(destroy) should place element back in original DOM position"); }); test( "enable/disable disabled", function() { @@ -81,29 +81,29 @@ test("close", function() { expect( 3 ); var el, - expected = $('<div></div>').dialog(), - actual = expected.dialog('close'); - equal(actual, expected, 'close is chainable'); - - el = $('<div></div>').dialog(); - ok(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog visible before close method called'); - el.dialog('close'); - ok(el.dialog('widget').is(':hidden') && !el.dialog('widget').is(':visible'), 'dialog hidden after close method called'); + expected = $("<div></div>").dialog(), + actual = expected.dialog("close"); + equal(actual, expected, "close is chainable"); + + el = $("<div></div>").dialog(); + ok(el.dialog("widget").is(":visible") && !el.dialog("widget").is(":hidden"), "dialog visible before close method called"); + el.dialog("close"); + ok(el.dialog("widget").is(":hidden") && !el.dialog("widget").is(":visible"), "dialog hidden after close method called"); }); test("isOpen", function() { expect(4); - var el = $('<div></div>').dialog(); - equal(el.dialog('isOpen'), true, "dialog is open after init"); - el.dialog('close'); - equal(el.dialog('isOpen'), false, "dialog is closed"); + var el = $("<div></div>").dialog(); + equal(el.dialog("isOpen"), true, "dialog is open after init"); + el.dialog("close"); + equal(el.dialog("isOpen"), false, "dialog is closed"); el.remove(); - el = $('<div></div>').dialog({autoOpen: false}); - equal(el.dialog('isOpen'), false, "dialog is closed after init"); - el.dialog('open'); - equal(el.dialog('isOpen'), true, "dialog is open"); + el = $("<div></div>").dialog({autoOpen: false}); + equal(el.dialog("isOpen"), false, "dialog is closed after init"); + el.dialog("open"); + equal(el.dialog("isOpen"), true, "dialog is open"); el.remove(); }); @@ -137,49 +137,49 @@ test("moveToTop", function() { test("open", function() { expect( 3 ); var el, - expected = $('<div></div>').dialog(), - actual = expected.dialog('open'); - equal(actual, expected, 'open is chainable'); - - el = $('<div></div>').dialog({ autoOpen: false }); - ok(el.dialog('widget').is(':hidden') && !el.dialog('widget').is(':visible'), 'dialog hidden before open method called'); - el.dialog('open'); - ok(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog visible after open method called'); + expected = $("<div></div>").dialog(), + actual = expected.dialog("open"); + equal(actual, expected, "open is chainable"); + + el = $("<div></div>").dialog({ autoOpen: false }); + ok(el.dialog("widget").is(":hidden") && !el.dialog("widget").is(":visible"), "dialog hidden before open method called"); + el.dialog("open"); + ok(el.dialog("widget").is(":visible") && !el.dialog("widget").is(":hidden"), "dialog visible after open method called"); }); test("#6137: dialog('open') causes form elements to reset on IE7", function() { expect(2); - var d1 = $('<form><input type="radio" name="radio" id="a" value="a" checked="checked"></input>' + - '<input type="radio" name="radio" id="b" value="b">b</input></form>').appendTo( "body" ).dialog({autoOpen: false}); + var d1 = $("<form><input type='radio' name='radio' id='a' value='a' checked='checked'></input>" + + "<input type='radio' name='radio' id='b' value='b'>b</input></form>").appendTo( "body" ).dialog({autoOpen: false}); - d1.find('#b').prop( "checked", true ); - equal(d1.find('input:checked').val(), 'b', "checkbox b is checked"); + d1.find("#b").prop( "checked", true ); + equal(d1.find("input:checked").val(), "b", "checkbox b is checked"); - d1.dialog('open'); - equal(d1.find('input:checked').val(), 'b', "checkbox b is checked"); + d1.dialog("open"); + equal(d1.find("input:checked").val(), "b", "checkbox b is checked"); d1.remove(); }); test("#5531: dialog width should be at least minWidth on creation", function () { expect( 4 ); - var el = $('<div></div>').dialog({ + var el = $("<div></div>").dialog({ width: 200, minWidth: 300 }); - equal(el.dialog('option', 'width'), 300, "width is minWidth"); - el.dialog('option', 'width', 200); - equal(el.dialog('option', 'width'), 300, "width unchanged when set to < minWidth"); - el.dialog('option', 'width', 320); - equal(el.dialog('option', 'width'), 320, "width changed if set to > minWidth"); + equal(el.dialog("option", "width"), 300, "width is minWidth"); + el.dialog("option", "width", 200); + equal(el.dialog("option", "width"), 300, "width unchanged when set to < minWidth"); + el.dialog("option", "width", 320); + equal(el.dialog("option", "width"), 320, "width changed if set to > minWidth"); el.remove(); - el = $('<div></div>').dialog({ + el = $("<div></div>").dialog({ minWidth: 300 }); - ok(el.dialog('option', 'width') >= 300, "width is at least 300"); + ok(el.dialog("option", "width") >= 300, "width is at least 300"); el.remove(); }); diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js index dff3ffaae..a20480de6 100644 --- a/tests/unit/dialog/dialog_options.js +++ b/tests/unit/dialog/dialog_options.js @@ -49,12 +49,12 @@ test( "appendTo", function() { test("autoOpen", function() { expect(2); - var el = $('<div></div>').dialog({ autoOpen: false }); - ok( !el.dialog("widget").is(":visible"), '.dialog({ autoOpen: false })'); + var el = $("<div></div>").dialog({ autoOpen: false }); + ok( !el.dialog("widget").is(":visible"), ".dialog({ autoOpen: false })"); el.remove(); - el = $('<div></div>').dialog({ autoOpen: true }); - ok( el.dialog("widget").is(":visible"), '.dialog({ autoOpen: true })'); + el = $("<div></div>").dialog({ autoOpen: true }); + ok( el.dialog("widget").is(":visible"), ".dialog({ autoOpen: true })"); el.remove(); }); @@ -74,7 +74,7 @@ test("buttons", function() { equal(ev.target, btn[1], "event target"); } }, - el = $('<div></div>').dialog({ buttons: buttons }); + el = $("<div></div>").dialog({ buttons: buttons }); btn = el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" ); equal(btn.length, 2, "number of buttons"); @@ -85,8 +85,8 @@ test("buttons", function() { i++; }); - ok(btn.parent().hasClass('ui-dialog-buttonset'), "buttons in container"); - ok(el.parent().hasClass('ui-dialog-buttons'), "dialog wrapper adds class about having buttons"); + ok(btn.parent().hasClass("ui-dialog-buttonset"), "buttons in container"); + ok(el.parent().hasClass("ui-dialog-buttons"), "dialog wrapper adds class about having buttons"); btn.trigger("click"); @@ -98,13 +98,13 @@ test("buttons", function() { } }; - deepEqual(el.dialog("option", "buttons"), buttons, '.dialog("option", "buttons") getter'); + deepEqual(el.dialog("option", "buttons"), buttons, ".dialog('option', 'buttons') getter"); el.dialog("option", "buttons", newButtons); - deepEqual(el.dialog("option", "buttons"), newButtons, '.dialog("option", "buttons", ...) setter'); + deepEqual(el.dialog("option", "buttons"), newButtons, ".dialog('option', 'buttons', ...) setter"); btn = el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" ); equal(btn.length, 1, "number of buttons after setter"); - btn.trigger('click'); + btn.trigger("click"); i = 0; $.each(newButtons, function( key ) { @@ -116,7 +116,7 @@ test("buttons", function() { btn = el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" ); equal(btn.length, 0, "all buttons have been removed"); equal(el.find(".ui-dialog-buttonset").length, 0, "buttonset has been removed"); - equal(el.parent().hasClass('ui-dialog-buttons'), false, "dialog wrapper removes class about having buttons"); + equal(el.parent().hasClass("ui-dialog-buttons"), false, "dialog wrapper removes class about having buttons"); el.remove(); }); @@ -156,77 +156,77 @@ test("buttons - advanced", function() { test("closeOnEscape", function() { expect( 6 ); - var el = $('<div></div>').dialog({ closeOnEscape: false }); - ok(true, 'closeOnEscape: false'); - ok(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog is open before ESC'); - el.simulate('keydown', { keyCode: $.ui.keyCode.ESCAPE }) - .simulate('keypress', { keyCode: $.ui.keyCode.ESCAPE }) - .simulate('keyup', { keyCode: $.ui.keyCode.ESCAPE }); - ok(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog is open after ESC'); - - el.remove(); - - el = $('<div></div>').dialog({ closeOnEscape: true }); - ok(true, 'closeOnEscape: true'); - ok(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog is open before ESC'); - el.simulate('keydown', { keyCode: $.ui.keyCode.ESCAPE }) - .simulate('keypress', { keyCode: $.ui.keyCode.ESCAPE }) - .simulate('keyup', { keyCode: $.ui.keyCode.ESCAPE }); - ok(el.dialog('widget').is(':hidden') && !el.dialog('widget').is(':visible'), 'dialog is closed after ESC'); + var el = $("<div></div>").dialog({ closeOnEscape: false }); + ok(true, "closeOnEscape: false"); + ok(el.dialog("widget").is(":visible") && !el.dialog("widget").is(":hidden"), "dialog is open before ESC"); + el.simulate("keydown", { keyCode: $.ui.keyCode.ESCAPE }) + .simulate("keypress", { keyCode: $.ui.keyCode.ESCAPE }) + .simulate("keyup", { keyCode: $.ui.keyCode.ESCAPE }); + ok(el.dialog("widget").is(":visible") && !el.dialog("widget").is(":hidden"), "dialog is open after ESC"); + + el.remove(); + + el = $("<div></div>").dialog({ closeOnEscape: true }); + ok(true, "closeOnEscape: true"); + ok(el.dialog("widget").is(":visible") && !el.dialog("widget").is(":hidden"), "dialog is open before ESC"); + el.simulate("keydown", { keyCode: $.ui.keyCode.ESCAPE }) + .simulate("keypress", { keyCode: $.ui.keyCode.ESCAPE }) + .simulate("keyup", { keyCode: $.ui.keyCode.ESCAPE }); + ok(el.dialog("widget").is(":hidden") && !el.dialog("widget").is(":visible"), "dialog is closed after ESC"); }); test("closeText", function() { expect(3); - var el = $('<div></div>').dialog(); - equal(el.dialog('widget').find('.ui-dialog-titlebar-close span').text(), 'close', - 'default close text'); + var el = $("<div></div>").dialog(); + equal(el.dialog("widget").find(".ui-dialog-titlebar-close span").text(), "close", + "default close text"); el.remove(); - el = $('<div></div>').dialog({ closeText: "foo" }); - equal(el.dialog('widget').find('.ui-dialog-titlebar-close span').text(), 'foo', - 'closeText on init'); + el = $("<div></div>").dialog({ closeText: "foo" }); + equal(el.dialog("widget").find(".ui-dialog-titlebar-close span").text(), "foo", + "closeText on init"); el.remove(); - el = $('<div></div>').dialog().dialog('option', 'closeText', 'bar'); - equal(el.dialog('widget').find('.ui-dialog-titlebar-close span').text(), 'bar', - 'closeText via option method'); + el = $("<div></div>").dialog().dialog("option", "closeText", "bar"); + equal(el.dialog("widget").find(".ui-dialog-titlebar-close span").text(), "bar", + "closeText via option method"); el.remove(); }); test("dialogClass", function() { expect( 6 ); - var el = $('<div></div>').dialog(); - equal(el.dialog('widget').is(".foo"), false, 'dialogClass not specified. foo class added'); + var el = $("<div></div>").dialog(); + equal(el.dialog("widget").is(".foo"), false, "dialogClass not specified. foo class added"); el.remove(); - el = $('<div></div>').dialog({ dialogClass: "foo" }); - equal(el.dialog('widget').is(".foo"), true, 'dialogClass in init. foo class added'); + el = $("<div></div>").dialog({ dialogClass: "foo" }); + equal(el.dialog("widget").is(".foo"), true, "dialogClass in init. foo class added"); el.dialog( "option", "dialogClass", "foobar" ); - equal( el.dialog('widget').is(".foo"), false, "dialogClass changed, previous one was removed" ); - equal( el.dialog('widget').is(".foobar"), true, "dialogClass changed, new one was added" ); + equal( el.dialog("widget").is(".foo"), false, "dialogClass changed, previous one was removed" ); + equal( el.dialog("widget").is(".foobar"), true, "dialogClass changed, new one was added" ); el.remove(); - el = $('<div></div>').dialog({ dialogClass: "foo bar" }); - equal(el.dialog('widget').is(".foo"), true, 'dialogClass in init, two classes. foo class added'); - equal(el.dialog('widget').is(".bar"), true, 'dialogClass in init, two classes. bar class added'); + el = $("<div></div>").dialog({ dialogClass: "foo bar" }); + equal(el.dialog("widget").is(".foo"), true, "dialogClass in init, two classes. foo class added"); + equal(el.dialog("widget").is(".bar"), true, "dialogClass in init, two classes. bar class added"); el.remove(); }); test("draggable", function() { expect(4); - var el = $('<div></div>').dialog({ draggable: false }); + var el = $("<div></div>").dialog({ draggable: false }); TestHelpers.dialog.testDrag(el, 50, -50, 0, 0); - el.dialog('option', 'draggable', true); + el.dialog("option", "draggable", true); TestHelpers.dialog.testDrag(el, 50, -50, 50, -50); el.remove(); - el = $('<div></div>').dialog({ draggable: true }); + el = $("<div></div>").dialog({ draggable: true }); TestHelpers.dialog.testDrag(el, 50, -50, 50, -50); - el.dialog('option', 'draggable', false); + el.dialog("option", "draggable", false); TestHelpers.dialog.testDrag(el, 50, -50, 0, 0); el.remove(); }); @@ -234,22 +234,22 @@ test("draggable", function() { test("height", function() { expect(4); - var el = $('<div></div>').dialog(); - equal(el.dialog('widget').outerHeight(), 150, "default height"); + var el = $("<div></div>").dialog(); + equal(el.dialog("widget").outerHeight(), 150, "default height"); el.remove(); - el = $('<div></div>').dialog({ height: 237 }); - equal(el.dialog('widget').outerHeight(), 237, "explicit height"); + el = $("<div></div>").dialog({ height: 237 }); + equal(el.dialog("widget").outerHeight(), 237, "explicit height"); el.remove(); - el = $('<div></div>').dialog(); - el.dialog('option', 'height', 238); - equal(el.dialog('widget').outerHeight(), 238, "explicit height set after init"); + el = $("<div></div>").dialog(); + el.dialog("option", "height", 238); + equal(el.dialog("widget").outerHeight(), 238, "explicit height set after init"); el.remove(); - el = $('<div></div>').css("padding", "20px") + el = $("<div></div>").css("padding", "20px") .dialog({ height: 240 }); - equal(el.dialog('widget').outerHeight(), 240, "explicit height with padding"); + equal(el.dialog("widget").outerHeight(), 240, "explicit height with padding"); el.remove(); }); @@ -265,76 +265,76 @@ asyncTest( "hide, #5860 - don't leave effects wrapper behind", function() { test("maxHeight", function() { expect(3); - var el = $('<div></div>').dialog({ maxHeight: 200 }); - TestHelpers.dialog.drag(el, '.ui-resizable-s', 1000, 1000); - closeEnough(el.dialog('widget').height(), 200, 1, "maxHeight"); + var el = $("<div></div>").dialog({ maxHeight: 200 }); + TestHelpers.dialog.drag(el, ".ui-resizable-s", 1000, 1000); + closeEnough(el.dialog("widget").height(), 200, 1, "maxHeight"); el.remove(); - el = $('<div></div>').dialog({ maxHeight: 200 }); - TestHelpers.dialog.drag(el, '.ui-resizable-n', -1000, -1000); - closeEnough(el.dialog('widget').height(), 200, 1, "maxHeight"); + el = $("<div></div>").dialog({ maxHeight: 200 }); + TestHelpers.dialog.drag(el, ".ui-resizable-n", -1000, -1000); + closeEnough(el.dialog("widget").height(), 200, 1, "maxHeight"); el.remove(); - el = $('<div></div>').dialog({ maxHeight: 200 }).dialog('option', 'maxHeight', 300); - TestHelpers.dialog.drag(el, '.ui-resizable-s', 1000, 1000); - closeEnough(el.dialog('widget').height(), 300, 1, "maxHeight"); + el = $("<div></div>").dialog({ maxHeight: 200 }).dialog("option", "maxHeight", 300); + TestHelpers.dialog.drag(el, ".ui-resizable-s", 1000, 1000); + closeEnough(el.dialog("widget").height(), 300, 1, "maxHeight"); el.remove(); }); test("maxWidth", function() { expect(3); - var el = $('<div></div>').dialog({ maxWidth: 200 }); - TestHelpers.dialog.drag(el, '.ui-resizable-e', 1000, 1000); - closeEnough(el.dialog('widget').width(), 200, 1, "maxWidth"); + var el = $("<div></div>").dialog({ maxWidth: 200 }); + TestHelpers.dialog.drag(el, ".ui-resizable-e", 1000, 1000); + closeEnough(el.dialog("widget").width(), 200, 1, "maxWidth"); el.remove(); - el = $('<div></div>').dialog({ maxWidth: 200 }); - TestHelpers.dialog.drag(el, '.ui-resizable-w', -1000, -1000); - closeEnough(el.dialog('widget').width(), 200, 1, "maxWidth"); + el = $("<div></div>").dialog({ maxWidth: 200 }); + TestHelpers.dialog.drag(el, ".ui-resizable-w", -1000, -1000); + closeEnough(el.dialog("widget").width(), 200, 1, "maxWidth"); el.remove(); - el = $('<div></div>').dialog({ maxWidth: 200 }).dialog('option', 'maxWidth', 300); - TestHelpers.dialog.drag(el, '.ui-resizable-w', -1000, -1000); - closeEnough(el.dialog('widget').width(), 300, 1, "maxWidth"); + el = $("<div></div>").dialog({ maxWidth: 200 }).dialog("option", "maxWidth", 300); + TestHelpers.dialog.drag(el, ".ui-resizable-w", -1000, -1000); + closeEnough(el.dialog("widget").width(), 300, 1, "maxWidth"); el.remove(); }); test("minHeight", function() { expect(3); - var el = $('<div></div>').dialog({ minHeight: 10 }); - TestHelpers.dialog.drag(el, '.ui-resizable-s', -1000, -1000); - closeEnough(el.dialog('widget').height(), 10, 1, "minHeight"); + var el = $("<div></div>").dialog({ minHeight: 10 }); + TestHelpers.dialog.drag(el, ".ui-resizable-s", -1000, -1000); + closeEnough(el.dialog("widget").height(), 10, 1, "minHeight"); el.remove(); - el = $('<div></div>').dialog({ minHeight: 10 }); - TestHelpers.dialog.drag(el, '.ui-resizable-n', 1000, 1000); - closeEnough(el.dialog('widget').height(), 10, 1, "minHeight"); + el = $("<div></div>").dialog({ minHeight: 10 }); + TestHelpers.dialog.drag(el, ".ui-resizable-n", 1000, 1000); + closeEnough(el.dialog("widget").height(), 10, 1, "minHeight"); el.remove(); - el = $('<div></div>').dialog({ minHeight: 10 }).dialog('option', 'minHeight', 30); - TestHelpers.dialog.drag(el, '.ui-resizable-n', 1000, 1000); - closeEnough(el.dialog('widget').height(), 30, 1, "minHeight"); + el = $("<div></div>").dialog({ minHeight: 10 }).dialog("option", "minHeight", 30); + TestHelpers.dialog.drag(el, ".ui-resizable-n", 1000, 1000); + closeEnough(el.dialog("widget").height(), 30, 1, "minHeight"); el.remove(); }); test("minWidth", function() { expect(3); - var el = $('<div></div>').dialog({ minWidth: 10 }); - TestHelpers.dialog.drag(el, '.ui-resizable-e', -1000, -1000); - closeEnough(el.dialog('widget').width(), 10, 1, "minWidth"); + var el = $("<div></div>").dialog({ minWidth: 10 }); + TestHelpers.dialog.drag(el, ".ui-resizable-e", -1000, -1000); + closeEnough(el.dialog("widget").width(), 10, 1, "minWidth"); el.remove(); - el = $('<div></div>').dialog({ minWidth: 10 }); - TestHelpers.dialog.drag(el, '.ui-resizable-w', 1000, 1000); - closeEnough(el.dialog('widget').width(), 10, 1, "minWidth"); + el = $("<div></div>").dialog({ minWidth: 10 }); + TestHelpers.dialog.drag(el, ".ui-resizable-w", 1000, 1000); + closeEnough(el.dialog("widget").width(), 10, 1, "minWidth"); el.remove(); - el = $('<div></div>').dialog({ minWidth: 30 }).dialog('option', 'minWidth', 30); - TestHelpers.dialog.drag(el, '.ui-resizable-w', 1000, 1000); - closeEnough(el.dialog('widget').width(), 30, 1, "minWidth"); + el = $("<div></div>").dialog({ minWidth: 30 }).dialog("option", "minWidth", 30); + TestHelpers.dialog.drag(el, ".ui-resizable-w", 1000, 1000); + closeEnough(el.dialog("widget").width(), 30, 1, "minWidth"); el.remove(); }); @@ -378,8 +378,8 @@ test( "position, right bottom at right bottom via ui.position args", function() test( "position, at another element", function() { expect( 4 ); - var parent = $('<div></div>').css({ - position: 'absolute', + var parent = $("<div></div>").css({ + position: "absolute", top: 400, left: 600, height: 10, @@ -420,16 +420,16 @@ test( "position, at another element", function() { test("resizable", function() { expect(4); - var el = $('<div></div>').dialog(); + var el = $("<div></div>").dialog(); TestHelpers.dialog.shouldResize(el, 50, 50, "[default]"); - el.dialog('option', 'resizable', false); - TestHelpers.dialog.shouldResize(el, 0, 0, 'disabled after init'); + el.dialog("option", "resizable", false); + TestHelpers.dialog.shouldResize(el, 0, 0, "disabled after init"); el.remove(); - el = $('<div></div>').dialog({ resizable: false }); + el = $("<div></div>").dialog({ resizable: false }); TestHelpers.dialog.shouldResize(el, 0, 0, "disabled in init options"); - el.dialog('option', 'resizable', true); - TestHelpers.dialog.shouldResize(el, 50, 50, 'enabled after init'); + el.dialog("option", "resizable", true); + TestHelpers.dialog.shouldResize(el, 50, 50, "enabled after init"); el.remove(); }); @@ -437,37 +437,37 @@ test( "title", function() { expect( 11 ); function titleText() { - return el.dialog('widget').find( ".ui-dialog-title" ).html(); + return el.dialog("widget").find( ".ui-dialog-title" ).html(); } - var el = $( '<div></div>' ).dialog(); + var el = $( "<div></div>" ).dialog(); // some browsers return a non-breaking space and some return " " // so we generate a non-breaking space for comparison equal( titleText(), $( "<span> </span>" ).html(), "[default]" ); equal( el.dialog( "option", "title" ), null, "option not changed" ); el.remove(); - el = $( '<div title="foo">' ).dialog(); + el = $( "<div title='foo'>" ).dialog(); equal( titleText(), "foo", "title in element attribute" ); equal( el.dialog( "option", "title"), "foo", "option updated from attribute" ); el.remove(); - el = $( '<div></div>' ).dialog({ title: 'foo' }); + el = $( "<div></div>" ).dialog({ title: "foo" }); equal( titleText(), "foo", "title in init options" ); equal( el.dialog("option", "title"), "foo", "opiton set from options hash" ); el.remove(); - el = $( '<div title="foo">' ).dialog({ title: 'bar' }); + el = $( "<div title='foo'>" ).dialog({ title: "bar" }); equal( titleText(), "bar", "title in init options should override title in element attribute" ); equal( el.dialog("option", "title"), "bar", "opiton set from options hash" ); el.remove(); - el = $( '<div></div>' ).dialog().dialog( 'option', 'title', 'foo' ); - equal( titleText(), 'foo', 'title after init' ); + el = $( "<div></div>" ).dialog().dialog( "option", "title", "foo" ); + equal( titleText(), "foo", "title after init" ); el.remove(); // make sure attroperties are properly ignored - #5742 - .attr() might return a DOMElement - el = $( '<form><input name="title"></form>' ).dialog(); + el = $( "<form><input name='title'></form>" ).dialog(); // some browsers return a non-breaking space and some return " " // so we get the text to normalize to the actual non-breaking space equal( titleText(), $( "<span> </span>" ).html(), "[default]" ); @@ -478,34 +478,34 @@ test( "title", function() { test("width", function() { expect(3); - var el = $('<div></div>').dialog(); - closeEnough(el.dialog('widget').width(), 300, 1, "default width"); + var el = $("<div></div>").dialog(); + closeEnough(el.dialog("widget").width(), 300, 1, "default width"); el.remove(); - el = $('<div></div>').dialog({width: 437 }); - closeEnough(el.dialog('widget').width(), 437, 1, "explicit width"); - el.dialog('option', 'width', 438); - closeEnough(el.dialog('widget').width(), 438, 1, 'explicit width after init'); + el = $("<div></div>").dialog({width: 437 }); + closeEnough(el.dialog("widget").width(), 437, 1, "explicit width"); + el.dialog("option", "width", 438); + closeEnough(el.dialog("widget").width(), 438, 1, "explicit width after init"); el.remove(); }); test("#4826: setting resizable false toggles resizable on dialog", function() { expect(6); var i, - el = $('<div></div>').dialog({ resizable: false }); + el = $("<div></div>").dialog({ resizable: false }); TestHelpers.dialog.shouldResize(el, 0, 0, "[default]"); for (i=0; i<2; i++) { - el.dialog('close').dialog('open'); - TestHelpers.dialog.shouldResize(el, 0, 0, 'initialized with resizable false toggle ('+ (i+1) +')'); + el.dialog("close").dialog("open"); + TestHelpers.dialog.shouldResize(el, 0, 0, "initialized with resizable false toggle ("+ (i+1) +")"); } el.remove(); - el = $('<div></div>').dialog({ resizable: true }); + el = $("<div></div>").dialog({ resizable: true }); TestHelpers.dialog.shouldResize(el, 50, 50, "[default]"); for (i=0; i<2; i++) { - el.dialog('close').dialog('option', 'resizable', false).dialog('open'); - TestHelpers.dialog.shouldResize(el, 0, 0, 'set option resizable false toggle ('+ (i+1) +')'); + el.dialog("close").dialog("option", "resizable", false).dialog("open"); + TestHelpers.dialog.shouldResize(el, 0, 0, "set option resizable false toggle ("+ (i+1) +")"); } el.remove(); diff --git a/tests/unit/dialog/dialog_test_helpers.js b/tests/unit/dialog/dialog_test_helpers.js index e104ed63f..4ecaf0c0f 100644 --- a/tests/unit/dialog/dialog_test_helpers.js +++ b/tests/unit/dialog/dialog_test_helpers.js @@ -1,6 +1,6 @@ TestHelpers.dialog = { drag: function(el, handle, dx, dy) { - var d = el.dialog('widget'); + var d = el.dialog("widget"); //this mouseover is to work around a limitation in resizable //TODO: fix resizable so handle doesn't require mouseover in order to be used $( handle, d ).simulate("mouseover").simulate( "drag", { @@ -10,7 +10,7 @@ TestHelpers.dialog = { }, testDrag: function(el, dx, dy, expectedDX, expectedDY, msg) { var actualDX, actualDY, offsetAfter, - d = el.dialog('widget'), + d = el.dialog("widget"), handle = $(".ui-dialog-titlebar", d), offsetBefore = d.offset(); @@ -22,11 +22,11 @@ TestHelpers.dialog = { actualDX = offsetAfter.left - offsetBefore.left; actualDY = offsetAfter.top - offsetBefore.top; - ok( expectedDX - actualDX <= 1 && expectedDY - actualDY <= 1, 'dragged[' + expectedDX + ', ' + expectedDY + '] ' + msg); + ok( expectedDX - actualDX <= 1 && expectedDY - actualDY <= 1, "dragged[" + expectedDX + ", " + expectedDY + "] " + msg); }, shouldResize: function(el, dw, dh, msg) { var heightAfter, widthAfter, actual, expected, - d = el.dialog('widget'), + d = el.dialog("widget"), handle = $(".ui-resizable-se", d), heightBefore = d.height(), widthBefore = d.width(); @@ -39,6 +39,6 @@ TestHelpers.dialog = { msg = msg ? msg + "." : ""; actual = { width: widthAfter, height: heightAfter }, expected = { width: widthBefore + dw, height: heightBefore + dh }; - deepEqual(actual, expected, 'resized[' + 50 + ', ' + 50 + '] ' + msg); + deepEqual(actual, expected, "resized[" + 50 + ", " + 50 + "] " + msg); } };
\ No newline at end of file diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js index 2bfccbfa6..00d914194 100644 --- a/tests/unit/draggable/draggable_core.js +++ b/tests/unit/draggable/draggable_core.js @@ -7,20 +7,20 @@ module("draggable"); test("element types", function() { - var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form' + - ',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr' + - ',acronym,code,samp,kbd,var,img,hr' + - ',input,button,label,select,iframe').split(','); + var typeNames = ("p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form" + + ",table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr" + + ",acronym,code,samp,kbd,var,img,hr" + + ",input,button,label,select,iframe").split(","); expect( typeNames.length * 2 ); $.each(typeNames, function(i) { var offsetBefore, offsetAfter, typeName = typeNames[i], - el = $(document.createElement(typeName)).appendTo('#qunit-fixture'); + el = $(document.createElement(typeName)).appendTo("#qunit-fixture"); - (typeName === 'table' && el.append("<tr><td>content</td></tr>")); - el.draggable({ cancel: '' }); + (typeName === "table" && el.append("<tr><td>content</td></tr>")); + el.draggable({ cancel: "" }); offsetBefore = el.offset(); el.simulate( "drag", { dx: 50, @@ -50,16 +50,16 @@ test("No options, absolute", function() { test("resizable handle with complex markup (#8756 / #8757)", function() { expect( 2 ); - $('#draggable1') + $("#draggable1") .append( - $('<div>') + $("<div>") .addClass("ui-resizable-handle") .addClass("ui-resizable-w") - .append($('<div>')) + .append($("<div>")) ); - var handle = $('.ui-resizable-w div'), - target = $('#draggable1').draggable().resizable({ handles: 'all' }); + var handle = $(".ui-resizable-w div"), + target = $("#draggable1").draggable().resizable({ handles: "all" }); // todo: fix resizable so it doesn't require a mouseover handle.simulate("mouseover").simulate( "drag", { dx: -50 } ); diff --git a/tests/unit/draggable/draggable_events.js b/tests/unit/draggable/draggable_events.js index 07a53e22e..f4ab3a8ea 100644 --- a/tests/unit/draggable/draggable_events.js +++ b/tests/unit/draggable/draggable_events.js @@ -82,7 +82,7 @@ test("stopping the stop callback", function() { expect(1); var el = $("#draggable2").draggable({ - helper: 'clone', + helper: "clone", stop: function() { return false; } }); @@ -91,7 +91,7 @@ test("stopping the stop callback", function() { dy: 10 }); - ok($("#draggable2").data('ui-draggable').helper, "the clone should not be deleted if the stop callback is stopped"); + ok($("#draggable2").data("ui-draggable").helper, "the clone should not be deleted if the stop callback is stopped"); }); diff --git a/tests/unit/draggable/draggable_methods.js b/tests/unit/draggable/draggable_methods.js index 9ea353ca6..43db285ce 100644 --- a/tests/unit/draggable/draggable_methods.js +++ b/tests/unit/draggable/draggable_methods.js @@ -8,36 +8,36 @@ module("draggable: methods"); test("init", function() { expect(5); - $("<div></div>").appendTo('body').draggable().remove(); - ok(true, '.draggable() called on element'); + $("<div></div>").appendTo("body").draggable().remove(); + ok(true, ".draggable() called on element"); $([]).draggable(); - ok(true, '.draggable() called on empty collection'); + ok(true, ".draggable() called on empty collection"); $("<div></div>").draggable(); - ok(true, '.draggable() called on disconnected DOMElement'); + ok(true, ".draggable() called on disconnected DOMElement"); $("<div></div>").draggable().draggable("option", "foo"); - ok(true, 'arbitrary option getter after init'); + ok(true, "arbitrary option getter after init"); $("<div></div>").draggable().draggable("option", "foo", "bar"); - ok(true, 'arbitrary option setter after init'); + ok(true, "arbitrary option setter after init"); }); test("destroy", function() { expect(4); - $("<div></div>").appendTo('body').draggable().draggable("destroy").remove(); - ok(true, '.draggable("destroy") called on element'); + $("<div></div>").appendTo("body").draggable().draggable("destroy").remove(); + ok(true, ".draggable('destroy') called on element"); $([]).draggable().draggable("destroy"); - ok(true, '.draggable("destroy") called on empty collection'); + ok(true, ".draggable('destroy') called on empty collection"); $("<div></div>").draggable().draggable("destroy"); - ok(true, '.draggable("destroy") called on disconnected DOMElement'); + ok(true, ".draggable('destroy') called on disconnected DOMElement"); - var expected = $('<div></div>').draggable(), - actual = expected.draggable('destroy'); - equal(actual, expected, 'destroy is chainable'); + var expected = $("<div></div>").draggable(), + actual = expected.draggable("destroy"); + equal(actual, expected, "destroy is chainable"); }); test("enable", function() { @@ -46,23 +46,23 @@ test("enable", function() { var expected, actual, el; el = $("#draggable2").draggable({ disabled: true }); - TestHelpers.draggable.shouldNotMove(el, '.draggable({ disabled: true })'); + TestHelpers.draggable.shouldNotMove(el, ".draggable({ disabled: true })"); el.draggable("enable"); - TestHelpers.draggable.shouldMove(el, '.draggable("enable")'); + TestHelpers.draggable.shouldMove(el, ".draggable('enable')"); equal(el.draggable("option", "disabled"), false, "disabled option getter"); el.draggable("destroy"); el.draggable({ disabled: true }); - TestHelpers.draggable.shouldNotMove(el, '.draggable({ disabled: true })'); + TestHelpers.draggable.shouldNotMove(el, ".draggable({ disabled: true })"); el.draggable("option", "disabled", false); equal(el.draggable("option", "disabled"), false, "disabled option setter"); - TestHelpers.draggable.shouldMove(el, '.draggable("option", "disabled", false)'); + TestHelpers.draggable.shouldMove(el, ".draggable('option', 'disabled', false)"); - expected = $('<div></div>').draggable(), - actual = expected.draggable('enable'); - equal(actual, expected, 'enable is chainable'); + expected = $("<div></div>").draggable(), + actual = expected.draggable("enable"); + equal(actual, expected, "enable is chainable"); }); test("disable", function() { @@ -71,24 +71,24 @@ test("disable", function() { var expected, actual, el; el = $("#draggable2").draggable({ disabled: false }); - TestHelpers.draggable.shouldMove(el, '.draggable({ disabled: false })'); + TestHelpers.draggable.shouldMove(el, ".draggable({ disabled: false })"); el.draggable("disable"); - TestHelpers.draggable.shouldNotMove(el, '.draggable("disable")'); + TestHelpers.draggable.shouldNotMove(el, ".draggable('disable')"); equal(el.draggable("option", "disabled"), true, "disabled option getter"); el.draggable("destroy"); el.draggable({ disabled: false }); - TestHelpers.draggable.shouldMove(el, '.draggable({ disabled: false })'); + TestHelpers.draggable.shouldMove(el, ".draggable({ disabled: false })"); el.draggable("option", "disabled", true); equal(el.draggable("option", "disabled"), true, "disabled option setter"); - TestHelpers.draggable.shouldNotMove(el, '.draggable("option", "disabled", true)'); + TestHelpers.draggable.shouldNotMove(el, ".draggable('option', 'disabled', true)"); - expected = $('<div></div>').draggable(), - actual = expected.draggable('disable'); - equal(actual, expected, 'disable is chainable'); + expected = $("<div></div>").draggable(), + actual = expected.draggable("disable"); + equal(actual, expected, "disable is chainable"); }); })(jQuery); diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index 71a0d2f84..46280ca17 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -23,10 +23,10 @@ test("{ addClasses: false }", function() { test("{ appendTo: 'parent' }, default", function() { expect( 2 ); - var el = $("#draggable2").draggable({ appendTo: 'parent' }); + var el = $("#draggable2").draggable({ appendTo: "parent" }); TestHelpers.draggable.shouldMove(el); - el = $("#draggable1").draggable({ appendTo: 'parent' }); + el = $("#draggable1").draggable({ appendTo: "parent" }); TestHelpers.draggable.shouldMove(el); }); @@ -90,7 +90,7 @@ test("{ axis: ? }, unexpected", function() { test("{ cancel: 'input,textarea,button,select,option' }, default", function() { expect( 2 ); - $('<div id="draggable-option-cancel-default"><input type="text"></div>').appendTo('#main'); + $("<div id='draggable-option-cancel-default'><input type='text'></div>").appendTo("#main"); var el = $("#draggable-option-cancel-default").draggable({ cancel: "input,textarea,button,select,option" }); TestHelpers.draggable.shouldMove(el); @@ -110,7 +110,7 @@ test("{ cancel: 'span' }", function() { el.draggable("destroy"); - el = $("#draggable2").draggable({ cancel: 'span' }); + el = $("#draggable2").draggable({ cancel: "span" }); TestHelpers.draggable.testDrag(el, "#draggable2 span", 50, 50, 0, 0); }); @@ -123,7 +123,7 @@ test("{ cancel: ? }, unexpected", function() { "[]": [], "null": null, "undefined": undefined, - "function() {return '';}": function() {return '';}, + "function() {return '';}": function() {return "";}, "function() {return true;}": function() {return true;}, "function() {return false;}": function() {return false;} }; @@ -141,13 +141,13 @@ test("{ cancel: ? }, unexpected", function() { test("{ containment: false }, default", function() { expect( 1 ); - ok(false, 'missing test - untested code is broken code'); + ok(false, "missing test - untested code is broken code"); }); test("{ containment: Element }", function() { expect( 1 ); - ok(false, 'missing test - untested code is broken code'); + ok(false, "missing test - untested code is broken code"); }); */ @@ -155,12 +155,12 @@ test("{ containment: 'parent' }, relative", function() { expect( 1 ); var offsetAfter, - el = $("#draggable1").draggable({ containment: 'parent' }), + el = $("#draggable1").draggable({ containment: "parent" }), p = el.parent(), po = p.offset(), expected = { - left: po.left + TestHelpers.draggable.border(p, 'left') + TestHelpers.draggable.margin(el, 'left'), - top: po.top + TestHelpers.draggable.border(p, 'top') + TestHelpers.draggable.margin(el, 'top') + left: po.left + TestHelpers.draggable.border(p, "left") + TestHelpers.draggable.margin(el, "left"), + top: po.top + TestHelpers.draggable.border(p, "top") + TestHelpers.draggable.margin(el, "top") }; el.simulate( "drag", { @@ -168,19 +168,19 @@ test("{ containment: 'parent' }, relative", function() { dy: -100 }); offsetAfter = el.offset(); - deepEqual(offsetAfter, expected, 'compare offset to parent'); + deepEqual(offsetAfter, expected, "compare offset to parent"); }); test("{ containment: 'parent' }, absolute", function() { expect( 1 ); var offsetAfter, - el = $("#draggable2").draggable({ containment: 'parent' }), + el = $("#draggable2").draggable({ containment: "parent" }), p = el.parent(), po = p.offset(), expected = { - left: po.left + TestHelpers.draggable.border(p, 'left') + TestHelpers.draggable.margin(el, 'left'), - top: po.top + TestHelpers.draggable.border(p, 'top') + TestHelpers.draggable.margin(el, 'top') + left: po.left + TestHelpers.draggable.border(p, "left") + TestHelpers.draggable.margin(el, "left"), + top: po.top + TestHelpers.draggable.border(p, "top") + TestHelpers.draggable.margin(el, "top") }; el.simulate( "drag", { @@ -188,32 +188,32 @@ test("{ containment: 'parent' }, absolute", function() { dy: -100 }); offsetAfter = el.offset(); - deepEqual(offsetAfter, expected, 'compare offset to parent'); + deepEqual(offsetAfter, expected, "compare offset to parent"); }); /* test("{ containment: 'document' }", function() { expect( 1 ); - ok(false, 'missing test - untested code is broken code'); + ok(false, "missing test - untested code is broken code"); }); test("{ containment: 'window' }", function() { expect( 1 ); - ok(false, 'missing test - untested code is broken code'); + ok(false, "missing test - untested code is broken code"); }); test("{ containment: Selector }", function() { expect( 1 ); - ok(false, 'missing test - untested code is broken code'); + ok(false, "missing test - untested code is broken code"); }); test("{ containment: [x1, y1, x2, y2] }", function() { expect( 1 ); - ok(false, 'missing test - untested code is broken code'); + ok(false, "missing test - untested code is broken code"); }); */ @@ -274,7 +274,7 @@ test("{ cursor: 'move' }", function() { test("{ cursorAt: false}, default", function() { expect( 1 ); - ok(false, 'missing test - untested code is broken code'); + ok(false, "missing test - untested code is broken code"); }); */ @@ -318,11 +318,11 @@ test("{ distance: 10 }", function() { expect( 3 ); var el = $("#draggable2").draggable({ distance: 10 }); - TestHelpers.draggable.testDrag(el, el, -9, -9, 0, 0, 'distance not met'); + TestHelpers.draggable.testDrag(el, el, -9, -9, 0, 0, "distance not met"); - TestHelpers.draggable.testDrag(el, el, -10, -10, -10, -10, 'distance met'); + TestHelpers.draggable.testDrag(el, el, -10, -10, -10, -10, "distance met"); - TestHelpers.draggable.testDrag(el, el, 9, 9, 0, 0, 'distance not met'); + TestHelpers.draggable.testDrag(el, el, 9, 9, 0, 0, "distance not met"); }); @@ -345,7 +345,7 @@ test("{ grid: [50, 50] }, absolute", function() { test("{ handle: 'span' }", function() { expect( 2 ); - var el = $("#draggable2").draggable({ handle: 'span' }); + var el = $("#draggable2").draggable({ handle: "span" }); TestHelpers.draggable.testDrag(el, "#draggable2 span", 50, 50, 50, 50, "drag span"); TestHelpers.draggable.shouldNotMove(el, "drag element"); @@ -371,13 +371,13 @@ test("{ helper: 'original' }, relative, with scroll offset on parent", function( var el = $("#draggable1").draggable({ helper: "original" }); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, 'relative'); + TestHelpers.draggable.testScroll(el, "relative"); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, 'static'); + TestHelpers.draggable.testScroll(el, "static"); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, 'absolute'); + TestHelpers.draggable.testScroll(el, "absolute"); TestHelpers.draggable.restoreScroll(); @@ -388,16 +388,16 @@ test("{ helper: 'original' }, relative, with scroll offset on root", function() var el = $("#draggable1").draggable({ helper: "original" }); - TestHelpers.draggable.setScroll('root'); - TestHelpers.draggable.testScroll(el, 'relative'); + TestHelpers.draggable.setScroll("root"); + TestHelpers.draggable.testScroll(el, "relative"); - TestHelpers.draggable.setScroll('root'); - TestHelpers.draggable.testScroll(el, 'static'); + TestHelpers.draggable.setScroll("root"); + TestHelpers.draggable.testScroll(el, "static"); - TestHelpers.draggable.setScroll('root'); - TestHelpers.draggable.testScroll(el, 'absolute'); + TestHelpers.draggable.setScroll("root"); + TestHelpers.draggable.testScroll(el, "absolute"); - TestHelpers.draggable.restoreScroll('root'); + TestHelpers.draggable.restoreScroll("root"); }); @@ -408,19 +408,19 @@ test("{ helper: 'original' }, relative, with scroll offset on root and parent", var el = $("#draggable1").draggable({ helper: "original" }); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll('root'); - TestHelpers.draggable.testScroll(el, 'relative'); + TestHelpers.draggable.setScroll("root"); + TestHelpers.draggable.testScroll(el, "relative"); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll('root'); - TestHelpers.draggable.testScroll(el, 'static'); + TestHelpers.draggable.setScroll("root"); + TestHelpers.draggable.testScroll(el, "static"); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll('root'); - TestHelpers.draggable.testScroll(el, 'absolute'); + TestHelpers.draggable.setScroll("root"); + TestHelpers.draggable.testScroll(el, "absolute"); TestHelpers.draggable.restoreScroll(); - TestHelpers.draggable.restoreScroll('root'); + TestHelpers.draggable.restoreScroll("root"); }); @@ -428,16 +428,16 @@ test("{ helper: 'original' }, absolute, with scroll offset on parent", function( expect(3); - var el = $("#draggable1").css({ position: 'absolute', top: 0, left: 0 }).draggable({ helper: "original" }); + var el = $("#draggable1").css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" }); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, 'relative'); + TestHelpers.draggable.testScroll(el, "relative"); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, 'static'); + TestHelpers.draggable.testScroll(el, "static"); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, 'absolute'); + TestHelpers.draggable.testScroll(el, "absolute"); TestHelpers.draggable.restoreScroll(); @@ -447,18 +447,18 @@ test("{ helper: 'original' }, absolute, with scroll offset on root", function() expect(3); - var el = $("#draggable1").css({ position: 'absolute', top: 0, left: 0 }).draggable({ helper: "original" }); + var el = $("#draggable1").css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" }); - TestHelpers.draggable.setScroll('root'); - TestHelpers.draggable.testScroll(el, 'relative'); + TestHelpers.draggable.setScroll("root"); + TestHelpers.draggable.testScroll(el, "relative"); - TestHelpers.draggable.setScroll('root'); - TestHelpers.draggable.testScroll(el, 'static'); + TestHelpers.draggable.setScroll("root"); + TestHelpers.draggable.testScroll(el, "static"); - TestHelpers.draggable.setScroll('root'); - TestHelpers.draggable.testScroll(el, 'absolute'); + TestHelpers.draggable.setScroll("root"); + TestHelpers.draggable.testScroll(el, "absolute"); - TestHelpers.draggable.restoreScroll('root'); + TestHelpers.draggable.restoreScroll("root"); }); @@ -466,22 +466,22 @@ test("{ helper: 'original' }, absolute, with scroll offset on root and parent", expect(3); - var el = $("#draggable1").css({ position: 'absolute', top: 0, left: 0 }).draggable({ helper: "original" }); + var el = $("#draggable1").css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" }); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll('root'); - TestHelpers.draggable.testScroll(el, 'relative'); + TestHelpers.draggable.setScroll("root"); + TestHelpers.draggable.testScroll(el, "relative"); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll('root'); - TestHelpers.draggable.testScroll(el, 'static'); + TestHelpers.draggable.setScroll("root"); + TestHelpers.draggable.testScroll(el, "static"); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll('root'); - TestHelpers.draggable.testScroll(el, 'absolute'); + TestHelpers.draggable.setScroll("root"); + TestHelpers.draggable.testScroll(el, "absolute"); TestHelpers.draggable.restoreScroll(); - TestHelpers.draggable.restoreScroll('root'); + TestHelpers.draggable.restoreScroll("root"); }); @@ -489,16 +489,16 @@ test("{ helper: 'original' }, fixed, with scroll offset on parent", function() { expect(3); - var el = $("#draggable1").css({ position: 'fixed', top: 0, left: 0 }).draggable({ helper: "original" }); + var el = $("#draggable1").css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" }); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, 'relative'); + TestHelpers.draggable.testScroll(el, "relative"); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, 'static'); + TestHelpers.draggable.testScroll(el, "static"); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, 'absolute'); + TestHelpers.draggable.testScroll(el, "absolute"); TestHelpers.draggable.restoreScroll(); @@ -508,40 +508,40 @@ test("{ helper: 'original' }, fixed, with scroll offset on root", function() { expect(3); - var el = $("#draggable1").css({ position: 'fixed', top: 0, left: 0 }).draggable({ helper: "original" }); + var el = $("#draggable1").css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" }); - TestHelpers.draggable.setScroll('root'); - TestHelpers.draggable.testScroll(el, 'relative'); + TestHelpers.draggable.setScroll("root"); + TestHelpers.draggable.testScroll(el, "relative"); - TestHelpers.draggable.setScroll('root'); - TestHelpers.draggable.testScroll(el, 'static'); + TestHelpers.draggable.setScroll("root"); + TestHelpers.draggable.testScroll(el, "static"); - TestHelpers.draggable.setScroll('root'); - TestHelpers.draggable.testScroll(el, 'absolute'); + TestHelpers.draggable.setScroll("root"); + TestHelpers.draggable.testScroll(el, "absolute"); - TestHelpers.draggable.restoreScroll('root'); + TestHelpers.draggable.restoreScroll("root"); }); test("{ helper: 'original' }, fixed, with scroll offset on root and parent", function() { expect(3); - var el = $("#draggable1").css({ position: 'fixed', top: 0, left: 0 }).draggable({ helper: "original" }); + var el = $("#draggable1").css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" }); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll('root'); - TestHelpers.draggable.testScroll(el, 'relative'); + TestHelpers.draggable.setScroll("root"); + TestHelpers.draggable.testScroll(el, "relative"); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll('root'); - TestHelpers.draggable.testScroll(el, 'static'); + TestHelpers.draggable.setScroll("root"); + TestHelpers.draggable.testScroll(el, "static"); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll('root'); - TestHelpers.draggable.testScroll(el, 'absolute'); + TestHelpers.draggable.setScroll("root"); + TestHelpers.draggable.testScroll(el, "absolute"); TestHelpers.draggable.restoreScroll(); - TestHelpers.draggable.restoreScroll('root'); + TestHelpers.draggable.restoreScroll("root"); }); @@ -559,7 +559,7 @@ test("{ helper: 'clone' }, absolute", function() { dx: 1, dy: 1 }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); + deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); }); @@ -574,29 +574,29 @@ test("{ helper: 'clone' }, absolute with scroll offset on parent", function() { helperOffset = ui.helper.offset(); } }); - $("#main").css('position', 'relative'); + $("#main").css("position", "relative"); origOffset = $("#draggable1").offset(); el.simulate( "drag", { dx: 1, dy: 1 }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); + deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - $("#main").css('position', 'static'); + $("#main").css("position", "static"); origOffset = $("#draggable1").offset(); el.simulate( "drag", { dx: 1, dy: 1 }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); + deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - $("#main").css('position', 'absolute'); + $("#main").css("position", "absolute"); origOffset = $("#draggable1").offset(); el.simulate( "drag", { dx: 1, dy: 1 }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); + deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); TestHelpers.draggable.restoreScroll(); @@ -606,38 +606,38 @@ test("{ helper: 'clone' }, absolute with scroll offset on root", function() { expect(3); - TestHelpers.draggable.setScroll('root'); + TestHelpers.draggable.setScroll("root"); var helperOffset = null, origOffset = null, el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) { helperOffset = ui.helper.offset(); } }); - $("#main").css('position', 'relative'); + $("#main").css("position", "relative"); origOffset = $("#draggable1").offset(); el.simulate( "drag", { dx: 1, dy: 1 }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); + deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - $("#main").css('position', 'static'); + $("#main").css("position", "static"); origOffset = $("#draggable1").offset(); el.simulate( "drag", { dx: 1, dy: 1 }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); + deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - $("#main").css('position', 'absolute'); + $("#main").css("position", "absolute"); origOffset = $("#draggable1").offset(); el.simulate( "drag", { dx: 1, dy: 1 }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); + deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - TestHelpers.draggable.restoreScroll('root'); + TestHelpers.draggable.restoreScroll("root"); }); @@ -645,7 +645,7 @@ test("{ helper: 'clone' }, absolute with scroll offset on root and parent", func expect(3); - TestHelpers.draggable.setScroll('root'); + TestHelpers.draggable.setScroll("root"); TestHelpers.draggable.setScroll(); var helperOffset = null, @@ -654,31 +654,31 @@ test("{ helper: 'clone' }, absolute with scroll offset on root and parent", func helperOffset = ui.helper.offset(); } }); - $("#main").css('position', 'relative'); + $("#main").css("position", "relative"); origOffset = $("#draggable1").offset(); el.simulate( "drag", { dx: 1, dy: 1 }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); + deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - $("#main").css('position', 'static'); + $("#main").css("position", "static"); origOffset = $("#draggable1").offset(); el.simulate( "drag", { dx: 1, dy: 1 }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); + deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - $("#main").css('position', 'absolute'); + $("#main").css("position", "absolute"); origOffset = $("#draggable1").offset(); el.simulate( "drag", { dx: 1, dy: 1 }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); + deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - TestHelpers.draggable.restoreScroll('root'); + TestHelpers.draggable.restoreScroll("root"); TestHelpers.draggable.restoreScroll(); }); diff --git a/tests/unit/draggable/draggable_test_helpers.js b/tests/unit/draggable/draggable_test_helpers.js index 9a6355b2e..c1ac0ab88 100644 --- a/tests/unit/draggable/draggable_test_helpers.js +++ b/tests/unit/draggable/draggable_test_helpers.js @@ -15,7 +15,7 @@ TestHelpers.draggable = { expected = { left: offsetBefore.left + expectedDX, top: offsetBefore.top + expectedDY }; msg = msg ? msg + "." : ""; - deepEqual(actual, expected, 'dragged[' + dx + ', ' + dy + '] ' + msg); + deepEqual(actual, expected, "dragged[" + dx + ", " + dy + "] " + msg); }, shouldMove: function(el, why) { TestHelpers.draggable.testDrag(el, el, 50, 50, 50, 50, why); @@ -24,10 +24,10 @@ TestHelpers.draggable = { TestHelpers.draggable.testDrag(el, el, 50, 50, 0, 0, why); }, testScroll: function(el, position ) { - var oldPosition = $("#main").css('position'); - $("#main").css('position', position); - TestHelpers.draggable.shouldMove(el, position+' parent'); - $("#main").css('position', oldPosition); + var oldPosition = $("#main").css("position"); + $("#main").css("position", position); + TestHelpers.draggable.shouldMove(el, position+" parent"); + $("#main").css("position", oldPosition); }, restoreScroll: function( what ) { if( what ) { @@ -46,9 +46,9 @@ TestHelpers.draggable = { } }, border: function(el, side) { - return parseInt(el.css('border-' + side + '-width'), 10) || 0; + return parseInt(el.css("border-" + side + "-width"), 10) || 0; }, margin: function(el, side) { - return parseInt(el.css('margin-' + side), 10) || 0; + return parseInt(el.css("margin-" + side), 10) || 0; } };
\ No newline at end of file diff --git a/tests/unit/droppable/droppable_core.js b/tests/unit/droppable/droppable_core.js index c98850a03..53b08fd85 100644 --- a/tests/unit/droppable/droppable_core.js +++ b/tests/unit/droppable/droppable_core.js @@ -7,18 +7,18 @@ module("droppable: core"); test("element types", function() { - var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form' + - ',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr' + - ',acronym,code,samp,kbd,var,img,hr' + - ',input,button,label,select,iframe').split(','); + var typeNames = ("p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form" + + ",table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr" + + ",acronym,code,samp,kbd,var,img,hr" + + ",input,button,label,select,iframe").split(","); expect( typeNames.length ); $.each(typeNames, function(i) { var typeName = typeNames[i], - el = $(document.createElement(typeName)).appendTo('body'); + el = $(document.createElement(typeName)).appendTo("body"); - (typeName === 'table' && el.append("<tr><td>content</td></tr>")); + (typeName === "table" && el.append("<tr><td>content</td></tr>")); el.droppable(); TestHelpers.droppable.shouldDrop(); el.droppable("destroy"); diff --git a/tests/unit/droppable/droppable_methods.js b/tests/unit/droppable/droppable_methods.js index 76501c5b1..2b452a63d 100644 --- a/tests/unit/droppable/droppable_methods.js +++ b/tests/unit/droppable/droppable_methods.js @@ -8,37 +8,37 @@ module("droppable: methods"); test("init", function() { expect( 5 ); - $("<div></div>").appendTo('body').droppable().remove(); - ok(true, '.droppable() called on element'); + $("<div></div>").appendTo("body").droppable().remove(); + ok(true, ".droppable() called on element"); $([]).droppable(); - ok(true, '.droppable() called on empty collection'); + ok(true, ".droppable() called on empty collection"); $("<div></div>").droppable(); - ok(true, '.droppable() called on disconnected DOMElement'); + ok(true, ".droppable() called on disconnected DOMElement"); $("<div></div>").droppable().droppable("option", "foo"); - ok(true, 'arbitrary option getter after init'); + ok(true, "arbitrary option getter after init"); $("<div></div>").droppable().droppable("option", "foo", "bar"); - ok(true, 'arbitrary option setter after init'); + ok(true, "arbitrary option setter after init"); }); test("destroy", function() { expect( 4 ); - $("<div></div>").appendTo('body').droppable().droppable("destroy").remove(); - ok(true, '.droppable("destroy") called on element'); + $("<div></div>").appendTo("body").droppable().droppable("destroy").remove(); + ok(true, ".droppable('destroy') called on element"); $([]).droppable().droppable("destroy"); - ok(true, '.droppable("destroy") called on empty collection'); + ok(true, ".droppable('destroy') called on empty collection"); $("<div></div>").droppable().droppable("destroy"); - ok(true, '.droppable("destroy") called on disconnected DOMElement'); + ok(true, ".droppable('destroy') called on disconnected DOMElement"); - var expected = $('<div></div>').droppable(), - actual = expected.droppable('destroy'); - equal(actual, expected, 'destroy is chainable'); + var expected = $("<div></div>").droppable(), + actual = expected.droppable("destroy"); + equal(actual, expected, "destroy is chainable"); }); test("enable", function() { @@ -58,9 +58,9 @@ test("enable", function() { equal(el.droppable("option", "disabled"), false, "disabled option setter"); TestHelpers.droppable.shouldDrop(); - expected = $('<div></div>').droppable(), - actual = expected.droppable('enable'); - equal(actual, expected, 'enable is chainable'); + expected = $("<div></div>").droppable(), + actual = expected.droppable("enable"); + equal(actual, expected, "enable is chainable"); }); test("disable", function() { @@ -80,9 +80,9 @@ test("disable", function() { equal(el.droppable("option", "disabled"), true, "disabled option setter"); TestHelpers.droppable.shouldNotDrop(); - expected = $('<div></div>').droppable(), - actual = expected.droppable('disable'); - equal(actual, expected, 'disable is chainable'); + expected = $("<div></div>").droppable(), + actual = expected.droppable("disable"); + equal(actual, expected, "disable is chainable"); }); })(jQuery); diff --git a/tests/unit/droppable/droppable_test_helpers.js b/tests/unit/droppable/droppable_test_helpers.js index 79311788c..ffd374529 100644 --- a/tests/unit/droppable/droppable_test_helpers.js +++ b/tests/unit/droppable/droppable_test_helpers.js @@ -1,10 +1,10 @@ TestHelpers.droppable = { shouldDrop: function() { // todo: actually implement this - ok(true, 'missing test - untested code is broken code'); + ok(true, "missing test - untested code is broken code"); }, shouldNotDrop: function() { // todo: actually implement this - ok(true, 'missing test - untested code is broken code'); + ok(true, "missing test - untested code is broken code"); } };
\ No newline at end of file diff --git a/tests/unit/qunit-composite.js b/tests/unit/qunit-composite.js index 89c47eb29..b3df04217 100644 --- a/tests/unit/qunit-composite.js +++ b/tests/unit/qunit-composite.js @@ -96,7 +96,7 @@ QUnit.testDone(function() { } }); - current.getElementsByTagName('a')[0].href = src; + current.getElementsByTagName("a")[0].href = src; }); }( QUnit ) ); diff --git a/tests/unit/resizable/resizable_common.js b/tests/unit/resizable/resizable_common.js index 2c64f3cb1..6758214ad 100644 --- a/tests/unit/resizable/resizable_common.js +++ b/tests/unit/resizable/resizable_common.js @@ -1,19 +1,19 @@ -TestHelpers.commonWidgetTests('resizable', { +TestHelpers.commonWidgetTests("resizable", { defaults: { alsoResize: false, animate: false, - animateDuration: 'slow', - animateEasing: 'swing', + animateDuration: "slow", + animateEasing: "swing", aspectRatio: false, autoHide: false, - cancel: 'input,textarea,button,select,option', + cancel: "input,textarea,button,select,option", containment: false, delay: 0, disabled: false, distance: 1, ghost: false, grid: false, - handles: 'e,s,se', + handles: "e,s,se", helper: false, maxHeight: null, maxWidth: null, diff --git a/tests/unit/resizable/resizable_core.js b/tests/unit/resizable/resizable_core.js index 13da26ece..4cffea185 100644 --- a/tests/unit/resizable/resizable_core.js +++ b/tests/unit/resizable/resizable_core.js @@ -8,17 +8,17 @@ module("resizable: core"); /* test("element types", function() { - var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form' - + ',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr' - + ',acronym,code,samp,kbd,var,img,object,hr' - + ',input,button,label,select,iframe').split(','); + var typeNames = ("p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form" + + ",table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr" + + ",acronym,code,samp,kbd,var,img,object,hr" + + ",input,button,label,select,iframe").split(","); $.each(typeNames, function(i) { var typeName = typeNames[i]; - el = $(document.createElement(typeName)).appendTo('body'); - (typeName == 'table' && el.append("<tr><td>content</td></tr>")); + el = $(document.createElement(typeName)).appendTo("body"); + (typeName == "table" && el.append("<tr><td>content</td></tr>")); el.resizable(); - ok(true, '$("<' + typeName + '/>").resizable()'); + ok(true, "$('<" + typeName + "/>').resizable()"); el.resizable("destroy"); el.remove(); }); @@ -28,7 +28,7 @@ test("element types", function() { test("n", function() { expect(4); - var handle = '.ui-resizable-n', target = $('#resizable1').resizable({ handles: 'all' }); + var handle = ".ui-resizable-n", target = $("#resizable1").resizable({ handles: "all" }); TestHelpers.resizable.drag(handle, 0, -50); equal( target.height(), 150, "compare height" ); @@ -43,7 +43,7 @@ test("n", function() { test("s", function() { expect(5); - var handle = '.ui-resizable-s', target = $('#resizable1').resizable({ handles: 'all' }); + var handle = ".ui-resizable-s", target = $("#resizable1").resizable({ handles: "all" }); TestHelpers.resizable.drag(handle, 0, 50); equal( target.height(), 150, "compare height" ); @@ -59,7 +59,7 @@ test("s", function() { test("e", function() { expect(5); - var handle = '.ui-resizable-e', target = $('#resizable1').resizable({ handles: 'all' }); + var handle = ".ui-resizable-e", target = $("#resizable1").resizable({ handles: "all" }); TestHelpers.resizable.drag(handle, 50); equal( target.width(), 150, "compare width"); @@ -75,7 +75,7 @@ test("e", function() { test("w", function() { expect(4); - var handle = '.ui-resizable-w', target = $('#resizable1').resizable({ handles: 'all' }); + var handle = ".ui-resizable-w", target = $("#resizable1").resizable({ handles: "all" }); TestHelpers.resizable.drag(handle, -50); equal( target.width(), 150, "compare width" ); @@ -90,7 +90,7 @@ test("w", function() { test("ne", function() { expect(5); - var handle = '.ui-resizable-ne', target = $('#resizable1').css({ overflow: 'hidden' }).resizable({ handles: 'all' }); + var handle = ".ui-resizable-ne", target = $("#resizable1").css({ overflow: "hidden" }).resizable({ handles: "all" }); TestHelpers.resizable.drag(handle, -50, -50); equal( target.width(), 50, "compare width" ); @@ -106,7 +106,7 @@ test("ne", function() { test("se", function() { expect(6); - var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all' }); + var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all" }); TestHelpers.resizable.drag(handle, 50, 50); equal( target.width(), 150, "compare width" ); @@ -123,7 +123,7 @@ test("se", function() { test("sw", function() { expect(5); - var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ handles: 'all' }); + var handle = ".ui-resizable-sw", target = $("#resizable1").resizable({ handles: "all" }); TestHelpers.resizable.drag(handle, -50, -50); equal( target.width(), 150, "compare width" ); @@ -139,7 +139,7 @@ test("sw", function() { test("nw", function() { expect(4); - var handle = '.ui-resizable-nw', target = $('#resizable1').resizable({ handles: 'all' }); + var handle = ".ui-resizable-nw", target = $("#resizable1").resizable({ handles: "all" }); TestHelpers.resizable.drag(handle, -50, -50); equal( target.width(), 150, "compare width" ); @@ -153,15 +153,15 @@ test("nw", function() { test("handle with complex markup (#8756)", function() { expect(2); - $('#resizable1') + $("#resizable1") .append( - $('<div>') + $("<div>") .addClass("ui-resizable-handle") .addClass("ui-resizable-w") - .append($('<div>')) + .append($("<div>")) ); - var handle = '.ui-resizable-w div', target = $('#resizable1').resizable({ handles: 'all' }); + var handle = ".ui-resizable-w div", target = $("#resizable1").resizable({ handles: "all" }); TestHelpers.resizable.drag(handle, -50); equal( target.width(), 150, "compare width" ); @@ -176,7 +176,7 @@ test("resizable accounts for scroll position correctly (#3815)", function() { var position, top, left, container = $("<div style='overflow:scroll;height:300px;width:300px;position:relative;'></div>").appendTo("#qunit-fixture"), overflowed = $("<div style='width: 1000px; height: 1000px;'></div>").appendTo( container ), - el = $("<div style='height:100px;width:100px;position:absolute;top:10px;left:10px;'></div>").appendTo( overflowed ).resizable({ handles: 'all' }), + el = $("<div style='height:100px;width:100px;position:absolute;top:10px;left:10px;'></div>").appendTo( overflowed ).resizable({ handles: "all" }), handle = ".ui-resizable-e"; container.scrollLeft( 100 ).scrollTop( 100 ); diff --git a/tests/unit/resizable/resizable_options.js b/tests/unit/resizable/resizable_options.js index d79523183..89504e363 100644 --- a/tests/unit/resizable/resizable_options.js +++ b/tests/unit/resizable/resizable_options.js @@ -28,7 +28,7 @@ test( "alsoResize", function() { test("aspectRatio: 'preserve' (e)", function() { expect(4); - var handle = '.ui-resizable-e', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); + var handle = ".ui-resizable-e", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); TestHelpers.resizable.drag(handle, 80); equal( target.width(), 130, "compare maxWidth"); @@ -42,7 +42,7 @@ test("aspectRatio: 'preserve' (e)", function() { test("aspectRatio: 'preserve' (w)", function() { expect(4); - var handle = '.ui-resizable-w', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); + var handle = ".ui-resizable-w", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); TestHelpers.resizable.drag(handle, -80); equal( target.width(), 130, "compare maxWidth"); @@ -56,7 +56,7 @@ test("aspectRatio: 'preserve' (w)", function() { test("aspectRatio: 'preserve' (n)", function() { expect(4); - var handle = '.ui-resizable-n', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); + var handle = ".ui-resizable-n", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); TestHelpers.resizable.drag(handle, 0, -80); equal( target.width(), 130, "compare maxWidth"); @@ -70,7 +70,7 @@ test("aspectRatio: 'preserve' (n)", function() { test("aspectRatio: 'preserve' (s)", function() { expect(4); - var handle = '.ui-resizable-s', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); + var handle = ".ui-resizable-s", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); TestHelpers.resizable.drag(handle, 0, 80); equal( target.width(), 130, "compare maxWidth"); @@ -84,7 +84,7 @@ test("aspectRatio: 'preserve' (s)", function() { test("aspectRatio: 'preserve' (se)", function() { expect(4); - var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); + var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); TestHelpers.resizable.drag(handle, 80, 80); equal( target.width(), 130, "compare maxWidth"); @@ -98,7 +98,7 @@ test("aspectRatio: 'preserve' (se)", function() { test("aspectRatio: 'preserve' (sw)", function() { expect(4); - var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); + var handle = ".ui-resizable-sw", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); TestHelpers.resizable.drag(handle, -80, 80); equal( target.width(), 130, "compare maxWidth"); @@ -112,7 +112,7 @@ test("aspectRatio: 'preserve' (sw)", function() { test("aspectRatio: 'preserve' (ne)", function() { expect(4); - var handle = '.ui-resizable-ne', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); + var handle = ".ui-resizable-ne", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); TestHelpers.resizable.drag(handle, 80, -80); equal( target.width(), 130, "compare maxWidth"); @@ -141,7 +141,7 @@ test( "containment", function() { test("grid", function() { expect(4); - var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all', grid: [0, 20] }); + var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all", grid: [0, 20] }); TestHelpers.resizable.drag(handle, 3, 9); equal( target.width(), 103, "compare width"); @@ -169,7 +169,7 @@ test("grid (min/max dimensions)", function() { test("grid (wrapped)", function() { expect(4); - var handle = '.ui-resizable-se', target = $('#resizable2').resizable({ handles: 'all', grid: [0, 20] }); + var handle = ".ui-resizable-se", target = $("#resizable2").resizable({ handles: "all", grid: [0, 20] }); TestHelpers.resizable.drag(handle, 3, 9); equal( target.width(), 103, "compare width"); @@ -183,7 +183,7 @@ test("grid (wrapped)", function() { test("ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { expect(4); - var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); + var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); TestHelpers.resizable.drag(handle, -50, -50); equal( target.width(), 60, "compare minWidth" ); @@ -197,7 +197,7 @@ test("ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 1 test("ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { expect(4); - var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); + var handle = ".ui-resizable-sw", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); TestHelpers.resizable.drag(handle, 50, -50); equal( target.width(), 60, "compare minWidth" ); @@ -211,7 +211,7 @@ test("ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 1 test("ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { expect(4); - var handle = '.ui-resizable-ne', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); + var handle = ".ui-resizable-ne", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); TestHelpers.resizable.drag(handle, -50, 50); equal( target.width(), 60, "compare minWidth" ); @@ -225,7 +225,7 @@ test("ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 1 test("ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { expect(4); - var handle = '.ui-resizable-nw', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); + var handle = ".ui-resizable-nw", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); TestHelpers.resizable.drag(handle, 70, 70); equal( target.width(), 60, "compare minWidth" ); @@ -239,9 +239,9 @@ test("ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 1 test("zIndex, applied to all handles", function() { expect(8); - var target = $('<div></div>').resizable({ handles: 'all', zIndex: 100 }); - target.children( '.ui-resizable-handle' ).each( function( index, handle ) { - equal( $( handle ).css( 'zIndex' ), 100, 'compare zIndex' ); + var target = $("<div></div>").resizable({ handles: "all", zIndex: 100 }); + target.children( ".ui-resizable-handle" ).each( function( index, handle ) { + equal( $( handle ).css( "zIndex" ), 100, "compare zIndex" ); }); }); diff --git a/tests/unit/selectable/selectable_common.js b/tests/unit/selectable/selectable_common.js index aee6a15ac..00bbedc61 100644 --- a/tests/unit/selectable/selectable_common.js +++ b/tests/unit/selectable/selectable_common.js @@ -1,13 +1,13 @@ -TestHelpers.commonWidgetTests('selectable', { +TestHelpers.commonWidgetTests("selectable", { defaults: { - appendTo: 'body', + appendTo: "body", autoRefresh: true, - cancel: 'input,textarea,button,select,option', + cancel: "input,textarea,button,select,option", create: null, delay: 0, disabled: false, distance: 0, - filter: '*', - tolerance: 'touch' + filter: "*", + tolerance: "touch" } }); diff --git a/tests/unit/selectable/selectable_methods.js b/tests/unit/selectable/selectable_methods.js index d894a13e4..72f9bb28d 100644 --- a/tests/unit/selectable/selectable_methods.js +++ b/tests/unit/selectable/selectable_methods.js @@ -8,39 +8,39 @@ module("selectable: methods"); test("init", function() { expect( 5 ); - $("<div></div>").appendTo('body').selectable().remove(); - ok(true, '.selectable() called on element'); + $("<div></div>").appendTo("body").selectable().remove(); + ok(true, ".selectable() called on element"); $([]).selectable().remove(); - ok(true, '.selectable() called on empty collection'); + ok(true, ".selectable() called on empty collection"); $("<div></div>").selectable().remove(); - ok(true, '.selectable() called on disconnected DOMElement'); + ok(true, ".selectable() called on disconnected DOMElement"); var el = $("<div></div>").selectable(); el.selectable("option", "foo"); el.remove(); - ok(true, 'arbitrary option getter after init'); + ok(true, "arbitrary option getter after init"); $("<div></div>").selectable().selectable("option", "foo", "bar").remove(); - ok(true, 'arbitrary option setter after init'); + ok(true, "arbitrary option setter after init"); }); test("destroy", function() { expect( 4 ); - $("<div></div>").appendTo('body').selectable().selectable("destroy").remove(); - ok(true, '.selectable("destroy") called on element'); + $("<div></div>").appendTo("body").selectable().selectable("destroy").remove(); + ok(true, ".selectable('destroy') called on element"); $([]).selectable().selectable("destroy").remove(); - ok(true, '.selectable("destroy") called on empty collection'); + ok(true, ".selectable('destroy') called on empty collection"); $("<div></div>").selectable().selectable("destroy").remove(); - ok(true, '.selectable("destroy") called on disconnected DOMElement'); + ok(true, ".selectable('destroy') called on disconnected DOMElement"); - var expected = $('<div></div>').selectable(), - actual = expected.selectable('destroy'); - equal(actual, expected, 'destroy is chainable'); + var expected = $("<div></div>").selectable(), + actual = expected.selectable("destroy"); + equal(actual, expected, "destroy is chainable"); }); test("enable", function() { @@ -66,9 +66,9 @@ test("enable", function() { equal(fired, true, "start fired"); el.selectable("destroy"); - expected = $('<div></div>').selectable(); - actual = expected.selectable('enable'); - equal(actual, expected, 'enable is chainable'); + expected = $("<div></div>").selectable(); + actual = expected.selectable("enable"); + equal(actual, expected, "enable is chainable"); }); test("disable", function() { @@ -96,9 +96,9 @@ test("disable", function() { equal(fired, false, "start fired"); el.selectable("destroy"); - expected = $('<div></div>').selectable(); - actual = expected.selectable('disable'); - equal(actual, expected, 'disable is chainable'); + expected = $("<div></div>").selectable(); + actual = expected.selectable("disable"); + equal(actual, expected, "disable is chainable"); }); })(jQuery); diff --git a/tests/unit/selectable/selectable_options.js b/tests/unit/selectable/selectable_options.js index a2455fdca..973247f56 100644 --- a/tests/unit/selectable/selectable_options.js +++ b/tests/unit/selectable/selectable_options.js @@ -52,7 +52,7 @@ test("filter", function() { selected = function() { actual += 1; }; - el = $("#selectable1").selectable({ filter: '.special', selected: selected }); + el = $("#selectable1").selectable({ filter: ".special", selected: selected }); el.simulate( "drag", { dx: 1000, dy: 1000 diff --git a/tests/unit/slider/slider_common.js b/tests/unit/slider/slider_common.js index ccf793549..48fd5e457 100644 --- a/tests/unit/slider/slider_common.js +++ b/tests/unit/slider/slider_common.js @@ -1,13 +1,13 @@ TestHelpers.commonWidgetTests( "slider", { defaults: { animate: false, - cancel: 'input,textarea,button,select,option', + cancel: "input,textarea,button,select,option", delay: 0, disabled: false, distance: 0, max: 100, min: 0, - orientation: 'horizontal', + orientation: "horizontal", range: false, step: 1, value: 0, diff --git a/tests/unit/slider/slider_core.js b/tests/unit/slider/slider_core.js index 86a516875..7195147cc 100644 --- a/tests/unit/slider/slider_core.js +++ b/tests/unit/slider/slider_core.js @@ -17,11 +17,11 @@ module("slider: core"); test("keydown HOME on handle sets value to min", function() { expect( 2 ); - el = $('<div></div>'); + el = $("<div></div>"); options = { max: 5, min: -5, - orientation: 'horizontal', + orientation: "horizontal", step: 1 }; el.slider(options); @@ -31,13 +31,13 @@ test("keydown HOME on handle sets value to min", function() { handle().simulate("keydown", { keyCode: $.ui.keyCode.HOME }); equal(el.slider("value"), options.min); - el.slider('destroy'); + el.slider("destroy"); - el = $('<div></div>'); + el = $("<div></div>"); options = { max: 5, min: -5, - orientation: 'vertical', + orientation: "vertical", step: 1 }; el.slider(options); @@ -47,16 +47,16 @@ test("keydown HOME on handle sets value to min", function() { handle().simulate("keydown", { keyCode: $.ui.keyCode.HOME }); equal(el.slider("value"), options.min); - el.slider('destroy'); + el.slider("destroy"); }); test("keydown END on handle sets value to max", function() { expect( 2 ); - el = $('<div></div>'); + el = $("<div></div>"); options = { max: 5, min: -5, - orientation: 'horizontal', + orientation: "horizontal", step: 1 }; el.slider(options); @@ -66,13 +66,13 @@ test("keydown END on handle sets value to max", function() { handle().simulate("keydown", { keyCode: $.ui.keyCode.END }); equal(el.slider("value"), options.max); - el.slider('destroy'); + el.slider("destroy"); - el = $('<div></div>'); + el = $("<div></div>"); options = { max: 5, min: -5, - orientation: 'vertical', + orientation: "vertical", step: 1 }; el.slider(options); @@ -82,13 +82,13 @@ test("keydown END on handle sets value to max", function() { handle().simulate("keydown", { keyCode: $.ui.keyCode.END }); equal(el.slider("value"), options.max); - el.slider('destroy'); + el.slider("destroy"); }); test("keydown PAGE_UP on handle increases value by 1/5 range, not greater than max", function() { expect( 4 ); - $.each(['horizontal', 'vertical'], function(i, orientation) { - el = $('<div></div>'); + $.each(["horizontal", "vertical"], function(i, orientation) { + el = $("<div></div>"); options = { max: 100, min: 0, @@ -111,8 +111,8 @@ test("keydown PAGE_UP on handle increases value by 1/5 range, not greater than m test("keydown PAGE_DOWN on handle decreases value by 1/5 range, not less than min", function() { expect( 4 ); - $.each(['horizontal', 'vertical'], function(i, orientation) { - el = $('<div></div>'); + $.each(["horizontal", "vertical"], function(i, orientation) { + el = $("<div></div>"); options = { max: 100, min: 0, @@ -135,11 +135,11 @@ test("keydown PAGE_DOWN on handle decreases value by 1/5 range, not less than mi test("keydown UP on handle increases value by step, not greater than max", function() { expect( 4 ); - el = $('<div></div>'); + el = $("<div></div>"); options = { max: 5, min: -5, - orientation: 'horizontal', + orientation: "horizontal", step: 1 }; el.slider(options); @@ -154,11 +154,11 @@ test("keydown UP on handle increases value by step, not greater than max", funct el.slider("destroy"); - el = $('<div></div>'); + el = $("<div></div>"); options = { max: 5, min: -5, - orientation: 'vertical', + orientation: "vertical", step: 1 }; el.slider(options); @@ -176,11 +176,11 @@ test("keydown UP on handle increases value by step, not greater than max", funct test("keydown RIGHT on handle increases value by step, not greater than max", function() { expect( 4 ); - el = $('<div></div>'); + el = $("<div></div>"); options = { max: 5, min: -5, - orientation: 'horizontal', + orientation: "horizontal", step: 1 }; el.slider(options); @@ -195,11 +195,11 @@ test("keydown RIGHT on handle increases value by step, not greater than max", fu el.slider("destroy"); - el = $('<div></div>'); + el = $("<div></div>"); options = { max: 5, min: -5, - orientation: 'vertical', + orientation: "vertical", step: 1 }; el.slider(options); @@ -217,11 +217,11 @@ test("keydown RIGHT on handle increases value by step, not greater than max", fu test("keydown DOWN on handle decreases value by step, not less than min", function() { expect( 4 ); - el = $('<div></div>'); + el = $("<div></div>"); options = { max: 5, min: -5, - orientation: 'horizontal', + orientation: "horizontal", step: 1 }; el.slider(options); @@ -236,11 +236,11 @@ test("keydown DOWN on handle decreases value by step, not less than min", functi el.slider("destroy"); - el = $('<div></div>'); + el = $("<div></div>"); options = { max: 5, min: -5, - orientation: 'vertical', + orientation: "vertical", step: 1 }; el.slider(options); @@ -258,11 +258,11 @@ test("keydown DOWN on handle decreases value by step, not less than min", functi test("keydown LEFT on handle decreases value by step, not less than min", function() { expect( 4 ); - el = $('<div></div>'); + el = $("<div></div>"); options = { max: 5, min: -5, - orientation: 'horizontal', + orientation: "horizontal", step: 1 }; el.slider(options); @@ -277,11 +277,11 @@ test("keydown LEFT on handle decreases value by step, not less than min", functi el.slider("destroy"); - el = $('<div></div>'); + el = $("<div></div>"); options = { max: 5, min: -5, - orientation: 'vertical', + orientation: "vertical", step: 1 }; el.slider(options); diff --git a/tests/unit/slider/slider_methods.js b/tests/unit/slider/slider_methods.js index 83e78b855..73b8eb739 100644 --- a/tests/unit/slider/slider_methods.js +++ b/tests/unit/slider/slider_methods.js @@ -8,22 +8,22 @@ module("slider: methods"); test("init", function() { expect(5); - $("<div></div>").appendTo('body').slider().remove(); - ok(true, '.slider() called on element'); + $("<div></div>").appendTo("body").slider().remove(); + ok(true, ".slider() called on element"); $([]).slider().remove(); - ok(true, '.slider() called on empty collection'); + ok(true, ".slider() called on empty collection"); - $('<div></div>').slider().remove(); - ok(true, '.slider() called on disconnected DOMElement'); + $("<div></div>").slider().remove(); + ok(true, ".slider() called on disconnected DOMElement"); - var el = $('<div></div>').slider(); + var el = $("<div></div>").slider(); el.slider("option", "foo"); el.remove(); - ok(true, 'arbitrary option getter after init'); + ok(true, "arbitrary option getter after init"); - $('<div></div>').slider().slider("option", "foo", "bar").remove(); - ok(true, 'arbitrary option setter after init'); + $("<div></div>").slider().slider("option", "foo", "bar").remove(); + ok(true, "arbitrary option setter after init"); }); test("destroy", function() { @@ -36,60 +36,60 @@ test("destroy", function() { test("enable", function() { expect( 5 ); var el, - expected = $('<div></div>').slider(), - actual = expected.slider('enable'); - equal(actual, expected, 'enable is chainable'); + expected = $("<div></div>").slider(), + actual = expected.slider("enable"); + equal(actual, expected, "enable is chainable"); - el = $('<div></div>').slider({ disabled: true }); - ok(el.hasClass('ui-state-disabled'), 'slider has ui-state-disabled class before enable method call'); - ok(el.hasClass('ui-slider-disabled'), 'slider has ui-slider-disabled class before enable method call'); - el.slider('enable'); - ok(!el.hasClass('ui-state-disabled'), 'slider does not have ui-state-disabled class after enable method call'); - ok(!el.hasClass('ui-slider-disabled'), 'slider does not have ui-slider-disabled class after enable method call'); + el = $("<div></div>").slider({ disabled: true }); + ok(el.hasClass("ui-state-disabled"), "slider has ui-state-disabled class before enable method call"); + ok(el.hasClass("ui-slider-disabled"), "slider has ui-slider-disabled class before enable method call"); + el.slider("enable"); + ok(!el.hasClass("ui-state-disabled"), "slider does not have ui-state-disabled class after enable method call"); + ok(!el.hasClass("ui-slider-disabled"), "slider does not have ui-slider-disabled class after enable method call"); }); test("disable", function() { expect( 5 ); var el, - expected = $('<div></div>').slider(), - actual = expected.slider('disable'); - equal(actual, expected, 'disable is chainable'); + expected = $("<div></div>").slider(), + actual = expected.slider("disable"); + equal(actual, expected, "disable is chainable"); - el = $('<div></div>').slider({ disabled: false }); - ok(!el.hasClass('ui-state-disabled'), 'slider does not have ui-state-disabled class before disabled method call'); - ok(!el.hasClass('ui-slider-disabled'), 'slider does not have ui-slider-disabled class before disable method call'); - el.slider('disable'); - ok(el.hasClass('ui-state-disabled'), 'slider has ui-state-disabled class after disable method call'); - ok(el.hasClass('ui-slider-disabled'), 'slider has ui-slider-disabled class after disable method call'); + el = $("<div></div>").slider({ disabled: false }); + ok(!el.hasClass("ui-state-disabled"), "slider does not have ui-state-disabled class before disabled method call"); + ok(!el.hasClass("ui-slider-disabled"), "slider does not have ui-slider-disabled class before disable method call"); + el.slider("disable"); + ok(el.hasClass("ui-state-disabled"), "slider has ui-state-disabled class after disable method call"); + ok(el.hasClass("ui-slider-disabled"), "slider has ui-slider-disabled class after disable method call"); }); test("value", function() { expect( 17 ); - $([false, 'min', 'max']).each(function() { - var el = $('<div></div>').slider({ + $([false, "min", "max"]).each(function() { + var el = $("<div></div>").slider({ range: this, value: 5 }); - equal(el.slider('value'), 5, 'range: ' + this + ' slider method get'); - equal(el.slider('value', 10), el, 'value method is chainable'); - equal(el.slider('value'), 10, 'range: ' + this + ' slider method set'); + equal(el.slider("value"), 5, "range: " + this + " slider method get"); + equal(el.slider("value", 10), el, "value method is chainable"); + equal(el.slider("value"), 10, "range: " + this + " slider method set"); el.remove(); }); - var el = $('<div></div>').slider({ + var el = $("<div></div>").slider({ min: -1, value: 0, max: 1 }); // min with value option vs value method - el.slider('option', 'value', -2); - equal(el.slider('option', 'value'), -2, 'value option does not respect min'); - equal(el.slider('value'), -1, 'value method get respects min'); - equal(el.slider('value', -2), el, 'value method is chainable'); - equal(el.slider('option', 'value'), -1, 'value method set respects min'); + el.slider("option", "value", -2); + equal(el.slider("option", "value"), -2, "value option does not respect min"); + equal(el.slider("value"), -1, "value method get respects min"); + equal(el.slider("value", -2), el, "value method is chainable"); + equal(el.slider("option", "value"), -1, "value method set respects min"); // max with value option vs value method - el.slider('option', 'value', 2); - equal(el.slider('option', 'value'), 2, 'value option does not respect max'); - equal(el.slider('value'), 1, 'value method get respects max'); - equal(el.slider('value', 2), el, 'value method is chainable'); - equal(el.slider('option', 'value'), 1, 'value method set respects max'); + el.slider("option", "value", 2); + equal(el.slider("option", "value"), 2, "value option does not respect max"); + equal(el.slider("value"), 1, "value method get respects max"); + equal(el.slider("value", 2), el, "value method is chainable"); + equal(el.slider("option", "value"), 1, "value method set respects max"); }); //test("values", function() { diff --git a/tests/unit/slider/slider_options.js b/tests/unit/slider/slider_options.js index e34352eb0..d354ef91c 100644 --- a/tests/unit/slider/slider_options.js +++ b/tests/unit/slider/slider_options.js @@ -13,12 +13,12 @@ module("slider: options"); test("max", function() { expect( 2 ); - el = $('<div></div>'); + el = $("<div></div>"); options = { max: 37, min: 6, - orientation: 'horizontal', + orientation: "horizontal", step: 1, value: 50 }; @@ -26,18 +26,18 @@ test("max", function() { el.slider(options); ok(el.slider("option", "value") === options.value, "value option is not contained by max"); ok(el.slider("value") === options.max, "value method is contained by max"); - el.slider('destroy'); + el.slider("destroy"); }); test("min", function() { expect( 2 ); - el = $('<div></div>'); + el = $("<div></div>"); options = { max: 37, min: 6, - orientation: 'vertical', + orientation: "vertical", step: 1, value: 2 }; @@ -45,45 +45,45 @@ test("min", function() { el.slider(options); ok(el.slider("option", "value") === options.value, "value option is not contained by min"); ok(el.slider("value") === options.min, "value method is contained by min"); - el.slider('destroy'); + el.slider("destroy"); }); test("orientation", function() { expect( 6 ); - el = $('#slider1'); + el = $("#slider1"); options = { max: 2, min: -2, - orientation: 'vertical', + orientation: "vertical", value: 1 }; var percentVal = (options.value - options.min) / (options.max - options.min) * 100; el.slider(options).slider("option", "orientation", "horizontal"); - ok(el.is('.ui-slider-horizontal'), "horizontal slider has class .ui-slider-horizontal"); - ok(!el.is('.ui-slider-vertical'), "horizontal slider does not have class .ui-slider-vertical"); - equal(handle()[0].style.left, percentVal + '%', "horizontal slider handle is positioned with left: %"); + ok(el.is(".ui-slider-horizontal"), "horizontal slider has class .ui-slider-horizontal"); + ok(!el.is(".ui-slider-vertical"), "horizontal slider does not have class .ui-slider-vertical"); + equal(handle()[0].style.left, percentVal + "%", "horizontal slider handle is positioned with left: %"); - el.slider('destroy'); + el.slider("destroy"); options = { max: 2, min: -2, - orientation: 'horizontal', + orientation: "horizontal", value: -1 }; percentVal = (options.value - options.min) / (options.max - options.min) * 100; el.slider(options).slider("option", "orientation", "vertical"); - ok(el.is('.ui-slider-vertical'), "vertical slider has class .ui-slider-vertical"); - ok(!el.is('.ui-slider-horizontal'), "vertical slider does not have class .ui-slider-horizontal"); - equal(handle()[0].style.bottom, percentVal + '%', "vertical slider handle is positioned with bottom: %"); + ok(el.is(".ui-slider-vertical"), "vertical slider has class .ui-slider-vertical"); + ok(!el.is(".ui-slider-horizontal"), "vertical slider does not have class .ui-slider-horizontal"); + equal(handle()[0].style.bottom, percentVal + "%", "vertical slider handle is positioned with bottom: %"); - el.slider('destroy'); + el.slider("destroy"); }); @@ -96,7 +96,7 @@ test("orientation", function() { // What is returned by the value method is restricted by min (>=), max (<=), and step (even multiple) test("step", function() { expect( 9 ); - var el = $('<div></div>').slider({ + var el = $("<div></div>").slider({ min: 0, value: 0, step: 10, @@ -116,7 +116,7 @@ test("step", function() { el.slider("value", 19); equal( el.slider("value"), 20 ); - el = $('<div></div>').slider({ + el = $("<div></div>").slider({ min: 0, value: 0, step: 20, @@ -136,7 +136,7 @@ test("step", function() { el.slider("option", "value", 19); equal( el.slider("value"), 20 ); - el.slider('destroy'); + el.slider("destroy"); }); //test("value", function() { diff --git a/tests/unit/sortable/sortable_events.js b/tests/unit/sortable/sortable_events.js index b9ee078f5..1b8165acb 100644 --- a/tests/unit/sortable/sortable_events.js +++ b/tests/unit/sortable/sortable_events.js @@ -17,15 +17,15 @@ test("start", function() { dy: 10 }); - ok(hash, 'start event triggered'); - ok(hash.helper, 'UI hash includes: helper'); - ok(hash.placeholder, 'UI hash includes: placeholder'); - ok(hash.item, 'UI hash includes: item'); - ok(!hash.sender, 'UI hash does not include: sender'); + ok(hash, "start event triggered"); + ok(hash.helper, "UI hash includes: helper"); + ok(hash.placeholder, "UI hash includes: placeholder"); + ok(hash.item, "UI hash includes: item"); + ok(!hash.sender, "UI hash does not include: sender"); // todo: see if these events should actually have sane values in them - ok('position' in hash, 'UI hash includes: position'); - ok('offset' in hash, 'UI hash includes: offset'); + ok("position" in hash, "UI hash includes: position"); + ok("offset" in hash, "UI hash includes: offset"); }); @@ -42,13 +42,13 @@ test("sort", function() { dy: 10 }); - ok(hash, 'sort event triggered'); - ok(hash.helper, 'UI hash includes: helper'); - ok(hash.placeholder, 'UI hash includes: placeholder'); - ok(hash.position && ('top' in hash.position && 'left' in hash.position), 'UI hash includes: position'); - ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset'); - ok(hash.item, 'UI hash includes: item'); - ok(!hash.sender, 'UI hash does not include: sender'); + ok(hash, "sort event triggered"); + ok(hash.helper, "UI hash includes: helper"); + ok(hash.placeholder, "UI hash includes: placeholder"); + ok(hash.position && ("top" in hash.position && "left" in hash.position), "UI hash includes: position"); + ok(hash.offset && (hash.offset.top && hash.offset.left), "UI hash includes: offset"); + ok(hash.item, "UI hash includes: item"); + ok(!hash.sender, "UI hash does not include: sender"); }); @@ -65,7 +65,7 @@ test("change", function() { dy: 1 }); - ok(!hash, '1px drag, change event should not be triggered'); + ok(!hash, "1px drag, change event should not be triggered"); $("#sortable").sortable({ change: function( e, ui ) { @@ -75,13 +75,13 @@ test("change", function() { dy: 22 }); - ok(hash, 'change event triggered'); - ok(hash.helper, 'UI hash includes: helper'); - ok(hash.placeholder, 'UI hash includes: placeholder'); - ok(hash.position && ('top' in hash.position && 'left' in hash.position), 'UI hash includes: position'); - ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset'); - ok(hash.item, 'UI hash includes: item'); - ok(!hash.sender, 'UI hash does not include: sender'); + ok(hash, "change event triggered"); + ok(hash.helper, "UI hash includes: helper"); + ok(hash.placeholder, "UI hash includes: placeholder"); + ok(hash.position && ("top" in hash.position && "left" in hash.position), "UI hash includes: position"); + ok(hash.offset && (hash.offset.top && hash.offset.left), "UI hash includes: offset"); + ok(hash.item, "UI hash includes: item"); + ok(!hash.sender, "UI hash does not include: sender"); }); @@ -97,13 +97,13 @@ test("beforeStop", function() { dy: 20 }); - ok(hash, 'beforeStop event triggered'); - ok(hash.helper, 'UI hash includes: helper'); - ok(hash.placeholder, 'UI hash includes: placeholder'); - ok(hash.position && ('top' in hash.position && 'left' in hash.position), 'UI hash includes: position'); - ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset'); - ok(hash.item, 'UI hash includes: item'); - ok(!hash.sender, 'UI hash does not include: sender'); + ok(hash, "beforeStop event triggered"); + ok(hash.helper, "UI hash includes: helper"); + ok(hash.placeholder, "UI hash includes: placeholder"); + ok(hash.position && ("top" in hash.position && "left" in hash.position), "UI hash includes: position"); + ok(hash.offset && (hash.offset.top && hash.offset.left), "UI hash includes: offset"); + ok(hash.item, "UI hash includes: item"); + ok(!hash.sender, "UI hash does not include: sender"); }); @@ -119,13 +119,13 @@ test("stop", function() { dy: 20 }); - ok(hash, 'stop event triggered'); - ok(!hash.helper, 'UI should not include: helper'); - ok(hash.placeholder, 'UI hash includes: placeholder'); - ok(hash.position && ('top' in hash.position && 'left' in hash.position), 'UI hash includes: position'); - ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset'); - ok(hash.item, 'UI hash includes: item'); - ok(!hash.sender, 'UI hash does not include: sender'); + ok(hash, "stop event triggered"); + ok(!hash.helper, "UI should not include: helper"); + ok(hash.placeholder, "UI hash includes: placeholder"); + ok(hash.position && ("top" in hash.position && "left" in hash.position), "UI hash includes: position"); + ok(hash.offset && (hash.offset.top && hash.offset.left), "UI hash includes: offset"); + ok(hash.item, "UI hash includes: item"); + ok(!hash.sender, "UI hash does not include: sender"); }); @@ -142,7 +142,7 @@ test("update", function() { dy: 1 }); - ok(!hash, '1px drag, update event should not be triggered'); + ok(!hash, "1px drag, update event should not be triggered"); $("#sortable").sortable({ update: function( e, ui ) { @@ -152,13 +152,13 @@ test("update", function() { dy: 22 }); - ok(hash, 'update event triggered'); - ok(!hash.helper, 'UI hash should not include: helper'); - ok(hash.placeholder, 'UI hash includes: placeholder'); - ok(hash.position && ('top' in hash.position && 'left' in hash.position), 'UI hash includes: position'); - ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset'); - ok(hash.item, 'UI hash includes: item'); - ok(!hash.sender, 'UI hash does not include: sender'); + ok(hash, "update event triggered"); + ok(!hash.helper, "UI hash should not include: helper"); + ok(hash.placeholder, "UI hash includes: placeholder"); + ok(hash.position && ("top" in hash.position && "left" in hash.position), "UI hash includes: position"); + ok(hash.offset && (hash.offset.top && hash.offset.left), "UI hash includes: offset"); + ok(hash.item, "UI hash includes: item"); + ok(!hash.sender, "UI hash does not include: sender"); }); @@ -172,21 +172,21 @@ test("#3019: Stop fires too early", function() { } }); - TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, 'Dragging the sortable'); + TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, "Dragging the sortable"); equal(helper, null, "helper should be false"); }); -test('#4752: link event firing on sortable with connect list', function () { +test("#4752: link event firing on sortable with connect list", function () { expect( 10 ); var fired = {}, hasFired = function (type) { return (type in fired) && (true === fired[type]); }; - $('#sortable').clone().attr('id', 'sortable2').insertAfter('#sortable'); + $("#sortable").clone().attr("id", "sortable2").insertAfter("#sortable"); - $('#qunit-fixture ul').sortable({ - connectWith: '#qunit-fixture ul', + $("#qunit-fixture ul").sortable({ + connectWith: "#qunit-fixture ul", change: function () { fired.change = true; }, @@ -198,29 +198,29 @@ test('#4752: link event firing on sortable with connect list', function () { } }); - $('#qunit-fixture ul').bind('click.ui-sortable-test', function () { + $("#qunit-fixture ul").bind("click.ui-sortable-test", function () { fired.click = true; }); - $('#sortable li:eq(0)').simulate('click'); - ok(!hasFired('change'), 'Click only, change event should not have fired'); - ok(hasFired('click'), 'Click event should have fired'); + $("#sortable li:eq(0)").simulate("click"); + ok(!hasFired("change"), "Click only, change event should not have fired"); + ok(hasFired("click"), "Click event should have fired"); // Drag an item within the first list fired = {}; - $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 40 }); - ok(hasFired('change'), '40px drag, change event should have fired'); - ok(!hasFired('receive'), 'Receive event should not have fired'); - ok(!hasFired('remove'), 'Remove event should not have fired'); - ok(!hasFired('click'), 'Click event should not have fired'); + $("#sortable li:eq(0)").simulate("drag", { dx: 0, dy: 40 }); + ok(hasFired("change"), "40px drag, change event should have fired"); + ok(!hasFired("receive"), "Receive event should not have fired"); + ok(!hasFired("remove"), "Remove event should not have fired"); + ok(!hasFired("click"), "Click event should not have fired"); // Drag an item from the first list to the second, connected list fired = {}; - $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 150 }); - ok(hasFired('change'), '150px drag, change event should have fired'); - ok(hasFired('receive'), 'Receive event should have fired'); - ok(hasFired('remove'), 'Remove event should have fired'); - ok(!hasFired('click'), 'Click event should not have fired'); + $("#sortable li:eq(0)").simulate("drag", { dx: 0, dy: 150 }); + ok(hasFired("change"), "150px drag, change event should have fired"); + ok(hasFired("receive"), "Receive event should have fired"); + ok(hasFired("remove"), "Remove event should have fired"); + ok(!hasFired("click"), "Click event should not have fired"); }); /* diff --git a/tests/unit/sortable/sortable_methods.js b/tests/unit/sortable/sortable_methods.js index de32e2f5d..07a7bc77d 100644 --- a/tests/unit/sortable/sortable_methods.js +++ b/tests/unit/sortable/sortable_methods.js @@ -8,36 +8,36 @@ module("sortable: methods"); test("init", function() { expect(5); - $("<div></div>").appendTo('body').sortable().remove(); - ok(true, '.sortable() called on element'); + $("<div></div>").appendTo("body").sortable().remove(); + ok(true, ".sortable() called on element"); $([]).sortable(); - ok(true, '.sortable() called on empty collection'); + ok(true, ".sortable() called on empty collection"); $("<div></div>").sortable(); - ok(true, '.sortable() called on disconnected DOMElement'); + ok(true, ".sortable() called on disconnected DOMElement"); $("<div></div>").sortable().sortable("option", "foo"); - ok(true, 'arbitrary option getter after init'); + ok(true, "arbitrary option getter after init"); $("<div></div>").sortable().sortable("option", "foo", "bar"); - ok(true, 'arbitrary option setter after init'); + ok(true, "arbitrary option setter after init"); }); test("destroy", function() { expect(4); - $("<div></div>").appendTo('body').sortable().sortable("destroy").remove(); - ok(true, '.sortable("destroy") called on element'); + $("<div></div>").appendTo("body").sortable().sortable("destroy").remove(); + ok(true, ".sortable('destroy') called on element"); $([]).sortable().sortable("destroy"); - ok(true, '.sortable("destroy") called on empty collection'); + ok(true, ".sortable('destroy') called on empty collection"); $("<div></div>").sortable().sortable("destroy"); - ok(true, '.sortable("destroy") called on disconnected DOMElement'); + ok(true, ".sortable('destroy') called on disconnected DOMElement"); - var expected = $('<div></div>').sortable(), - actual = expected.sortable('destroy'); - equal(actual, expected, 'destroy is chainable'); + var expected = $("<div></div>").sortable(), + actual = expected.sortable("destroy"); + equal(actual, expected, "destroy is chainable"); }); test("enable", function() { @@ -47,7 +47,7 @@ test("enable", function() { el = $("#sortable").sortable({ disabled: true }); - TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, '.sortable({ disabled: true })'); + TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, ".sortable({ disabled: true })"); el.sortable("enable"); equal(el.sortable("option", "disabled"), false, "disabled option getter"); @@ -57,11 +57,11 @@ test("enable", function() { el.sortable("option", "disabled", false); equal(el.sortable("option", "disabled"), false, "disabled option setter"); - TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, '.sortable("option", "disabled", false)'); + TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, ".sortable('option', 'disabled', false)"); - expected = $('<div></div>').sortable(), - actual = expected.sortable('enable'); - equal(actual, expected, 'enable is chainable'); + expected = $("<div></div>").sortable(), + actual = expected.sortable("enable"); + equal(actual, expected, "enable is chainable"); }); test("disable", function() { @@ -70,23 +70,23 @@ test("disable", function() { var el, actual, expected; el = $("#sortable").sortable({ disabled: false }); - TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, '.sortable({ disabled: false })'); + TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, ".sortable({ disabled: false })"); el.sortable("disable"); - TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, 'disabled.sortable getter'); + TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, "disabled.sortable getter"); el.sortable("destroy"); el.sortable({ disabled: false }); - TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, '.sortable({ disabled: false })'); + TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, ".sortable({ disabled: false })"); el.sortable("option", "disabled", true); equal(el.sortable("option", "disabled"), true, "disabled option setter"); ok(el.sortable("widget").is(":not(.ui-state-disabled)"), "sortable element does not get ui-state-disabled since it's an interaction"); - TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, '.sortable("option", "disabled", true)'); + TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, ".sortable('option', 'disabled', true)"); - expected = $('<div></div>').sortable(), - actual = expected.sortable('disable'); - equal(actual, expected, 'disable is chainable'); + expected = $("<div></div>").sortable(), + actual = expected.sortable("disable"); + equal(actual, expected, "disable is chainable"); }); })(jQuery); |