tests_phone_world.js 881 B

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