Blame view

vendor/bower-asset/jquery.inputmask/qunit/tests_phoneru.js 1.6 KB
2e86c939   xu   “首次提交”
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
define([
	"qunit",
	"../dist/inputmask/dependencyLibs/inputmask.dependencyLib",
	"../dist/inputmask/inputmask.date.extensions",
	"../dist/inputmask/inputmask.extensions",
	"../dist/inputmask/inputmask.numeric.extensions",
	"../dist/inputmask/inputmask.phone.extensions",
	"../dist/inputmask/phone-codes/phone",
	"../dist/inputmask/phone-codes/phone-be",
	"../dist/inputmask/phone-codes/phone-nl",
	"../dist/inputmask/phone-codes/phone-ru",
	"../dist/inputmask/phone-codes/phone-uk",
	"prototypeExtensions",
	"simulator"
], function (qunit, $, Inputmask) {

	qunit.module("Phoneru masks");


	for (var i = 0; i < Inputmask.prototype.aliases.phoneru.phoneCodes.length; i += 25) {
		qunit.test("inputmask(\"phoneru\") - " + i + "-" + (i + 25), function (assert) {
				var i = assert.test.testName.match(/\d+$/);
				i = i - 25;
				var $fixture = $("#qunit-fixture");
				$fixture.append('<input type="text" id="testmask" />');
				var testmask = document.getElementById("testmask");
				Inputmask("phoneru", {nullable: false}).mask(testmask);

				testmask.focus();

				$.each(Inputmask.prototype.aliases.phoneru.phoneCodes.slice(i, i + 25), function (ndx, lmnt) {
					var ndx = 1, input, expected = lmnt.mask;
					while (expected.match(/#/)) {
						expected = expected.replace(/#/, ndx++);
						if (ndx > 9) ndx = 1;
					}
					input = expected;
					//input = input.replace(/\+/g, "");
					input = input.replace(/\(/g, "");
					// input = input.replace(/\)/g, "");
					input = input.replace(/-/g, "");

					$(testmask).val(input);
					assert.equal(testmask.value, expected, "Result " + testmask.value);
				});
			}
		)
	}
})
;