Tokentextarea: Fix issues
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.1.0 / tests / unit / select / select_cached.js
1 /*
2  * mobile select unit tests
3  */
4
5 (function($){
6         var resetHash;
7
8         resetHash = function(timeout){
9                 $.testHelper.openPage( location.hash.indexOf("#default") >= 0 ? "#" : "#default" );
10         };
11
12         // https://github.com/jquery/jquery-mobile/issues/2181
13         asyncTest( "dialog sized select should alter the value of its parent select", function(){
14                 var selectButton, value;
15
16                 $.testHelper.pageSequence([
17                         resetHash,
18
19                         function(){
20                                 $.mobile.changePage( "cached.html" );
21                         },
22
23                         function(){
24                                 ok( $.mobile.activePage.is("#dialog-select-parent-cache-test"), "cached page appears" );
25                                 selectButton = $( "#cached-page-select" ).siblings( 'a' );
26                                 selectButton.click();
27                         },
28
29                         function(){
30                                 ok( $.mobile.activePage.hasClass('ui-dialog'), "the dialog came up" );
31                                 var option = $.mobile.activePage.find( "li a" ).not(":contains('" + selectButton.text() + "')").last();
32                                 value = $.trim(option.text());
33                                 option.click();
34                         },
35
36                         function(){
37                                 same( value, $.trim(selectButton.text()), "the selected value is propogated back to the button text" );
38                                 start();
39                         }
40                 ]);
41         });
42
43         // https://github.com/jquery/jquery-mobile/issues/2181
44         asyncTest( "dialog sized select should prevent the removal of its parent page from the dom", function(){
45                 var selectButton, parentPageId;
46
47                 expect( 2 );
48
49                 $.testHelper.pageSequence([
50                         resetHash,
51
52                         function(){
53                                 $.mobile.changePage( "cached.html" );
54                         },
55
56                         function(){
57                                 selectButton = $.mobile.activePage.find( "#cached-page-select" ).siblings( 'a' );
58                                 parentPageId = $.mobile.activePage.attr( 'id' );
59                                 same( $("#" + parentPageId).length, 1, "establish the parent page exists" );
60                                 selectButton.click();
61                         },
62
63                         function(){
64                                 same( $( "#" + parentPageId).length, 1, "make sure parent page is still there after opening the dialog" );
65                                 $.mobile.activePage.find( "li a" ).last().click();
66                         },
67
68                         start
69                 ]);
70         });
71
72         asyncTest( "dialog sized select shouldn't rebind its parent page remove handler when closing, if the parent page domCache option is true", function(){
73                 expect( 3 );
74
75                 $.testHelper.pageSequence([
76                         resetHash,
77
78                         function(){
79                                 $.mobile.changePage( "cached-dom-cache-true.html" );
80                         },
81
82                         function(){
83                                 $.mobile.activePage.find( "#domcache-page-select" ).siblings( 'a' ).click();
84                         },
85
86                         function(){
87                                 ok( $.mobile.activePage.hasClass('ui-dialog'), "the dialog came up" );
88                                 $.mobile.activePage.find( "li a" ).last().click();
89                         },
90
91                         function(){
92                                 ok( $.mobile.activePage.is( "#dialog-select-parent-domcache-test" ), "the dialog closed" );
93                                 $.mobile.changePage( $( "#default" ) );
94                         },
95
96                         function(){
97                                 same( $("#dialog-select-parent-domcache-test").length, 1, "make sure the select parent page is still cached in the dom after changing page" );
98                                 start();
99                         }
100                 ]);
101         });
102
103         asyncTest( "menupage is removed when the parent page is removed", function(){
104                 var dialogCount = $(":jqmData(role='dialog')").length;
105                 $.testHelper.pageSequence([
106                         resetHash,
107
108                         function(){
109                                 $.mobile.changePage( "uncached-dom-cached-false.html" );
110                         },
111
112                         function(){
113                                 // for performance reason we don't initially create the menu dialog now
114                                 same( $(":jqmData(role='dialog')").length, dialogCount);
115
116                                 // manually trigger dialog opening
117                                 $( "#domcache-uncached-page-select" ).data( 'selectmenu' ).open();
118                         },
119
120                         function(){
121                                 // check if dialog was successfully  created
122                                 same( $(":jqmData(role='dialog')").length, dialogCount + 1 );
123                                 $( "#domcache-uncached-page-select" ).data( 'selectmenu' ).close();
124                         },
125
126                         function(){
127                                 // navigate to parent(initial) page
128                                 window.history.back();
129                         },
130
131                         function() {
132                                 same( $(":jqmData(role='dialog')").length, dialogCount );
133                                 start();
134                         }
135                 ]);
136         });
137 })(jQuery);