41381f519e28625b980aa6309a9de3a0f404808d
[framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.0.1pre / tests / unit / textinput / textinput_core.js
1 /*
2  * mobile textinput unit tests
3  */
4 (function($){
5         module( "jquery.mobile.forms.textinput.js" );
6
7         test( "inputs without type specified are enhanced", function(){
8                 ok( $( "#typeless-input" ).hasClass( "ui-input-text" ) );
9         });
10
11         $.mobile.page.prototype.options.keepNative = "textarea.should-be-native";
12
13         // not testing the positive case here since's it's obviously tested elsewhere
14         test( "textarea in the keepNative set shouldn't be enhanced", function() {
15                 ok( !$("textarea.should-be-native").is("ui-input-text") );
16         });
17
18         asyncTest( "textarea should autogrow on document ready", function() {
19                 var test = $( "#init-autogrow" );
20
21                 setTimeout(function() {
22                         ok( $( "#reference-autogrow" )[0].clientHeight < test[0].clientHeight, "the height is greater than the reference text area with no content" );
23                         ok( test[0].clientHeight > 100, "autogrow text area's height is greater than any style padding");
24                         start();
25                 }, 400);
26         });
27
28         asyncTest( "textarea should autogrow when text is added via the keyboard", function() {
29                 var test = $( "#keyup-autogrow" ),
30                         originalHeight = test[0].clientHeight;
31
32                 test.keyup(function() {
33                         setTimeout(function() {
34                                 ok( test[0].clientHeight > originalHeight, "the height is greater than original with no content" );
35                                 ok( test[0].clientHeight > 100, "autogrow text area's height is greater any style/padding");
36                                 start();
37                         }, 400);
38                 });
39
40                 test.val("foo\n\n\n\n\n\n\n\n\n\n\n\n\n\n").trigger("keyup");
41         });
42
43         asyncTest( "text area should auto grow when the parent page is loaded via ajax", function() {
44                 $.testHelper.pageSequence([
45                         function() {
46                                 $("#external").click();
47                         },
48
49                         function() {
50                                 setTimeout(function() {
51                                         ok($.mobile.activePage.find( "textarea" )[0].clientHeight > 100, "text area's height has grown");
52                                         window.history.back();
53                                 }, 1000);
54                         },
55
56                         function() {
57                                 start();
58                         }
59                 ]);
60         });
61 })(jQuery);