2 * mobile textinput unit tests
5 module( "jquery.mobile.forms.textinput.js" );
7 test( "inputs without type specified are enhanced", function(){
8 ok( $( "#typeless-input" ).hasClass( "ui-input-text" ) );
11 $.mobile.page.prototype.options.keepNative = "textarea.should-be-native";
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") );
18 asyncTest( "textarea should autogrow on document ready", function() {
19 var test = $( "#init-autogrow" );
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");
28 asyncTest( "textarea should autogrow when text is added via the keyboard", function() {
29 var test = $( "#keyup-autogrow" ),
30 originalHeight = test[0].clientHeight;
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");
40 test.val("foo\n\n\n\n\n\n\n\n\n\n\n\n\n\n").trigger("keyup");
43 asyncTest( "text area should auto grow when the parent page is loaded via ajax", function() {
44 $.testHelper.pageSequence([
46 $("#external").click();
50 setTimeout(function() {
51 ok($.mobile.activePage.find( "textarea" )[0].clientHeight > 100, "text area's height has grown");
52 window.history.back();
62 // NOTE init binding to alter the setting is in settings.js
63 test( "'clear text' button for search inputs should use configured text", function(){
64 strictEqual( $( "#search-input" ).closest( ".ui-input-search" ).find( ".ui-input-clear" ).attr( "title" ), "custom value" );