Tizen 2.0 Release
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.2.0 / tests / unit / widget / widget_init.js
1 /*
2  * mobile widget unit tests
3  */
4 (function($){
5         var widgetInitialized = false;
6
7         module( 'jquery.mobile.widget.js' );
8
9         $( "#foo" ).live( 'pageinit', function(){
10                 // ordering sensitive here, the value has to be set after the call
11                 // so that if the widget factory says that its not yet initialized,
12                 // which is an exception, the value won't be set
13                 $( "#foo-slider" ).slider( 'refresh' );
14                 widgetInitialized = true;
15         });
16
17         test( "page is enhanced before init is fired", function() {
18                 ok( widgetInitialized );
19         });
20
21         test( "elements within an ignore container are not enhanced when ignoreContentEnabled is true ", function() {
22                 $.mobile.ignoreContentEnabled = true;
23
24                 $.mobile.collapsible.prototype.enhanceWithin( $("#ignored") );
25
26                 ok( !$( "#ignored-collapsible" ).hasClass( "ui-collapsible" ), "ignored element doesn't have ui-collapsible" );
27
28                 $.mobile.collapsible.prototype.enhanceWithin( $("#not-ignored") );
29
30                 ok( $( "#collapsible" ).hasClass( "ui-collapsible" ), "identical unignored elements are enahanced" );
31
32                 $.mobile.ignoreContentEnabled = false;
33         });
34
35         test( "siblings without ignore parent are enhanced", function() {
36                 $.mobile.ignoreContentEnabled = true;
37
38                 $.mobile.collapsible.prototype.enhanceWithin( $("#many-ignored") );
39
40                 ok( !$( "#many-ignored-collapsible" ).hasClass( "ui-collapsible" ), "sibling ignored element doesn't have ui-collapsible" );
41                 ok( $( "#many-enhanced-collapsible" ).hasClass( "ui-collapsible" ), "sibling unignored elements are enahanced" );
42
43                 $.mobile.ignoreContentEnabled = false;
44         });
45 })( jQuery );