aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/widget/widget_core.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/widget/widget_core.js')
-rw-r--r--tests/unit/widget/widget_core.js51
1 files changed, 42 insertions, 9 deletions
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js
index 18b93d92e..8102b1f4f 100644
--- a/tests/unit/widget/widget_core.js
+++ b/tests/unit/widget/widget_core.js
@@ -13,18 +13,23 @@ TestHelpers.testJshint( "widget" );
test( "widget creation", function() {
expect( 5 );
- var myPrototype = {
- _create: function() {},
- creationTest: function() {}
- };
+ var method,
+ myPrototype = {
+ _create: function() {
+ equal( method, "_create", "create function is copied over" );
+ },
+ creationTest: function() {
+ equal( method, "creationTest", "random function is copied over" );
+ }
+ };
$.widget( "ui.testWidget", myPrototype );
ok( $.isFunction( $.ui.testWidget ), "constructor was created" );
- equal( "object", typeof $.ui.testWidget.prototype, "prototype was created" );
- equal( $.ui.testWidget.prototype._create, myPrototype._create,
- "create function is copied over" );
- equal( $.ui.testWidget.prototype.creationTest, myPrototype.creationTest,
- "random function is copied over" );
+ equal( typeof $.ui.testWidget.prototype, "object", "prototype was created" );
+ method = "_create";
+ $.ui.testWidget.prototype._create();
+ method = "creationTest";
+ $.ui.testWidget.prototype.creationTest();
equal( $.ui.testWidget.prototype.option, $.Widget.prototype.option,
"option method copied over from base widget" );
});
@@ -1324,6 +1329,34 @@ test( "redefine - widgetEventPrefix", function() {
});
+test( "mixins", function() {
+ expect( 2 );
+
+ var mixin = {
+ method: function() {
+ return "mixed " + this._super();
+ }
+ };
+
+ $.widget( "ui.testWidget1", {
+ method: function() {
+ return "testWidget1";
+ }
+ });
+ $.widget( "ui.testWidget2", {
+ method: function() {
+ return "testWidget2";
+ }
+ });
+ $.widget( "ui.testWidget1", $.ui.testWidget1, mixin );
+ $.widget( "ui.testWidget2", $.ui.testWidget2, mixin );
+
+ equal( $( "<div>" ).testWidget1().testWidget1( "method" ),
+ "mixed testWidget1", "testWidget1 mixin successful" );
+ equal( $( "<div>" ).testWidget2().testWidget2( "method" ),
+ "mixed testWidget2", "testWidget2 mixin successful" );
+});
+
asyncTest( "_delay", function() {
expect( 6 );
var order = 0,