diff options
author | Scott González <scott.gonzalez@gmail.com> | 2010-07-15 10:26:00 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2010-07-15 10:27:21 -0400 |
commit | f24bc0fb1f63e7f5e38014d7191a4fe69d4179f0 (patch) | |
tree | 567952cea5b7b2d347c87cd1ab8d05ea8f1206f4 /tests/unit | |
parent | 06f721b74f94272baf5da96133e961f5600f5a90 (diff) | |
download | jquery-ui-f24bc0fb1f63e7f5e38014d7191a4fe69d4179f0.tar.gz jquery-ui-f24bc0fb1f63e7f5e38014d7191a4fe69d4179f0.zip |
Widget: Deep extend options when creating a new plugin. Fixes #5830 - Widget: Using inheritance overwrites the base classes options.
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/widget/widget.html | 3 | ||||
-rw-r--r-- | tests/unit/widget/widget_core.js (renamed from tests/unit/widget/widget.js) | 0 | ||||
-rw-r--r-- | tests/unit/widget/widget_tickets.js | 46 |
3 files changed, 48 insertions, 1 deletions
diff --git a/tests/unit/widget/widget.html b/tests/unit/widget/widget.html index c3c3b0875..9e02880c4 100644 --- a/tests/unit/widget/widget.html +++ b/tests/unit/widget/widget.html @@ -13,7 +13,8 @@ <script type="text/javascript" src="../../jquery.simulate.js"></script> <script type="text/javascript" src="../testsuite.js"></script> - <script type="text/javascript" src="widget.js"></script> + <script type="text/javascript" src="widget_core.js"></script> + <script type="text/javascript" src="widget_tickets.js"></script> </head> <body> diff --git a/tests/unit/widget/widget.js b/tests/unit/widget/widget_core.js index 3c870f1fe..3c870f1fe 100644 --- a/tests/unit/widget/widget.js +++ b/tests/unit/widget/widget_core.js diff --git a/tests/unit/widget/widget_tickets.js b/tests/unit/widget/widget_tickets.js new file mode 100644 index 000000000..47303dc9c --- /dev/null +++ b/tests/unit/widget/widget_tickets.js @@ -0,0 +1,46 @@ +/* + * widget unit tests + */ +(function($) { + +module('widget: tickets'); + +test('#5830 - Widget: Using inheritance overwrites the base classes options', function() { + $.widget( "ui.testWidgetBase", { + options: { + obj: { + key1: "foo", + key2: "bar" + }, + arr: [ "testing" ] + } + }); + + $.widget( "ui.testWidgetExtension", $.ui.testWidgetBase, { + options: { + obj: { + key1: "baz" + }, + arr: [ "alpha", "beta" ] + } + }); + + same( $.ui.testWidgetBase.prototype.options.obj, { + key1: "foo", + key2: "bar" + }, "base class option object not overridden"); + same( $.ui.testWidgetBase.prototype.options.arr, [ "testing" ], + "base class option array not overridden"); + + same( $.ui.testWidgetExtension.prototype.options.obj, { + key1: "baz", + key2: "bar" + }, "extension class option object extends base"); + same( $.ui.testWidgetExtension.prototype.options.arr, [ "alpha", "beta" ], + "extension class option array overwrites base"); + + delete $.ui.testWidgetBase; + delete $.ui.testWidgetExtension; +}); + +})(jQuery); |