Browse Source

enhance alternation selection + add unit testing for phonecodes

Robin Herbots 9 years ago
parent
commit
71b819a375

+ 2 - 0
CHANGELOG.md

@@ -7,8 +7,10 @@ All notable changes to this project will be documented in this file.
 - 'casing': 'title' #1277
 
 ### Updates
+- improve alternation selection
 - removed nojumps option
 - update phone alias implementation
+	- add unit tests for phonecodes
 - replaced radixFocus option by positionCaretOnClick.  Allows choice for behavior of the caret on click. (none, lvp (default), radixFocus)
 - performance updates
 	- getmasklength

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.3.2-34",
+  "version": "3.3.2-41",
   "main": [
     "./dist/inputmask/inputmask.js"
   ],

+ 1 - 1
component.json

@@ -2,7 +2,7 @@
   "name": "jquery_inputmask",
   "repository": "robinherbots/jquery.inputmask",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
-  "version": "3.3.2-34",
+  "version": "3.3.2-41",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "main": "./dist/jquery.inputmask.bundle.js",
   "scripts": [

+ 1 - 1
composer.json

@@ -1,7 +1,7 @@
 {
   "name": "robinherbots/jquery.inputmask",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
-  "version": "3.3.2-34",
+  "version": "3.3.2-41",
   "type": "library",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "homepage": "http://robinherbots.github.io/jquery.inputmask",

+ 1 - 1
dist/inputmask/inputmask.date.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-34
+* Version: 3.3.2-41
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/inputmask.dependencyLib.jquery.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-34
+* Version: 3.3.2-41
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery")) : factory(jQuery);

+ 1 - 1
dist/inputmask/inputmask.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-34
+* Version: 3.3.2-41
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 5 - 5
dist/inputmask/inputmask.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-34
+* Version: 3.3.2-41
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery")) : factory(window.dependencyLib || jQuery);
@@ -372,7 +372,7 @@
                     }
                     function resolveNdxInitializer(pos, alternateNdx) {
                         var bestMatch = selectBestMatch(pos, alternateNdx);
-                        return bestMatch ? bestMatch.locator.slice(bestMatch.alternation + 1) : [];
+                        return bestMatch ? bestMatch.locator.slice(bestMatch.alternation + 1) : void 0;
                     }
                     if (testPos > 1e4) throw "Inputmask: There is probably an error in your mask definition or in the code. Create an issue on github with an example of the mask you are using. " + getMaskSet().mask;
                     if (testPos === pos && void 0 === match.matches) return matches.push({
@@ -395,7 +395,7 @@
                                 var amndx, currentPos = testPos, ndxInitializerClone = ndxInitializer.slice(), altIndexArr = [];
                                 if ("string" == typeof altIndex) altIndexArr = altIndex.split(","); else for (amndx = 0; amndx < alternateToken.matches.length; amndx++) altIndexArr.push(amndx);
                                 for (var ndx = 0; ndx < altIndexArr.length; ndx++) {
-                                    if (amndx = parseInt(altIndexArr[ndx]), matches = [], ndxInitializer = resolveNdxInitializer(testPos, amndx), 
+                                    if (amndx = parseInt(altIndexArr[ndx]), matches = [], ndxInitializer = resolveNdxInitializer(testPos, amndx) || ndxInitializerClone.slice(), 
                                     match = handleMatch(alternateToken.matches[amndx] || maskToken.matches[amndx], [ amndx ].concat(loopNdx), quantifierRecurse) || match, 
                                     match !== !0 && void 0 !== match && altIndexArr[altIndexArr.length - 1] < alternateToken.matches.length) {
                                         var ntndx = $.inArray(match, maskToken.matches) + 1;
@@ -405,7 +405,6 @@
                                         })));
                                     }
                                     maltMatches = matches.slice(), testPos = currentPos, matches = [];
-                                    for (var i = 0; i < ndxInitializerClone.length; i++) ndxInitializer[i] = ndxInitializerClone[i];
                                     for (var ndx1 = 0; ndx1 < maltMatches.length; ndx1++) {
                                         var altMatch = maltMatches[ndx1], hasMatch = !1;
                                         altMatch.alternation = altMatch.alternation || loopNdxCnt;
@@ -430,7 +429,8 @@
                                         lmnt.alternation = alternation);
                                         if (void 0 !== lmnt.locator[alternation]) return lmnt;
                                     }
