2 * mobile textinput unit tests
5 module( "jquery.mobile.forms.textinput.js" );
7 // NOTE this test isn't run because the event data isn't easily accessible
8 // and with the advent of the widget _on method we are actually testing the
9 // widget from UI which has it's own test suite for these sorts of things
10 // ie, don't test your dependencies / framework
11 if( !( $.fn.jquery.match(/^1.8/) )){
12 test( "input is cleaned up on destroy", function(){
13 var input = $( "#destroycorrectly" ),
17 loadLen = win.data("events").load.length;
21 equal(win.data("events").load.length, (loadLen-1), "window load event was not removed");
25 test( "inputs without type specified are enhanced", function(){
26 ok( $( "#typeless-input" ).hasClass( "ui-input-text" ) );
29 $.mobile.page.prototype.options.keepNative = "textarea.should-be-native";
31 // not testing the positive case here since's it's obviously tested elsewhere
32 test( "textarea in the keepNative set shouldn't be enhanced", function() {
33 ok( !$("textarea.should-be-native").is("ui-input-text") );
36 asyncTest( "textarea should autogrow on document ready", function() {
37 var test = $( "#init-autogrow" );
39 setTimeout(function() {
40 ok( $( "#reference-autogrow" )[0].clientHeight < test[0].clientHeight, "the height is greater than the reference text area with no content" );
41 ok( test[0].clientHeight > 100, "autogrow text area's height is greater than any style padding");
46 asyncTest( "textarea should autogrow when text is added via the keyboard", function() {
47 var test = $( "#keyup-autogrow" ),
48 originalHeight = test[0].clientHeight;
50 test.keyup(function() {
51 setTimeout(function() {
52 ok( test[0].clientHeight > originalHeight, "the height is greater than original with no content" );
53 ok( test[0].clientHeight > 100, "autogrow text area's height is greater any style/padding");
58 test.val("foo\n\n\n\n\n\n\n\n\n\n\n\n\n\n").trigger("keyup");
61 asyncTest( "text area should auto grow when the parent page is loaded via ajax", function() {
62 $.testHelper.pageSequence([
64 $("#external").click();
68 setTimeout(function() {
69 ok($.mobile.activePage.find( "textarea" )[0].clientHeight > 100, "text area's height has grown");
70 window.history.back();
80 // NOTE init binding to alter the setting is in settings.js
81 test( "'clear text' button for search inputs should use configured text", function(){
82 strictEqual( $( "#search-input" ).closest( ".ui-input-search" ).find( ".ui-input-clear" ).attr( "title" ), "custom value" );