diff options
author | Scott González <scott.gonzalez@gmail.com> | 2011-01-23 19:58:31 -0500 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2011-01-23 19:58:31 -0500 |
commit | bc71499a505d0932668b4ae75603cd9dbfd4a2ac (patch) | |
tree | c31cffd36e706f0194945d03089c575082988cfe /tests | |
parent | 29bfb86ce2e192dae456bf15655c25cb469ad977 (diff) | |
download | jquery-ui-bc71499a505d0932668b4ae75603cd9dbfd4a2ac.tar.gz jquery-ui-bc71499a505d0932668b4ae75603cd9dbfd4a2ac.zip |
Widget: Added tests for defaultElement and element normalization between jQuery objects, elements and selectors.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/widget/widget_core.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js index 388e078b0..189b75368 100644 --- a/tests/unit/widget/widget_core.js +++ b/tests/unit/widget/widget_core.js @@ -26,6 +26,47 @@ test( "widget creation", function() { "option method copied over from base widget" ); }); +test( "element normalization", function() { + expect( 10 ); + var elem; + $.widget( "ui.testWidget", {} ); + + $.ui.testWidget.prototype._create = function() { + ok( this.element.is( "div" ), "generated div" ); + same( this.element.data( "testWidget" ), this, "intance stored in .data()" ); + }; + $.ui.testWidget(); + + $.ui.testWidget.prototype.defaultElement = "<span data-test='pass'>"; + $.ui.testWidget.prototype._create = function() { + ok( this.element.is( "span[data-test=pass]" ), "generated span with properties" ); + same( this.element.data( "testWidget" ), this, "instace stored in .data()" ); + }; + $.ui.testWidget(); + + elem = $( "<input>" ); + $.ui.testWidget.prototype._create = function() { + same( this.element[ 0 ], elem[ 0 ], "from element" ); + same( elem.data( "testWidget" ), this, "instace stored in .data()" ); + }; + $.ui.testWidget( {}, elem[ 0 ] ); + + elem = $( "<div>" ); + $.ui.testWidget.prototype._create = function() { + same( this.element[ 0 ], elem[ 0 ], "from jQuery object" ); + same( elem.data( "testWidget" ), this, "instace stored in .data()" ); + }; + $.ui.testWidget( {}, elem ); + + elem = $( "<div id='element-normalization-selector'></div>" ) + .appendTo( "#main" ); + $.ui.testWidget.prototype._create = function() { + same( this.element[ 0 ], elem[ 0 ], "from selector" ); + same( elem.data( "testWidget" ), this, "instace stored in .data()" ); + }; + $.ui.testWidget( {}, "#element-normalization-selector" ); +}); + test( "jQuery usage", function() { expect( 11 ); |