This repository has been archived by the owner on Oct 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
textinput_core.js
78 lines (62 loc) · 2.4 KB
/
textinput_core.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* mobile textinput unit tests
*/
(function($){
module( "jquery.mobile.forms.textinput.js" );
test( "input is cleaned up on destroy", function(){
var input = $( "#destroycorrectly" ),
win = $( window ),
loadLen;
loadLen = win.data("events").load.length;
input.remove();
equal(win.data("events").load.length, (loadLen-1), "window load event was not removed");
});
test( "inputs without type specified are enhanced", function(){
ok( $( "#typeless-input" ).hasClass( "ui-input-text" ) );
});
$.mobile.page.prototype.options.keepNative = "textarea.should-be-native";
// not testing the positive case here since's it's obviously tested elsewhere
test( "textarea in the keepNative set shouldn't be enhanced", function() {
ok( !$("textarea.should-be-native").is("ui-input-text") );
});
asyncTest( "textarea should autogrow on document ready", function() {
var test = $( "#init-autogrow" );
setTimeout(function() {
ok( $( "#reference-autogrow" )[0].clientHeight < test[0].clientHeight, "the height is greater than the reference text area with no content" );
ok( test[0].clientHeight > 100, "autogrow text area's height is greater than any style padding");
start();
}, 400);
});
asyncTest( "textarea should autogrow when text is added via the keyboard", function() {
var test = $( "#keyup-autogrow" ),
originalHeight = test[0].clientHeight;
test.keyup(function() {
setTimeout(function() {
ok( test[0].clientHeight > originalHeight, "the height is greater than original with no content" );
ok( test[0].clientHeight > 100, "autogrow text area's height is greater any style/padding");
start();
}, 400);
});
test.val("foo\n\n\n\n\n\n\n\n\n\n\n\n\n\n").trigger("keyup");
});
asyncTest( "text area should auto grow when the parent page is loaded via ajax", function() {
$.testHelper.pageSequence([
function() {
$("#external").click();
},
function() {
setTimeout(function() {
ok($.mobile.activePage.find( "textarea" )[0].clientHeight > 100, "text area's height has grown");
window.history.back();
}, 1000);
},
function() {
start();
}
]);
});
// NOTE init binding to alter the setting is in settings.js
test( "'clear text' button for search inputs should use configured text", function(){
strictEqual( $( "#search-input" ).closest( ".ui-input-search" ).find( ".ui-input-clear" ).attr( "title" ), "custom value" );
});
})(jQuery);