Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Mask: Adding a unit test for parsing multi-character fields from input

  • Loading branch information...
commit 620964250575aeb9a27fc6e7e161ceaed92555af 1 parent 71b5d86
@gnarf gnarf authored
Showing with 29 additions and 0 deletions.
  1. +29 −0 tests/unit/mask/mask_core.js
View
29 tests/unit/mask/mask_core.js
@@ -127,4 +127,33 @@ test( "Parsing initial value skips literals", function() {
});
+test( "Parsing initial value with multi-character fields", function() {
+ expect( 2 );
+ var defs = {
+ hh: function( value ) {
+ value = parseInt( value, 10 );
+ if ( value >= 1 || value <= 12 ) {
+ return ( value < 10 ? "0" : "" ) + value;
+ }
+ },
+ ss: function( value ) {
+ value = parseInt( value, 10 );
+ if ( value >= 0 || value <= 59 ) {
+ return ( value < 10 ? "0" : "" ) + value;
+ }
+ }
+ },
+ input = $( "#mask1" );
+
+ input.val("123456").mask({
+ mask: "hh:ss:ss",
+ definitions: defs
+ });
+
+ equal( input.val(), "12:34:56", "Literals were inserted into val");
+ input.mask( "option", "mask", "99-99-99" );
+ equal( input.val(), "12-34-56", "Old literals were ignored, and new ones inserted into val");
+
+});
+
}( jQuery ) );
Please sign in to comment.
Something went wrong with that request. Please try again.