-                                })), matches = currentMatches.concat(malternateMatches), testPos = pos, insertStop = matches.length > 0;
+                                })), matches = currentMatches.concat(malternateMatches), testPos = pos, insertStop = matches.length > 0, 
+                                ndxInitializer = ndxInitializerClone.slice();
                             } else match = handleMatch(alternateToken.matches[altIndex] || maskToken.matches[altIndex], [ altIndex ].concat(loopNdx), quantifierRecurse);
                             if (match) return !0;
                         } else if (match.isQuantifier && quantifierRecurse !== maskToken.matches[$.inArray(match, maskToken.matches) - 1]) for (var qt = match, qndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; qndx < (isNaN(qt.quantifier.max) ? qndx + 1 : qt.quantifier.max) && pos >= testPos; qndx++) {

+ 1 - 1
dist/inputmask/inputmask.numeric.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-34
+* Version: 3.3.2-41
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/inputmask.phone.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-34
+* Version: 3.3.2-41
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/inputmask.regex.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-34
+* Version: 3.3.2-41
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/jquery.inputmask.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-34
+* Version: 3.3.2-41
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery"), require("./inputmask")) : factory(jQuery, window.Inputmask);

+ 5 - 5
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-34
+* Version: 3.3.2-41
 */
 !function($) {
     function Inputmask(alias, options) {
@@ -370,7 +370,7 @@
                     }
                     function resolveNdxInitializer(pos, alternateNdx) {
                         var bestMatch = selectBestMatch(pos, alternateNdx);
-                        return bestMatch ? bestMatch.locator.slice(bestMatch.alternation + 1) : [];
+                        return bestMatch ? bestMatch.locator.slice(bestMatch.alternation + 1) : void 0;
                     }
                     if (testPos > 1e4) throw "Inputmask: There is probably an error in your mask definition or in the code. Create an issue on github with an example of the mask you are using. " + getMaskSet().mask;
                     if (testPos === pos && void 0 === match.matches) return matches.push({
@@ -393,7 +393,7 @@
                                 var amndx, currentPos = testPos, ndxInitializerClone = ndxInitializer.slice(), altIndexArr = [];
                                 if ("string" == typeof altIndex) altIndexArr = altIndex.split(","); else for (amndx = 0; amndx < alternateToken.matches.length; amndx++) altIndexArr.push(amndx);
                                 for (var ndx = 0; ndx < altIndexArr.length; ndx++) {
-                                    if (amndx = parseInt(altIndexArr[ndx]), matches = [], ndxInitializer = resolveNdxInitializer(testPos, amndx), 
+                                    if (amndx = parseInt(altIndexArr[ndx]), matches = [], ndxInitializer = resolveNdxInitializer(testPos, amndx) || ndxInitializerClone.slice(), 
                                     match = handleMatch(alternateToken.matches[amndx] || maskToken.matches[amndx], [ amndx ].concat(loopNdx), quantifierRecurse) || match, 
                                     match !== !0 && void 0 !== match && altIndexArr[altIndexArr.length - 1] < alternateToken.matches.length) {
                                         var ntndx = $.inArray(match, maskToken.matches) + 1;
@@ -403,7 +403,6 @@
                                         })));
                                     }
                                     maltMatches = matches.slice(), testPos = currentPos, matches = [];
-                                    for (var i = 0; i < ndxInitializerClone.length; i++) ndxInitializer[i] = ndxInitializerClone[i];
                                     for (var ndx1 = 0; ndx1 < maltMatches.length; ndx1++) {
                                         var altMatch = maltMatches[ndx1], hasMatch = !1;
                                         altMatch.alternation = altMatch.alternation || loopNdxCnt;
@@ -428,7 +427,8 @@
                                         lmnt.alternation = alternation);
                                         if (void 0 !== lmnt.locator[alternation]) return lmnt;
                                     }
-                                })), matches = currentMatches.concat(malternateMatches), testPos = pos, insertStop = matches.length > 0;
+                                })), matches = currentMatches.concat(malternateMatches), testPos = pos, insertStop = matches.length > 0, 
+                                ndxInitializer = ndxInitializerClone.slice();
                             } else match = handleMatch(alternateToken.matches[altIndex] || maskToken.matches[altIndex], [ altIndex ].concat(loopNdx), quantifierRecurse);
                             if (match) return !0;
                         } else if (match.isQuantifier && quantifierRecurse !== maskToken.matches[$.inArray(match, maskToken.matches) - 1]) for (var qt = match, qndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; qndx < (isNaN(qt.quantifier.max) ? qndx + 1 : qt.quantifier.max) && pos >= testPos; qndx++) {

File diff suppressed because it is too large
+ 1 - 1
dist/min/inputmask/inputmask.date.extensions.min.js


+ 1 - 1
dist/min/inputmask/inputmask.dependencyLib.jquery.min.js

@@ -3,6 +3,6 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-34
+* Version: 3.3.2-41
 */
 !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){return window.dependencyLib=a,a});

