aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/autocomplete/autocomplete_events.js2
-rw-r--r--tests/unit/button/button_core.js14
-rw-r--r--tests/unit/datepicker/datepicker.html1
-rw-r--r--tests/unit/datepicker/datepicker_events.js5
-rw-r--r--tests/unit/datepicker/datepicker_methods.js5
-rw-r--r--tests/unit/datepicker/datepicker_tickets.js14
-rw-r--r--tests/unit/effects/effects.html73
-rw-r--r--tests/unit/effects/effects_core.js110
-rw-r--r--tests/unit/index.html5
-rw-r--r--tests/unit/tabs/tabs.html10
-rw-r--r--tests/unit/tabs/tabs_deprecated.html10
-rw-r--r--tests/unit/tabs/tabs_deprecated.js58
-rw-r--r--tests/unit/tabs/tabs_events.js96
-rw-r--r--tests/unit/tabs/tabs_methods.js89
-rw-r--r--tests/unit/widget/widget.html1
-rw-r--r--tests/unit/widget/widget_extend.js104
16 files changed, 526 insertions, 71 deletions
diff --git a/tests/unit/autocomplete/autocomplete_events.js b/tests/unit/autocomplete/autocomplete_events.js
index eb009064c..c884733d6 100644
--- a/tests/unit/autocomplete/autocomplete_events.js
+++ b/tests/unit/autocomplete/autocomplete_events.js
@@ -203,6 +203,7 @@ test("cancel select", function() {
}, 50);
});
+/* TODO previous fix broke more than it fixed, disabling this for now - messed up regular menu select event
test("blur without selection", function() {
expect(1);
var ac = $("#autocomplete").autocomplete({
@@ -218,5 +219,6 @@ test("blur without selection", function() {
start();
}, 50);
});
+*/
})(jQuery);
diff --git a/tests/unit/button/button_core.js b/tests/unit/button/button_core.js
index 5b30aa860..692c40320 100644
--- a/tests/unit/button/button_core.js
+++ b/tests/unit/button/button_core.js
@@ -67,4 +67,18 @@ test("buttonset", function() {
ok( set.children("label:eq(2)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") );
});
+test("buttonset (rtl)", function() {
+ var parent = $("#radio1").parent();
+ // Set to rtl
+ parent.attr("dir", "rtl");
+
+ var set = $("#radio1").buttonset();
+ ok( set.is(".ui-buttonset") );
+ same( set.children(".ui-button").length, 3 );
+ same( set.children("input:radio.ui-helper-hidden-accessible").length, 3 );
+ ok( set.children("label:eq(0)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") );
+ ok( set.children("label:eq(1)").is(".ui-button:not(.ui-corner-all)") );
+ ok( set.children("label:eq(2)").is(".ui-button.ui-corner-left:not(.ui-corner-all)") );
+});
+
})(jQuery);
diff --git a/tests/unit/datepicker/datepicker.html b/tests/unit/datepicker/datepicker.html
index fa346c6c9..d0c2c8c8c 100644
--- a/tests/unit/datepicker/datepicker.html
+++ b/tests/unit/datepicker/datepicker.html
@@ -49,6 +49,7 @@
<div id="qunit-fixture">
<p><input type="text" id="inp"/><input type="text" id="alt"/><div id="inl"></div></p>
+ <p><input type="text" id="inp2"/></p>
</div>
</body>
diff --git a/tests/unit/datepicker/datepicker_events.js b/tests/unit/datepicker/datepicker_events.js
index 84ca2f98e..bf48c9c8a 100644
--- a/tests/unit/datepicker/datepicker_events.js
+++ b/tests/unit/datepicker/datepicker_events.js
@@ -112,6 +112,11 @@ test('events', function() {
inp.val('02/04/2008').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_END});
equals(selectedDate, '', 'Callback close date - ctrl+end');
+
+ var inp2 = init('#inp2');
+ inp2.datepicker().datepicker('option', {onClose: callback}).datepicker('show');
+ inp.datepicker('show');
+ equals(selectedThis, inp2[0], 'Callback close this');
});
})(jQuery);
diff --git a/tests/unit/datepicker/datepicker_methods.js b/tests/unit/datepicker/datepicker_methods.js
index 8d078f099..7ef977604 100644
--- a/tests/unit/datepicker/datepicker_methods.js
+++ b/tests/unit/datepicker/datepicker_methods.js
@@ -102,16 +102,19 @@ test('enableDisable', function() {
ok(inp.next('img').css('opacity') == 1, 'Enable/disable image - image now enabled');
inp.datepicker('destroy');
// Inline
- var inl = init('#inl');
+ var inl = init('#inl', {changeYear: true});
var 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').attr('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').attr('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').attr('disabled'), 'Enable/disable inline - form element enabled');
inl.datepicker('destroy');
});
diff --git a/tests/unit/datepicker/datepicker_tickets.js b/tests/unit/datepicker/datepicker_tickets.js
index 7e6dc5f00..d5249f905 100644
--- a/tests/unit/datepicker/datepicker_tickets.js
+++ b/tests/unit/datepicker/datepicker_tickets.js
@@ -24,4 +24,18 @@ test('beforeShowDay-getDate', function() {
inp.datepicker('hide');
});
+test('Ticket 6827: formatDate day of year calculation is wrong during day lights savings time', function(){
+ var time = $.datepicker.formatDate("oo", new Date("2010/03/30 12:00:00 CDT"));
+ equals(time, "089");
+});
+
+test('Ticket #7244: date parser does not fail when too many numbers are passed into the date function', function() {
+ expect(1);
+ try{
+ var date = $.datepicker.parseDate('dd/mm/yy', '18/04/19881');
+ }catch(e){
+ ok("invalid date detected");
+ }
+});
+
})(jQuery);
diff --git a/tests/unit/effects/effects.html b/tests/unit/effects/effects.html
new file mode 100644
index 000000000..0879a98b2
--- /dev/null
+++ b/tests/unit/effects/effects.html
@@ -0,0 +1,73 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>jQuery UI Core Test Suite</title>
+
+ <script src="../../../jquery-1.5.1.js"></script>
+ <script>
+ $.uiBackCompat = false;
+ </script>
+ <script src="../../../ui/jquery.effects.core.js"></script>
+ <script src="../../../ui/jquery.effects.blind.js"></script>
+ <script src="../../../ui/jquery.effects.bounce.js"></script>
+ <script src="../../../ui/jquery.effects.clip.js"></script>
+ <script src="../../../ui/jquery.effects.drop.js"></script>
+ <script src="../../../ui/jquery.effects.explode.js"></script>
+ <script src="../../../ui/jquery.effects.fade.js"></script>
+ <script src="../../../ui/jquery.effects.fold.js"></script>
+ <script src="../../../ui/jquery.effects.highlight.js"></script>
+ <script src="../../../ui/jquery.effects.pulsate.js"></script>
+ <script src="../../../ui/jquery.effects.scale.js"></script>
+ <script src="../../../ui/jquery.effects.shake.js"></script>
+ <script src="../../../ui/jquery.effects.slide.js"></script>
+ <script src="../../../ui/jquery.effects.transfer.js"></script>
+
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
+ <script src="effects_core.js"></script>
+
+ <script src="../swarminject.js"></script>
+
+ <style type="text/css">
+ .hidden {
+ display: none;
+ }
+ .test {
+ background: #000;
+ border: 0;
+ }
+ .testAddBorder {
+ border: 10px solid #000;
+ }
+ .testChangeBackground {
+ background: #fff;
+ }
+ .test h2 {
+ font-size: 10px;
+ }
+ .testChildren h2 {
+ font-size: 20px;
+ }
+ </style>
+</head>
+<body>
+
+<h1 id="qunit-header">jQuery UI Effects Test Suite</h1>
+<h2 id="qunit-banner"></h2>
+<div id="qunit-testrunner-toolbar"></div>
+<h2 id="qunit-userAgent"></h2>
+<ol id="qunit-tests">
+</ol>
+
+<div id="qunit-fixture">
+ <div class="hidden test"></div>
+ <div class="animateClass test">
+ <h2>Child Element Test</h2>
+ </div>
+</div>
+
+</body>
+</html>
diff --git a/tests/unit/effects/effects_core.js b/tests/unit/effects/effects_core.js
new file mode 100644
index 000000000..8d2e8f8df
--- /dev/null
+++ b/tests/unit/effects/effects_core.js
@@ -0,0 +1,110 @@
+(function($) {
+
+function present( value, array, message ) {
+ QUnit.push( jQuery.inArray( value, array ) !== -1 , value, array, message );
+}
+
+function notPresent( value, array, message ) {
+ QUnit.push( jQuery.inArray( value, array ) === -1 , value, array, message );
+}
+
+// minDuration is used for "short" animate tests where we are only concerned about the final
+var minDuration = 15,
+
+ // duration is used for "long" animates where we plan on testing properties during animation
+ duration = 200,
+
+ // mid is used for testing in the "middle" of the "duration" animations
+ mid = duration / 2;
+
+module( "effects.core" );
+
+$.each( $.effects.effect, function( effect ) {
+ if ( effect === "transfer" ) {
+ return;
+ }
+ module( "effect."+effect );
+ asyncTest( "show/hide", function() {
+ var hidden = $( "div.hidden" );
+ expect( 8 );
+
+ var count = 0,
+ test = 0;
+
+ function queueTest( fn ) {
+ count++;
+ var point = count;
+ return function( next ) {
+ test++;
+ equal( point, test, "Queue function fired in order" );
+ if ( fn ) {
+ fn();
+ } else {
+ setTimeout( next, minDuration );
+ }
+ };
+ }
+
+ hidden.queue( queueTest() ).show( effect, minDuration, queueTest(function() {
+ equal( hidden.css("display"), "block", "Hidden is shown after .show(\"" +effect+ "\", time)" );
+ })).queue( queueTest() ).hide( effect, minDuration, queueTest(function() {
+ equal( hidden.css("display"), "none", "Back to hidden after .hide(\"" +effect+ "\", time)" );
+ })).queue( queueTest(function(next) {
+ deepEqual( hidden.queue(), ["inprogress"], "Only the inprogress sentinel remains");
+ start();
+ }));
+ });
+});
+
+module("animateClass");
+
+asyncTest( "animateClass works with borderStyle", function() {
+ var test = $("div.animateClass"),
+ count = 0;
+ expect(3);
+ test.toggleClass("testAddBorder", minDuration, function() {
+ test.toggleClass("testAddBorder", minDuration, function() {
+ equal( test.css("borderLeftStyle"), "none", "None border set" );
+ start();
+ });
+ equal( test.css("borderLeftStyle"), "solid", "None border not immedately set" );
+ });
+ equal( test.css("borderLeftStyle"), "solid", "Solid border immedately set" );
+});
+
+asyncTest( "animateClass works with colors", function() {
+ var test = $("div.animateClass"),
+ count = 0;
+ expect(2);
+ test.toggleClass("testChangeBackground", duration, function() {
+ present( test.css("backgroundColor"), [ "#ffffff", "rgb(255, 255, 255)" ], "Color is final" );
+ start();
+ });
+ setTimeout(function() {
+ var color = test.css("backgroundColor");
+ notPresent( color, [ "#000000", "#ffffff", "rgb(0, 0, 0)", "rgb(255,255,255)" ],
+ "Color is not endpoints in middle." );
+ }, mid);
+});
+
+asyncTest( "animateClass works with children", function() {
+ var test = $("div.animateClass"),
+ h2 = test.find("h2");
+
+ expect(4);
+ test.toggleClass("testChildren", { children: true, duration: duration, complete: function() {
+ equal( h2.css("fontSize"), "20px", "Text size is final during complete");
+ test.toggleClass("testChildren", duration, function() {
+ equal( h2.css("fontSize"), "10px", "Text size revertted after class removed");
+ start();
+ });
+ setTimeout(function() {
+ equal( h2.css("fontSize"), "20px", "Text size unchanged with children: undefined" );
+ }, mid);
+ }});
+ setTimeout(function() {
+ notPresent( h2.css("fontSize"), ["10px","20px"], "Font size is neither endpoint when in middle.");
+ }, mid);
+});
+
+})(jQuery);
diff --git a/tests/unit/index.html b/tests/unit/index.html
index a677023dc..5282d3f27 100644
--- a/tests/unit/index.html
+++ b/tests/unit/index.html
@@ -59,6 +59,11 @@
<li><a href="position/position.html">Position</a></li>
</ul>
+<h2>Effects</h2>
+<ul>
+ <li><a href="effects/effects.html">Effects</a></li>
+</ul>
+
</body>
</html>
diff --git a/tests/unit/tabs/tabs.html b/tests/unit/tabs/tabs.html
index 34ec28bc4..60f5e972e 100644
--- a/tests/unit/tabs/tabs.html
+++ b/tests/unit/tabs/tabs.html
@@ -81,16 +81,6 @@
same( actual, expected );
}
</script>
- <script>
- // disable this stale testsuite for testswarm only
- var url = window.location.search;
- url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) );
- if ( url && url.indexOf("http") == 0 ) {
- // reset config to kill previous tests; make sure testsuite.js is loaded afterwards to init the testswarm script
- QUnit.init();
- test("tabs", function() { ok(true, "disabled tabs testsuite"); });
- }
- </script>
<script src="../swarminject.js"></script>
</head>
<body>
diff --git a/tests/unit/tabs/tabs_deprecated.html b/tests/unit/tabs/tabs_deprecated.html
index 89d08f4d0..ed6518be3 100644
--- a/tests/unit/tabs/tabs_deprecated.html
+++ b/tests/unit/tabs/tabs_deprecated.html
@@ -80,16 +80,6 @@
same( actual, expected );
}
</script>
- <script>
- // disable this stale testsuite for testswarm only
- var url = window.location.search;
- url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) );
- if ( url && url.indexOf("http") == 0 ) {
- // reset config to kill previous tests; make sure testsuite.js is loaded afterwards to init the testswarm script
- QUnit.init();
- test("tabs", function() { ok(true, "disabled tabs testsuite"); });
- }
- </script>
<script src="../swarminject.js"></script>
</head>
<body>
diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js
index 4b50df405..1323c774a 100644
--- a/tests/unit/tabs/tabs_deprecated.js
+++ b/tests/unit/tabs/tabs_deprecated.js
@@ -35,7 +35,7 @@ asyncTest( "ajaxOptions", function() {
}
});
element.one( "tabsload", function( event, ui ) {
- equals( ui.panel.html(), "test" );
+ equals( $( ui.panel ).html(), "test" );
start();
});
element.tabs( "option", "active", 2 );
@@ -220,6 +220,62 @@ test( "selected", function() {
module( "tabs (deprecated): events" );
+asyncTest( "load", function() {
+ expect( 15 );
+
+ var tab, panelId, panel,
+ element = $( "#tabs2" );
+
+ // init
+ element.one( "tabsload", function( event, ui ) {
+ tab = element.find( ".ui-tabs-nav a" ).eq( 2 );
+ panelId = tab.attr( "aria-controls" );
+ panel = $( "#" + panelId );
+
+ ok( !( "originalEvent" in event ), "originalEvent" );
+ strictEqual( ui.tab, tab[ 0 ], "tab" );
+ strictEqual( ui.panel, panel[ 0 ], "panel" );
+ equals( $( ui.panel ).find( "p" ).length, 1, "panel html" );
+ tabs_state( element, 0, 0, 1, 0, 0 );
+ tabsload1();
+ });
+ element.tabs({ active: 2 });
+
+ function tabsload1() {
+ // .option()
+ element.one( "tabsload", function( event, ui ) {
+ tab = element.find( ".ui-tabs-nav a" ).eq( 3 );
+ panelId = tab.attr( "aria-controls" );
+ panel = $( "#" + panelId );
+
+ ok( !( "originalEvent" in event ), "originalEvent" );
+ strictEqual( ui.tab, tab[ 0 ], "tab" );
+ strictEqual( ui.panel, panel[ 0 ], "panel" );
+ equals( $( ui.panel ).find( "p" ).length, 1, "panel html" );
+ tabs_state( element, 0, 0, 0, 1, 0 );
+ tabsload2();
+ });
+ element.tabs( "option", "active", 3 );
+ }
+
+ function tabsload2() {
+ // click, change panel content
+ element.one( "tabsload", function( event, ui ) {
+ tab = element.find( ".ui-tabs-nav a" ).eq( 4 );
+ panelId = tab.attr( "aria-controls" );
+ panel = $( "#" + panelId );
+
+ equals( event.originalEvent.type, "click", "originalEvent" );
+ strictEqual( ui.tab, tab[ 0 ], "tab" );
+ strictEqual( ui.panel, panel[ 0 ], "panel" );
+ equals( $( ui.panel ).find( "p" ).length, 1, "panel html" );
+ tabs_state( element, 0, 0, 0, 0, 1 );
+ start();
+ });
+ element.find( ".ui-tabs-nav a" ).eq( 4 ).click();
+ }
+});
+
test( "enable", function() {
expect( 3 );
diff --git a/tests/unit/tabs/tabs_events.js b/tests/unit/tabs/tabs_events.js
index 2fabaafca..12c9bb87b 100644
--- a/tests/unit/tabs/tabs_events.js
+++ b/tests/unit/tabs/tabs_events.js
@@ -209,66 +209,68 @@ test( "beforeLoad", function() {
equals( panel.html(), "<p>testing</p>", "panel html after" );
});
-asyncTest( "load", function() {
- expect( 21 );
+if ( $.uiBackCompat === false ) {
+ asyncTest( "load", function() {
+ expect( 21 );
- var tab, panelId, panel,
- element = $( "#tabs2" );
-
- // init
- element.one( "tabsload", function( event, ui ) {
- tab = element.find( ".ui-tabs-nav a" ).eq( 2 );
- panelId = tab.attr( "aria-controls" );
- panel = $( "#" + panelId );
-
- ok( !( "originalEvent" in event ), "originalEvent" );
- equals( ui.tab.size(), 1, "tab size" );
- strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equals( ui.panel.size(), 1, "panel size" );
- strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
- equals( ui.panel.find( "p" ).length, 1, "panel html" );
- tabs_state( element, 0, 0, 1, 0, 0 );
- tabsload1();
- });
- element.tabs({ active: 2 });
+ var tab, panelId, panel,
+ element = $( "#tabs2" );
- function tabsload1() {
- // .option()
+ // init
element.one( "tabsload", function( event, ui ) {
- tab = element.find( ".ui-tabs-nav a" ).eq( 3 );
+ tab = element.find( ".ui-tabs-nav a" ).eq( 2 );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );
-
+
ok( !( "originalEvent" in event ), "originalEvent" );
equals( ui.tab.size(), 1, "tab size" );
strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
equals( ui.panel.size(), 1, "panel size" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
equals( ui.panel.find( "p" ).length, 1, "panel html" );
- tabs_state( element, 0, 0, 0, 1, 0 );
- tabsload2();
+ tabs_state( element, 0, 0, 1, 0, 0 );
+ tabsload1();
});
- element.tabs( "option", "active", 3 );
- }
+ element.tabs({ active: 2 });
- function tabsload2() {
- // click, change panel content
- element.one( "tabsload", function( event, ui ) {
- tab = element.find( ".ui-tabs-nav a" ).eq( 4 );
- panelId = tab.attr( "aria-controls" );
- panel = $( "#" + panelId );
+ function tabsload1() {
+ // .option()
+ element.one( "tabsload", function( event, ui ) {
+ tab = element.find( ".ui-tabs-nav a" ).eq( 3 );
+ panelId = tab.attr( "aria-controls" );
+ panel = $( "#" + panelId );
- equals( event.originalEvent.type, "click", "originalEvent" );
- equals( ui.tab.size(), 1, "tab size" );
- strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equals( ui.panel.size(), 1, "panel size" );
- strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
- equals( ui.panel.find( "p" ).length, 1, "panel html" );
- tabs_state( element, 0, 0, 0, 0, 1 );
- start();
- });
- element.find( ".ui-tabs-nav a" ).eq( 4 ).click();
- }
-});
+ ok( !( "originalEvent" in event ), "originalEvent" );
+ equals( ui.tab.size(), 1, "tab size" );
+ strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
+ equals( ui.panel.size(), 1, "panel size" );
+ strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
+ equals( ui.panel.find( "p" ).length, 1, "panel html" );
+ tabs_state( element, 0, 0, 0, 1, 0 );
+ tabsload2();
+ });
+ element.tabs( "option", "active", 3 );
+ }
+
+ function tabsload2() {
+ // click, change panel content
+ element.one( "tabsload", function( event, ui ) {
+ tab = element.find( ".ui-tabs-nav a" ).eq( 4 );
+ panelId = tab.attr( "aria-controls" );
+ panel = $( "#" + panelId );
+
+ equals( event.originalEvent.type, "click", "originalEvent" );
+ equals( ui.tab.size(), 1, "tab size" );
+ strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
+ equals( ui.panel.size(), 1, "panel size" );
+ strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
+ equals( ui.panel.find( "p" ).length, 1, "panel html" );
+ tabs_state( element, 0, 0, 0, 0, 1 );
+ start();
+ });
+ element.find( ".ui-tabs-nav a" ).eq( 4 ).click();
+ }
+ });
+}
}( jQuery ) );
diff --git a/tests/unit/tabs/tabs_methods.js b/tests/unit/tabs/tabs_methods.js
index 221b0d39d..ec21e2de7 100644
--- a/tests/unit/tabs/tabs_methods.js
+++ b/tests/unit/tabs/tabs_methods.js
@@ -145,8 +145,93 @@ test( "refresh", function() {
tabs_disabled( element, false );
});
-test('load', function() {
- ok(false, "missing test - untested code is broken code.");
+asyncTest( "load", function() {
+ expect( 30 );
+
+ var element = $( "#tabs2" ).tabs();
+
+ // load content of inactive tab
+ // useful for preloading content with custom caching
+ element.one( "tabsbeforeload", function( event, ui ) {
+ var tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
+ panelId = tab.attr( "aria-controls" ),
+ panel = $( "#" + panelId );
+
+ ok( !( "originalEvent" in event ), "originalEvent" );
+ equals( ui.tab.size(), 1, "tab size" );
+ strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
+ equals( ui.panel.size(), 1, "panel size" );
+ strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
+ tabs_state( element, 1, 0, 0, 0, 0 );
+ });
+ element.one( "tabsload", function( event, ui ) {
+ // TODO: remove wrapping in 2.0
+ var uiTab = $( ui.tab ),
+ uiPanel = $( ui.panel );
+
+ var tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
+ panelId = tab.attr( "aria-controls" ),
+ panel = $( "#" + panelId );
+
+ ok( !( "originalEvent" in event ), "originalEvent" );
+ equals( uiTab.size(), 1, "tab size" );
+ strictEqual( uiTab[ 0 ], tab[ 0 ], "tab" );
+ equals( uiPanel.size(), 1, "panel size" );
+ strictEqual( uiPanel[ 0 ], panel[ 0 ], "panel" );
+ equals( uiPanel.find( "p" ).length, 1, "panel html" );
+ tabs_state( element, 1, 0, 0, 0, 0 );
+ setTimeout( tabsload1, 1 );
+ });
+ element.tabs( "load", 3 );
+ tabs_state( element, 1, 0, 0, 0, 0 );
+
+ function tabsload1() {
+ // no need to test details of event (tested in events tests)
+ element.one( "tabsbeforeload", function() {
+ ok( true, "tabsbeforeload invoked" );
+ });
+ element.one( "tabsload", function() {
+ ok( true, "tabsload invoked" );
+ setTimeout( tabsload2, 1 );
+ });
+ element.tabs( "option", "active", 3 );
+ tabs_state( element, 0, 0, 0, 1, 0 );
+ }
+
+ function tabsload2() {
+ // reload content of active tab
+ element.one( "tabsbeforeload", function( event, ui ) {
+ var tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
+ panelId = tab.attr( "aria-controls" ),
+ panel = $( "#" + panelId );
+
+ ok( !( "originalEvent" in event ), "originalEvent" );
+ equals( ui.tab.size(), 1, "tab size" );
+ strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
+ equals( ui.panel.size(), 1, "panel size" );
+ strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
+ tabs_state( element, 0, 0, 0, 1, 0 );
+ });
+ element.one( "tabsload", function( event, ui ) {
+ // TODO: remove wrapping in 2.0
+ var uiTab = $( ui.tab ),
+ uiPanel = $( ui.panel );
+
+ var tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
+ panelId = tab.attr( "aria-controls" ),
+ panel = $( "#" + panelId );
+
+ ok( !( "originalEvent" in event ), "originalEvent" );
+ equals( uiTab.size(), 1, "tab size" );
+ strictEqual( uiTab[ 0 ], tab[ 0 ], "tab" );
+ equals( uiPanel.size(), 1, "panel size" );
+ strictEqual( uiPanel[ 0 ], panel[ 0 ], "panel" );
+ tabs_state( element, 0, 0, 0, 1, 0 );
+ start();
+ });
+ element.tabs( "load", 3 );
+ tabs_state( element, 0, 0, 0, 1, 0 );
+ }
});
}( jQuery ) );
diff --git a/tests/unit/widget/widget.html b/tests/unit/widget/widget.html
index e74abb317..183537612 100644
--- a/tests/unit/widget/widget.html
+++ b/tests/unit/widget/widget.html
@@ -14,6 +14,7 @@
<script src="../testsuite.js"></script>
<script src="widget_core.js"></script>
+ <script src="widget_extend.js"></script>
<script src="../swarminject.js"></script>
</head>
diff --git a/tests/unit/widget/widget_extend.js b/tests/unit/widget/widget_extend.js
new file mode 100644
index 000000000..fb78ecfb7
--- /dev/null
+++ b/tests/unit/widget/widget_extend.js
@@ -0,0 +1,104 @@
+test( "$.widget.extend()", function() {
+ expect( 26 );
+
+ var settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
+ options = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
+ optionsCopy = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
+ merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" },
+ deep1 = { foo: { bar: true } },
+ deep1copy = { foo: { bar: true } },
+ deep2 = { foo: { baz: true }, foo2: document },
+ deep2copy = { foo: { baz: true }, foo2: document },
+ deepmerged = { foo: { bar: true, baz: true }, foo2: document },
+ arr = [1, 2, 3],
+ nestedarray = { arr: arr },
+ ret;
+
+ $.widget.extend( settings, options );
+ deepEqual( settings, merged, "Check if extended: settings must be extended" );
+ deepEqual( options, optionsCopy, "Check if not modified: options must not be modified" );
+
+ $.widget.extend( deep1, deep2 );
+ deepEqual( deep1.foo, deepmerged.foo, "Check if foo: settings must be extended" );
+ deepEqual( deep2.foo, deep2copy.foo, "Check if not deep2: options must not be modified" );
+ equal( deep1.foo2, document, "Make sure that a deep clone was not attempted on the document" );
+
+ strictEqual( $.widget.extend({}, nestedarray).arr, arr, "Don't clone arrays" );
+ ok( $.isPlainObject( $.widget.extend({ arr: arr }, { arr: {} }).arr ), "Cloned object heve to be an plain object" );
+
+ var empty = {};
+ var optionsWithLength = { foo: { length: -1 } };
+ $.widget.extend( empty, optionsWithLength );
+ deepEqual( empty.foo, optionsWithLength.foo, "The length property must copy correctly" );
+
+ empty = {};
+ var optionsWithDate = { foo: { date: new Date } };
+ $.widget.extend( empty, optionsWithDate );
+ deepEqual( empty.foo, optionsWithDate.foo, "Dates copy correctly" );
+
+ var myKlass = function() {};
+ var customObject = new myKlass();
+ var optionsWithCustomObject = { foo: { date: customObject } };
+ empty = {};
+ $.widget.extend( empty, optionsWithCustomObject );
+ strictEqual( empty.foo.date, customObject, "Custom objects copy correctly (no methods)" );
+
+ // Makes the class a little more realistic
+ myKlass.prototype = { someMethod: function(){} };
+ empty = {};
+ $.widget.extend( empty, optionsWithCustomObject );
+ strictEqual( empty.foo.date, customObject, "Custom objects copy correctly" );
+
+ ret = $.widget.extend({ foo: 4 }, { foo: new Number(5) } );
+ equal( ret.foo, 5, "Wrapped numbers copy correctly" );
+
+ var nullUndef;
+ nullUndef = $.widget.extend( {}, options, { xnumber2: null } );
+ strictEqual( nullUndef.xnumber2, null, "Check to make sure null values are copied");
+
+ nullUndef = $.widget.extend( {}, options, { xnumber2: undefined } );
+ strictEqual( nullUndef.xnumber2, options.xnumber2, "Check to make sure undefined values are not copied");
+
+ nullUndef = $.widget.extend( {}, options, { xnumber0: null } );
+ strictEqual( nullUndef.xnumber0, null, "Check to make sure null values are inserted");
+
+ var target = {};
+ var recursive = { foo:target, bar:5 };
+ $.widget.extend( target, recursive );
+ deepEqual( target, { foo: {}, bar: 5 }, "Check to make sure a recursive obj doesn't go never-ending loop by not copying it over" );
+
+ ret = $.widget.extend( { foo: [] }, { foo: [0] } ); // 1907
+ equal( ret.foo.length, 1, "Check to make sure a value with coersion 'false' copies over when necessary to fix #1907" );
+
+ ret = $.widget.extend( { foo: "1,2,3" }, { foo: [1, 2, 3] } );
+ strictEqual( typeof ret.foo, "object", "Check to make sure values equal with coersion (but not actually equal) overwrite correctly" );
+
+ ret = $.widget.extend( { foo:"bar" }, { foo:null } );
+ strictEqual( typeof ret.foo, "object", "Make sure a null value doesn't crash with deep extend, for #1908" );
+
+ var obj = { foo:null };
+ $.widget.extend( obj, { foo:"notnull" } );
+ equal( obj.foo, "notnull", "Make sure a null value can be overwritten" );
+
+ var defaults = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
+ defaultsCopy = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
+ options1 = { xnumber2: 1, xstring2: "x" },
+ options1Copy = { xnumber2: 1, xstring2: "x" },
+ options2 = { xstring2: "xx", xxx: "newstringx" },
+ options2Copy = { xstring2: "xx", xxx: "newstringx" },
+ merged2 = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "xx", xxx: "newstringx" };
+
+ var settings = $.widget.extend( {}, defaults, options1, options2 );
+ deepEqual( settings, merged2, "Check if extended: settings must be extended" );
+ deepEqual( defaults, defaultsCopy, "Check if not modified: options1 must not be modified" );
+ deepEqual( options1, options1Copy, "Check if not modified: options1 must not be modified" );
+ deepEqual( options2, options2Copy, "Check if not modified: options2 must not be modified" );
+
+ var input = {
+ key: [ 1, 2, 3 ]
+ }
+ var output = $.widget.extend( {}, input );
+ deepEqual( input, output, "don't clone arrays" );
+ input.key[0] = 10;
+ deepEqual( input, output, "don't clone arrays" );
+});