diff options
author | Scott González <scott.gonzalez@gmail.com> | 2011-06-09 09:47:18 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2011-06-09 09:47:18 -0400 |
commit | 3dea8f1786e07b17458f4fecff1dbb8b04f79a2d (patch) | |
tree | ec00489ecbd19376c729e46e0817b53420cca57b /tests | |
parent | 7cd3d0a99ec4c92671aa637d322a41300786d879 (diff) | |
download | jquery-ui-3dea8f1786e07b17458f4fecff1dbb8b04f79a2d.tar.gz jquery-ui-3dea8f1786e07b17458f4fecff1dbb8b04f79a2d.zip |
Widget: Added ability to get deep options. Fixes #7459 - Widget: Extend .option() to get partial nested options.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/widget/widget_core.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js index b1c27b104..40fd97ba5 100644 --- a/tests/unit/widget/widget_core.js +++ b/tests/unit/widget/widget_core.js @@ -413,6 +413,7 @@ test( ".option() - getter", function() { qux: [ "quux", "quuux" ] }); + same( div.testWidget( "option", "x" ), null, "non-existent option" ); same( div.testWidget( "option", "foo"), "bar", "single option - string" ); same( div.testWidget( "option", "baz"), 5, "single option - number" ); same( div.testWidget( "option", "qux"), [ "quux", "quuux" ], @@ -431,6 +432,24 @@ test( ".option() - getter", function() { "modifying returned options hash does not modify plugin instance" ); }); +test( ".option() - deep option getter", function() { + $.widget( "ui.testWidget", {} ); + var div = $( "<div>" ).testWidget({ + foo: { + bar: "baz", + qux: { + quux: "xyzzy" + } + } + }); + equal( div.testWidget( "option", "foo.bar" ), "baz", "one level deep - string" ); + deepEqual( div.testWidget( "option", "foo.qux" ), { quux: "xyzzy" }, + "one level deep - object" ); + equal( div.testWidget( "option", "foo.qux.quux" ), "xyzzy", "two levels deep - string" ); + equal( div.testWidget( "option", "x.y" ), null, "top level non-existent" ); + equal( div.testWidget( "option", "foo.x.y" ), null, "one level deep - non-existent" ); +}); + test( ".option() - delegate to ._setOptions()", function() { var calls = []; $.widget( "ui.testWidget", { |