File diff suppressed because it is too large
+ 1 - 1
dist/min/inputmask/inputmask.extensions.min.js


File diff suppressed because it is too large
+ 2 - 2
dist/min/inputmask/inputmask.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/min/inputmask/inputmask.numeric.extensions.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/min/inputmask/inputmask.phone.extensions.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/min/inputmask/inputmask.regex.extensions.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/min/inputmask/jquery.inputmask.min.js


File diff suppressed because it is too large
+ 2 - 2
dist/min/jquery.inputmask.bundle.min.js


+ 5 - 3
extra/phone-codes/phone.js

@@ -54,7 +54,8 @@
 				{ "mask": "+1(441)###-####", "cc": "BM", "cd": "Bermuda", "desc_en": "", "name_ru": "Бермудские острова", "desc_ru": "" },
 				{ "mask": "+673-###-####", "cc": "BN", "cd": "Brunei Darussalam", "desc_en": "", "name_ru": "Бруней-Даруссалам", "desc_ru": "" },
 				{ "mask": "+591-#-###-####", "cc": "BO", "cd": "Bolivia", "desc_en": "", "name_ru": "Боливия", "desc_ru": "" },
-				{ "mask": "+55-##-####[#]-####", "cc": "BR", "cd": "Brazil", "desc_en": "", "name_ru": "Бразилия", "desc_ru": "" },
+				{ "mask": "+55-##-####-####", "cc": "BR", "cd": "Brazil", "desc_en": "", "name_ru": "Бразилия", "desc_ru": "" },
+				{ "mask": "+55-##-#####-####", "cc": "BR", "cd": "Brazil", "desc_en": "", "name_ru": "Бразилия", "desc_ru": "" },
 				{ "mask": "+1(242)###-####", "cc": "BS", "cd": "Bahamas", "desc_en": "", "name_ru": "Багамские Острова", "desc_ru": "" },
 				{ "mask": "+975-17-###-###", "cc": "BT", "cd": "Bhutan", "desc_en": "", "name_ru": "Бутан", "desc_ru": "" },
 				{ "mask": "+975-#-###-###", "cc": "BT", "cd": "Bhutan", "desc_en": "", "name_ru": "Бутан", "desc_ru": "" },
@@ -312,9 +313,10 @@
 				{ "mask": "+27-##-###-####", "cc": "ZA", "cd": "South Africa", "desc_en": "", "name_ru": "Южно-Африканская Респ.", "desc_ru": "" },
 				{ "mask": "+260-##-###-####", "cc": "ZM", "cd": "Zambia", "desc_en": "", "name_ru": "Замбия", "desc_ru": "" },
 				{ "mask": "+263-#-######", "cc": "ZW", "cd": "Zimbabwe", "desc_en": "", "name_ru": "Зимбабве", "desc_ru": "" },
-				{ "mask": "+1(###)###-####", "cc": ["US", "CA"], "cd": "USA and Canada", "desc_en": "", "name_ru": "США и Канада", "desc_ru": "" }]
+				{ "mask": "+1(###)###-####", "cc": ["US", "CA"], "cd": "USA and Canada", "desc_en": "", "name_ru": "США и Канада", "desc_ru": "" }
+			 ]
 		}
 	});
 
-	return Inputmask;
+    return Inputmask;
 }));

+ 8 - 6
js/inputmask.js

