tests_phoneru.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. export default function (qunit, $, Inputmask) {
  2. qunit.module("Phoneru masks");
  3. for (var i = 0; i < Inputmask.prototype.aliases.phoneru.phoneCodes.length; i += 25) {
  4. qunit.test("inputmask(\"phoneru\") - " + i + "-" + (i + 25), function (assert) {
  5. var i = assert.test.testName.match(/\d+$/);
  6. i = i - 25;
  7. var $fixture = $("#qunit-fixture");
  8. $fixture.append('<input type="text" id="testmask" />');
  9. var testmask = document.getElementById("testmask");
  10. Inputmask("phoneru", {nullable: false}).mask(testmask);
  11. testmask.focus();
  12. $.each(Inputmask.prototype.aliases.phoneru.phoneCodes.slice(i, i + 25), function (ndx, lmnt) {
  13. var ndx = 1, input, expected = lmnt.mask;
  14. while (expected.match(/#/)) {
  15. expected = expected.replace(/#/, ndx++);
  16. if (ndx > 9) ndx = 1;
  17. }
  18. input = expected;
  19. //input = input.replace(/\+/g, "");
  20. input = input.replace(/\(/g, "");
  21. // input = input.replace(/\)/g, "");
  22. input = input.replace(/-/g, "");
  23. $(testmask).val(input);
  24. assert.equal(testmask.value, expected, "Result " + testmask.value);
  25. });
  26. }
  27. )
  28. }
  29. };