aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-03-24 09:21:53 -0400
committerScott González <scott.gonzalez@gmail.com>2011-03-24 09:21:53 -0400
commit6fc98deef03b91b0ea2ed51be2708bdd2c61d479 (patch)
tree95c28d5127688df58fd140e06a2cc45067d845ad /tests/unit
parenta2015497fc9ac32fb75e414a4bc644de05ed0c1c (diff)
downloadjquery-ui-6fc98deef03b91b0ea2ed51be2708bdd2c61d479.tar.gz
jquery-ui-6fc98deef03b91b0ea2ed51be2708bdd2c61d479.zip
Widget: Allow setting individual properties of deep options. Fixes #7035 - Widget: Extend .option() to set partial nested options.
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/widget/widget_core.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js
index 300acd0d8..34f5ef67f 100644
--- a/tests/unit/widget/widget_core.js
+++ b/tests/unit/widget/widget_core.js
@@ -441,6 +441,30 @@ test( ".option() - delegate to ._setOption()", function() {
], "_setOption called with multiple options" );
});
+test( ".option() - deep option setter", function() {
+ $.widget( "ui.testWidget", {} );
+ var div = $( "<div>" ).testWidget();
+ function deepOption( from, to, msg ) {
+ div.data( "testWidget" ).options.foo = from;
+ $.ui.testWidget.prototype._setOption = function( key, value ) {
+ same( key, "foo", msg + ": key" );
+ same( value, to, msg + ": value" );
+ };
+ }
+
+ deepOption( { bar: "baz" }, { bar: "qux" }, "one deep" );
+ div.testWidget( "option", "foo.bar", "qux" );
+
+ deepOption( null, { bar: "baz" }, "null" );
+ div.testWidget( "option", "foo.bar", "baz" );
+
+ deepOption(
+ { bar: "baz", qux: { quux: "quuux" } },
+ { bar: "baz", qux: { quux: "quuux", newOpt: "newVal" } },
+ "add property" );
+ div.testWidget( "option", "foo.qux.newOpt", "newVal" );
+});
+
test( ".enable()", function() {
expect( 2 );
$.widget( "ui.testWidget", {