@@ -995,7 +995,7 @@
 
 					function resolveNdxInitializer(pos, alternateNdx) {
 						var bestMatch = selectBestMatch(pos, alternateNdx);
-						return bestMatch ? bestMatch.locator.slice(bestMatch.alternation + 1) : [];
+						return bestMatch ? bestMatch.locator.slice(bestMatch.alternation + 1) : undefined;
 					}
 
 					if (testPos > 10000) {
@@ -1028,6 +1028,7 @@
 								maltMatches,
 								currentMatches = matches.slice(),
 								loopNdxCnt = loopNdx.length;
+							//console.log("before " + ndxInitializer);
 							var altIndex = ndxInitializer.length > 0 ? ndxInitializer.shift() : -1;
 							if (altIndex === -1 || typeof altIndex === "string") {
 								var currentPos = testPos,
@@ -1045,7 +1046,8 @@
 									amndx = parseInt(altIndexArr[ndx]);
 									matches = [];
 									//set the correct ndxInitializer
-									ndxInitializer = resolveNdxInitializer(testPos, amndx);
+									ndxInitializer = resolveNdxInitializer(testPos, amndx) || ndxInitializerClone.slice();
+									//console.log("resolved " + ndxInitializerClone + " vs " + resolveNdxInitializer(testPos, amndx));
 									match = handleMatch(alternateToken.matches[amndx] || maskToken.matches[amndx], [amndx].concat(loopNdx), quantifierRecurse) || match;
 									if (match !== true && match !== undefined && (altIndexArr[altIndexArr.length - 1] < alternateToken.matches.length)) { //no match in the alternations (length mismatch) => look further
 										var ntndx = $.inArray(match, maskToken.matches) + 1;
@@ -1062,10 +1064,7 @@
 									maltMatches = matches.slice();
 									testPos = currentPos;
 									matches = [];
-									//cloneback
-									for (var i = 0; i < ndxInitializerClone.length; i++) {
-										ndxInitializer[i] = ndxInitializerClone[i];
-									}
+
 									//fuzzy merge matches
 									for (var ndx1 = 0; ndx1 < maltMatches.length; ndx1++) {
 										var altMatch = maltMatches[ndx1], hasMatch = false;
@@ -1116,6 +1115,9 @@
 								matches = currentMatches.concat(malternateMatches);
 								testPos = pos;
 								insertStop = matches.length > 0; //insert a stopelemnt when there is an alternate - needed for non-greedy option
+
+								//cloneback
+								ndxInitializer = ndxInitializerClone.slice();
 							} else {
 								// if (alternateToken.matches[altIndex]) { //if not in the initial alternation => look further
 								match = handleMatch(alternateToken.matches[altIndex] || maskToken.matches[altIndex], [altIndex].concat(loopNdx), quantifierRecurse);

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.3.2-34",
+  "version": "3.3.2-41",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
   "main": "./dist/inputmask/jquery.inputmask.js",
   "files": [

+ 10 - 0
qunit/main_phone.js

@@ -0,0 +1,10 @@
+define([
+	"qunit",
+	"tests_phone_world",
+	"tests_phonebe",
+	"tests_phonenl"
+	//"tests_phoneru"
+], function(qunit) {
+	qunit.load();
+	qunit.start();
+});

+ 14 - 0
qunit/qunit_phone.html

@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="utf-8">
+  <title>jquery.inputmask - QUnit</title>
+  <link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css">
+</head>
+<body>
+  <div id="qunit"></div>
+  <div id="qunit-fixture"></div>
+  <script data-main="main_phone" src="../node_modules/requirejs/require.js"></script>
+  <script src="config.js"></script>
+</body>
+</html>

+ 1 - 1
qunit/tests_phone.js

@@ -111,7 +111,7 @@ define([
 	qunit.test("inputmask(\"phone\") - russian backspace", 1, function (assert) {
 		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" />');
-		Inputmask("phone", { nullable: false }).mask(testmask);
+		Inputmask("phone", {nullable: false}).mask(testmask);
 
 		testmask.focus();
 		$("#testmask").Type("71");

+ 36 - 0
qunit/tests_phone_world.js

@@ -0,0 +1,36 @@
+define([
+	"qunit",
+	"inputmask.dependencyLib",
+	"inputmask",
+	"../dist/inputmask/inputmask.date.extensions",
+	"../dist/inputmask/inputmask.extensions",
+	"../dist/inputmask/inputmask.numeric.extensions",
+	"../dist/inputmask/inputmask.phone.extensions",
+	"../extra/phone-codes/phone",
+	"../extra/phone-codes/phone-be",
+	"../extra/phone-codes/phone-nl",
+	"../extra/phone-codes/phone-ru",
+	"../extra/phone-codes/phone-uk",
+	"../dist/inputmask/inputmask.regex.extensions",
+	"prototypeExtensions",
+	"simulator"
+], function (qunit, $, Inputmask) {
+
+	qunit.module("Phone masks");
+
+	qunit.test("inputmask(\"phone\")", 293, function (assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		Inputmask("phone", {nullable: false}).mask(testmask);
+
+		testmask.focus();
+
+		$.each(Inputmask.prototype.defaults.aliases.phone.phoneCodes, function (ndx, lmnt) {
+			var input = lmnt.mask.replace(/#/g, "0");
+			$(testmask).val(input);
+			equal(testmask.value, input, "Result " + testmask.value);
+		});
+
+	});
+
+});

+ 36 - 0
qunit/tests_phonebe.js

@@ -0,0 +1,36 @@
+define([
+	"qunit",
+	"inputmask.dependencyLib",
+	"inputmask",
+	"../dist/inputmask/inputmask.date.extensions",
+	"../dist/inputmask/inputmask.extensions",
+	"../dist/inputmask/inputmask.numeric.extensions",
+	"../dist/inputmask/inputmask.phone.extensions",
+	"../extra/phone-codes/phone",
+	"../extra/phone-codes/phone-be",
+	"../extra/phone-codes/phone-nl",
+	"../extra/phone-codes/phone-ru",
+	"../extra/phone-codes/phone-uk",
+	"../dist/inputmask/inputmask.regex.extensions",
+	"prototypeExtensions",
+	"simulator"
+], function (qunit, $, Inputmask) {
+
+	qunit.module("Phone masks");
+
+	qunit.test("inputmask(\"phonebe\")", 45, function (assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		Inputmask("phonebe", {nullable: false}).mask(testmask);
+
+		testmask.focus();
+
+		$.each(Inputmask.prototype.defaults.aliases.phonebe.phoneCodes, function (ndx, lmnt) {
+			var input = lmnt.mask.replace(/#/g, "0");
+			$(testmask).val(input);
+			equal(testmask.value, input, "Result " + testmask.value);
+		});
+
+	});
+
+});

+ 36 - 0
qunit/tests_phonenl.js

@@ -0,0 +1,36 @@
+define([
+	"qunit",
+	"inputmask.dependencyLib",
+	"inputmask",
+	"../dist/inputmask/inputmask.date.extensions",
+	"../dist/inputmask/inputmask.extensions",
+	"../dist/inputmask/inputmask.numeric.extensions",
+	"../dist/inputmask/inputmask.phone.extensions",
+	"../extra/phone-codes/phone",
+	"../extra/phone-codes/phone-be",
+	"../extra/phone-codes/phone-nl",
+	"../extra/phone-codes/phone-ru",
+	"../extra/phone-codes/phone-uk",
+	"../dist/inputmask/inputmask.regex.extensions",
+	"prototypeExtensions",
+	"simulator"
+], function (qunit, $, Inputmask) {
+
+	qunit.module("Phone masks");
+
+	qunit.test("inputmask(\"phonenl\")", 181, function (assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		Inputmask("phonenl", {nullable: false}).mask(testmask);
+
+		testmask.focus();
+
+		$.each(Inputmask.prototype.defaults.aliases.phonenl.phoneCodes, function (ndx, lmnt) {
+			var input = lmnt.mask.replace(/#/g, "0");
+			$(testmask).val(input);
+			equal(testmask.value, input, "Result " + testmask.value);
+		});
+
+	});
+
+});

+ 36 - 0
qunit/tests_phoneru.js

@@ -0,0 +1,36 @@
+define([
+	"qunit",
+	"inputmask.dependencyLib",
+	"inputmask",
+	"../dist/inputmask/inputmask.date.extensions",
+	"../dist/inputmask/inputmask.extensions",
+	"../dist/inputmask/inputmask.numeric.extensions",
+	"../dist/inputmask/inputmask.phone.extensions",
+	"../extra/phone-codes/phone",
+	"../extra/phone-codes/phone-be",
+	"../extra/phone-codes/phone-nl",
+	"../extra/phone-codes/phone-ru",
+	"../extra/phone-codes/phone-uk",
+	"../dist/inputmask/inputmask.regex.extensions",
+	"prototypeExtensions",
+	"simulator"
+], function (qunit, $, Inputmask) {
+
+	qunit.module("Phone masks");
+
+	qunit.test("inputmask(\"phoneru\")", 181, function (assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		Inputmask("phoneru", {nullable: false}).mask(testmask);
+
+		testmask.focus();
+
+		$.each(Inputmask.prototype.defaults.aliases.phoneru.phoneCodes, function (ndx, lmnt) {
+			var input = lmnt.mask.replace(/#/g, "0");
+			$(testmask).val(input);
+			equal(testmask.value, input, "Result " + testmask.value);
+		});
+
+	});
+
+});