Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Mask: add unit tests for optional section

  • Loading branch information...
commit 3f23f5e0bc73f00224fd3094a5d8fe8d12ee042b 1 parent 8cca5e5
Zach Shepherd authored
Showing with 28 additions and 0 deletions.
  1. +19 −0 tests/unit/mask/mask_methods.js
  2. +9 −0 tests/unit/mask/mask_options.js
View
19 tests/unit/mask/mask_methods.js
@@ -25,6 +25,25 @@ test( "value: able to get (and set) raw values", function() {
equal( input.mask( "value" ), "123456", "Raw value read correctly" );
});
+test( "value: able to get (and set) raw values with optional section", function() {
+ expect( 5 );
+ var input = $( "#mask1" ).val("1234").mask({
+ mask: "(999) 999-9999?x9999",
+ });
+
+ equal( input.mask('value'), "1234", "Reading initial value" );
+
+ input.mask( "value", "123456" );
+
+ equal( input.val(), "(123) 456-____", "Raw value set properly" );
+ equal( input.mask( "value" ), "123456", "Raw value read correctly" );
+
+ input.mask( "value", "12345678901234" );
+
+ equal( input.val(), "(123) 456-7890x1234", "Raw value with optional set properly" );
+ equal( input.mask( "value" ), "12345678901234", "Raw value read correctly" );
+});
+
test( "valid: returns true when all required placeholders are filled", function() {
expect( 2 );
var input = $( "#mask1" ).mask({
View
9 tests/unit/mask/mask_options.js
@@ -45,6 +45,15 @@ test( "mask", function() {
equal( input.val(), "(123)4__-____", "Mask changed" );
});
+test( "mask with optional input", function() {
+ expect( 1 );
+ var input = $( "#mask1" ).val("1234").mask({
+ mask: "(999) 999-9999?x9999",
+ });
+
+ equal( input.val(), "(123) 4__-____", "Initial value" );
+});
+
test( "mask option parser", 1, function() {
var defs = {
hh: function( value ) {
Please sign in to comment.
Something went wrong with that request. Please try again.