Permalink
Browse files

Mask: Bringing branch up to date with master

  • Loading branch information...
1 parent bab9d81 commit e3db34b0d958df1c743b143861b8aabd8088d9e9 @gnarf gnarf committed Aug 3, 2012
View
@@ -4,12 +4,12 @@
<meta charset="utf-8">
<title>jQuery UI Mask Test Suite</title>
- <script src="../../../jquery-1.7.1.js"></script>
+ <script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
@@ -17,8 +17,8 @@
<script src="../testsuite.js"></script>
<script src="mask_test_helpers.js"></script>
+ <script src="mask_common.js"></script>
<script src="mask_core.js"></script>
- <script src="mask_defaults.js"></script>
<script src="mask_events.js"></script>
<script src="mask_methods.js"></script>
<script src="mask_options.js"></script>
@@ -1,4 +1,4 @@
-commonWidgetTests( "mask", {
+TestHelpers.commonWidgetTests( "mask", {
defaults: {
clearEmpty: true,
definitions: {
@@ -2,21 +2,21 @@
module( "mask: events" );
-test( "focus: Initial Caret Positioning", function() {
+test( "focus: Initial Caret Positioning", 4, function() {
var input = $( "#mask1" ).val("").mask({
mask: "9",
clearEmpty: false
}),
mask = input.data( "mask" );
equal( input.val(), "_", "Initial Value Expected" );
- focus( input );
+ TestHelpers.focus( input );
deepEqual( mask._caret(), { begin: 0, end: 0 }, "Caret position correct");
- blur( input );
+ TestHelpers.blur( input );
input.mask( "option", "mask", "(9)" );
equal( input.val(), "(_)", "Initial Value Expected" );
- focus( input );
+ TestHelpers.focus( input );
deepEqual( mask._caret(), { begin: 1, end: 1 }, "Caret position correct");
});
@@ -27,7 +27,7 @@ test( "keydown: Backspace pulls values from right", function() {
mask = input.data( "mask" );
- focus( input );
+ TestHelpers.focus( input );
equal( input.val(), "123", "Initial Value Expected" );
mask._caret( 2 );
@@ -66,7 +66,7 @@ test( "keydown: Backspace with the cursor to the right of a mask literal", funct
var input = $( "#mask1" ).val("123").mask({ mask: "9-99" }),
mask = input.data( "mask" );
- focus( input );
+ TestHelpers.focus( input );
equal( input.val(), "1-23", "Initial Value Expected" );
mask._caret( 2 );
@@ -88,7 +88,7 @@ test( "keydown: Backspace with multiple values higlighted", function() {
var input = $( "#mask1" ).val("1234567890").mask({ mask: "(999)999-9999" }),
mask = input.data( "mask" );
- focus( input );
+ TestHelpers.focus( input );
equal( input.val(), "(123)456-7890", "Initial Value Expected" );
mask._caret( 5, 8 );
@@ -102,11 +102,11 @@ test( "keypress: Typing with multiple values higlighted", function() {
var input = $( "#mask1" ).val("1234567890").mask({ mask: "(999)999-9999" }),
mask = input.data( "mask" );
- focus( input );
+ TestHelpers.focus( input );
equal( input.val(), "(123)456-7890", "Initial Value Expected" );
mask._caret( 5, 8 );
- press( input, "0" );
+ TestHelpers.press( input, "0" );
equal( input.val(), "(123)078-90__", "Deleted three highlighted values, pulled values from right" );
deepEqual( mask._caret(), { begin: 6, end: 6 }, "Caret position correct");
});
@@ -123,44 +123,52 @@ test( "keypress: Typing with multi-character fields", function() {
}),
mask = input.data( "mask" );
- focus( input );
+ TestHelpers.focus( input );
equal( input.val(), "__-__-__", "Initial Value Expected" );
mask._caret( 0 );
- press( input, "0" );
+ TestHelpers.press( input, "0" );
equal( input.val(), "0_-__-__", "typed a 0" );
deepEqual( mask._caret(), { begin: 1, end: 1 }, "Caret position correct");
- press( input, "z" );
+ TestHelpers.press( input, "z" );
equal( input.val(), "0z-__-__", "typed a z" );
deepEqual( mask._caret(), { begin: 3, end: 5 }, "Caret position correct");
});
test( "keypress: Typing with multi-character only accepts valid values", function() {
expect( 8 );
- var input = $( "#mask1" ).val("").mask({
+ var input = $( "#mask1" ).val( "" ).mask({
mask: "aa-aa-aa",
definitions: {
aa: function( value ) {
- if ( !value.length ) return;
- if ( value.charAt( 0 ) == "_" ) return;
- if ( value.length == 1 ) return value+value;
- if ( value.charAt( 0 ) == value.charAt( 1 ) ) return value;
+ if ( !value.length ) {
+ return;
+ }
+ if ( value.charAt( 0 ) === "_" ) {
+ return;
+ }
+ if ( value.length === 1 ) {
+ return value+value;
+ }
+ if ( value.charAt( 0 ) === value.charAt( 1 ) ) {
+ return value;
+ }
}
}
}),
mask = input.data( "mask" );
- focus( input );
+ TestHelpers.focus( input );
equal( input.val(), "__-__-__", "Initial Value Expected" );
deepEqual( mask._caret(), { begin: 0, end: 2 }, "Caret position correct");
- press( input, "0" );
+ TestHelpers.press( input, "0" );
equal( input.val(), "0_-__-__", "typed a 0" );
deepEqual( mask._caret(), { begin: 1, end: 1 }, "Caret position correct");
- press( input, "z" );
+ TestHelpers.press( input, "z" );
equal( input.val(), "0_-__-__", "typed a z, wasn't allowed" );
deepEqual( mask._caret(), { begin: 1, end: 1 }, "Caret position correct");
- press( input, "0" );
+ TestHelpers.press( input, "0" );
equal( input.val(), "00-__-__", "typed a 0, was allowed" );
deepEqual( mask._caret(), { begin: 3, end: 5 }, "Caret position correct");
});
@@ -171,7 +179,7 @@ test( "keydown: Delete pulling values", function() {
var input = $( "#mask1" ).val("123").mask({ mask: "9-99" }),
mask = input.data( "mask" );
- focus( input );
+ TestHelpers.focus( input );
equal( input.val(), "1-23", "Initial value expected" );
mask._caret( 1 );
@@ -227,10 +235,10 @@ test( "keydown: escape returns to original value", function() {
mask = input.data( "mask" );
equal( input.val(), "6", "Initial value expected" );
- focus( input );
+ TestHelpers.focus( input );
mask._caret( 0 );
- press( input, "1" );
+ TestHelpers.press( input, "1" );
equal( input.val(), "1", "Typed over" );
input.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE });
@@ -246,27 +254,27 @@ test( "keypress: typing behaviors", function() {
}),
mask = input.data( "mask" );
- focus( input );
+ TestHelpers.focus( input );
equal( input.val(), "_-_", "Initial value expected" );
mask._caret( 0 );
- press( input, "1" );
+ TestHelpers.press( input, "1" );
equal( input.val(), "1-_", "Typed a 1" );
mask._caret( 0 );
- press( input, "2" );
+ TestHelpers.press( input, "2" );
equal( input.val(), "2-1", "Typed a 2 before the 1" );
deepEqual( mask._caret(), { begin: 2, end: 2 }, "Caret position correct");
input.val("").mask( "option", "mask", "9-a" );
equal( input.val(), "_-_", "Initial value expected" );
mask._caret( 0 );
- press( input, "1" );
+ TestHelpers.press( input, "1" );
equal( input.val(), "1-_", "Typed a 1" );
mask._caret( 0 );
- press( input, "2" );
+ TestHelpers.press( input, "2" );
equal( input.val(), "2-_", "Typed a 2 before the 1 - 1 is lost because not valid" );
deepEqual( mask._caret(), { begin: 2, end: 2 }, "Caret position correct");
});
@@ -12,9 +12,9 @@ test( "clearEmpty", function() {
mask = input.data( "mask" );
equal( input.val(), "", "Empty value with clearEmpty displays no mask" );
- focus( input );
+ TestHelpers.focus( input );
equal( input.val(), "__/__/__", "Empty value with clearEmpty & element focus displays mask" );
- blur( input );
+ TestHelpers.blur( input );
equal( input.val(), "", "Empty value with clearEmpty displays no mask after blur" );
input.mask( "option", "clearEmpty", false );
equal( input.val(), "__/__/__", "Disabling clearEmpty displays mask" );
@@ -45,7 +45,7 @@ test( "mask", function() {
equal( input.val(), "(123)4__-____", "Mask changed" );
});
-test( "mask option parser", function() {
+test( "mask option parser", 1, function() {
var defs = {
hh: function( value ) {
value = parseInt( value, 10 );
@@ -1,45 +1,46 @@
-function press( input, key ) {
- var code = key.charCodeAt( 0 );
-
- input.simulate( "keypress", {
- charCode: code,
- which: code
- });
-}
-
-function focus( element ) {
- var triggered = false;
-
- function trigger() {
- triggered = true;
- }
-
- element.bind( "focus", trigger );
- element[ 0 ].focus();
-
- if ( !triggered ) {
- element.triggerHandler( "focus" );
- }
- element.unbind( "focus", trigger );
-}
-
-function blur( element ) {
- var triggered = false;
-
- function trigger() {
- triggered = true;
- }
-
- element.bind( "blur", trigger );
- element[ 0 ].blur();
-
- // Some versions of IE don't actually .blur() on an element - so we focus the body
- if ( element[ 0 ].ownerDocument.activeElement === element[ 0 ] ) {
- element[ 0 ].ownerDocument.body.focus();
- }
-
- if ( !triggered ) {
- element.triggerHandler( "blur" );
+jQuery.extend( TestHelpers, {
+ press: function( input, key ) {
+ var code = key.charCodeAt( 0 );
+
+ input.simulate( "keypress", {
+ charCode: code,
+ which: code
+ });
+ },
+ focus: function( element ) {
+ var triggered = false;
+
+ function trigger() {
+ triggered = true;
+ }
+
+ element.bind( "focus", trigger );
+ element[ 0 ].focus();
+
+ if ( !triggered ) {
+ element.triggerHandler( "focus" );
+ }
+ element.unbind( "focus", trigger );
+ },
+
+ blur: function( element ) {
+ var triggered = false;
+
+ function trigger() {
+ triggered = true;
+ }
+
+ element.bind( "blur", trigger );
+ element[ 0 ].blur();
+
+ // Some versions of IE don't actually .blur() on an element - so we focus the body
+ if ( element[ 0 ].ownerDocument.activeElement === element[ 0 ] ) {
+ element[ 0 ].ownerDocument.body.focus();
+ }
+
+ if ( !triggered ) {
+ element.triggerHandler( "blur" );
+ }
+ element.unbind( "blur", trigger );
}
- element.unbind( "blur", trigger );
-}
+});
@@ -4,12 +4,12 @@
<meta charset="utf-8">
<title>jQuery UI Timepicker Test Suite</title>
- <script src="../../../jquery-1.7.1.js"></script>
+ <script src="../../../jquery-1.7.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
- <link rel="stylesheet" href="../subsuiteRunner.css">
+ <link rel="stylesheet" href="../qunit-composite.css">
<script src="../../../external/qunit.js"></script>
- <script src="../subsuiteRunner.js"></script>
+ <script src="../qunit-composite.js"></script>
<script src="../subsuite.js"></script>
<script>
@@ -6,7 +6,7 @@
<link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css">
- <script src="../../../jquery-1.7.1.js"></script>
+ <script src="../../../jquery-1.7.2.js"></script>
<script src="../../../external/globalize.js"></script>
<script src="../../../ui/jquery.ui.core.js"></script>
<script src="../../../ui/jquery.ui.widget.js"></script>
@@ -21,8 +21,8 @@
<script src="../testsuite.js"></script>
<script src="timepicker_test_helpers.js"></script>
+ <script src="timepicker_common.js"></script>
<script src="timepicker_core.js"></script>
- <script src="timepicker_defaults.js"></script>
<script src="timepicker_events.js"></script>
<script src="timepicker_methods.js"></script>
<script src="timepicker_options.js"></script>
@@ -1,4 +1,4 @@
-commonWidgetTests( "timepicker", {
+TestHelpers.commonWidgetTests( "timepicker", {
defaults: {
ampm: true,
disabled: false,
Oops, something went wrong.

0 comments on commit e3db34b

Please sign in to comment.