aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/widget/widget_core.js
diff options
context:
space:
mode:
authorJyoti Deka <dekajp@gmail.com>2013-10-14 23:43:06 -0400
committerJörn Zaefferer <joern.zaefferer@gmail.com>2013-10-16 22:22:28 +0200
commitecde7cd41a59e9c3ff07f56baeeaec2147cca779 (patch)
treecdb3b636f816fa51c16b392b28ed11c9caa5ed91 /tests/unit/widget/widget_core.js
parent9620812986a090668c44d48a7c85a46b580a89df (diff)
downloadjquery-ui-ecde7cd41a59e9c3ff07f56baeeaec2147cca779.tar.gz
jquery-ui-ecde7cd41a59e9c3ff07f56baeeaec2147cca779.zip
Widget: option-method should work as getter only when argument length is 1. Fixes #9601 - Widget: calling _setOption with undefined as 3rd argument makes it a getter
Diffstat (limited to 'tests/unit/widget/widget_core.js')
-rw-r--r--tests/unit/widget/widget_core.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js
index ec4c85874..3cda48df9 100644
--- a/tests/unit/widget/widget_core.js
+++ b/tests/unit/widget/widget_core.js
@@ -535,7 +535,7 @@ test( ".option() - delegate to ._setOptions()", function() {
});
test( ".option() - delegate to ._setOption()", function() {
- expect( 2 );
+ expect( 3 );
var div,
calls = [];
$.widget( "ui.testWidget", {
@@ -555,6 +555,11 @@ test( ".option() - delegate to ._setOption()", function() {
"_setOption called for single option" );
calls = [];
+ div.testWidget( "option", "foo", undefined );
+ deepEqual( calls, [{ key: "foo", val: undefined }],
+ "_setOption called for single option where value is undefined" );
+
+ calls = [];
div.testWidget( "option", {
bar: "qux",
quux: "quuux"
@@ -566,9 +571,9 @@ test( ".option() - delegate to ._setOption()", function() {
});
test( ".option() - deep option setter", function() {
- expect( 6 );
+ expect( 9 );
$.widget( "ui.testWidget", {} );
- var div = $( "<div>" ).testWidget();
+ var result, div = $( "<div>" ).testWidget();
function deepOption( from, to, msg ) {
div.testWidget( "instance" ).options.foo = from;
$.ui.testWidget.prototype._setOption = function( key, value ) {
@@ -580,6 +585,12 @@ test( ".option() - deep option setter", function() {
deepOption( { bar: "baz" }, { bar: "qux" }, "one deep" );
div.testWidget( "option", "foo.bar", "qux" );
+ deepOption( { bar: "baz" }, { bar: undefined }, "one deep - value = undefined" );
+
+ result = div.testWidget( "option", "foo.bar", undefined );
+
+ deepEqual ( result, div, "option should return widget on successful set operation" );
+
deepOption( null, { bar: "baz" }, "null" );
div.testWidget( "option", "foo.bar", "baz" );