tests_setvalue.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. export default function(qunit, $, Inputmask)
  2. {
  3. qunit.module("Set value with fn.val");
  4. qunit.test("inputmask(\"decimal\") ~ value=\"123.45\"", function (assert) {
  5. var $fixture = $("#qunit-fixture");
  6. $fixture.append('<input type="text" id="testmask" />');
  7. var testmask = document.getElementById("testmask");
  8. Inputmask("decimal").mask(testmask);
  9. $("#testmask").val("123.45");
  10. assert.equal(testmask.value, "123.45", "Result " + testmask.value);
  11. });
  12. qunit.test("inputmask(\"9\") ~ value=\"1\"", function (assert) {
  13. var $fixture = $("#qunit-fixture");
  14. $fixture.append('<input type="text" id="testmask" />');
  15. var testmask = document.getElementById("testmask");
  16. Inputmask("9").mask(testmask);
  17. $("#testmask").val("1");
  18. assert.equal(testmask.value, "1", "Result " + testmask.value);
  19. });
  20. qunit.test("inputmask(\"decimal\") ~ .val(\"123.45\") - disabled input", function (assert) {
  21. var $fixture = $("#qunit-fixture");
  22. $fixture.append('<input type="text" id="testmask" disabled="disabled" />');
  23. var testmask = document.getElementById("testmask");
  24. Inputmask("decimal").mask(testmask);
  25. $("#testmask").val("123.45");
  26. assert.equal(testmask.value, "123.45", "Result " + testmask.value);
  27. });
  28. qunit.test("inputmask(\"mm/yyyy\") ~ .val(\"031973\") - disabled input", function (assert) {
  29. var $fixture = $("#qunit-fixture");
  30. $fixture.append('<input type="text" id="testmask" disabled="disabled" />');
  31. var testmask = document.getElementById("testmask");
  32. Inputmask("mm/yyyy").mask(testmask);
  33. $("#testmask").val("031973");
  34. assert.equal(testmask.value, "03/1973", "Result " + testmask.value);
  35. });
  36. qunit.test("inputmask({ \"mask\": \"(999) 999-9999\" }) ~ .val(\"8144419449\") - type=\"tel\" - bodrick", function (assert) {
  37. var $fixture = $("#qunit-fixture");
  38. $fixture.append('<input type="tel" id="testmask" disabled="disabled" />');
  39. var testmask = document.getElementById("testmask");
  40. Inputmask({
  41. "mask": "(999) 999-9999"
  42. }).mask(testmask);
  43. $("#testmask").val("8144419449");
  44. assert.equal(testmask.value, "(814) 441-9449", "Result " + testmask.value);
  45. });
  46. qunit.test(".inputmask('decimal',{ alias:\"decimal\",integerDigits:9,digits:3,digitsOptional: false,placeholder: '0' }); - '2000.000' - vijjj", function (assert) {
  47. var $fixture = $("#qunit-fixture");
  48. $fixture.append('<input type="text" id="testmask" />');
  49. var testmask = document.getElementById("testmask");
  50. Inputmask('decimal', {
  51. alias: "decimal",
  52. integerDigits: 9,
  53. digits: 3,
  54. digitsOptional: false,
  55. placeholder: '0'
  56. }).mask(testmask);
  57. $("#testmask").val('2000.000');
  58. assert.equal(testmask.value, "2000.000", "Result " + testmask.value);
  59. });
  60. qunit.test(".inputmask('decimal',{ alias:\"decimal\",integerDigits:9,digits:3,digitsOptional: false,placeholder: '0' }); - 3000.000 - vijjj", function (assert) {
  61. var $fixture = $("#qunit-fixture");
  62. $fixture.append('<input type="text" id="testmask" />');
  63. var testmask = document.getElementById("testmask");
  64. Inputmask('decimal', {
  65. alias: "decimal",
  66. integerDigits: 9,
  67. digits: 3,
  68. digitsOptional: false,
  69. placeholder: '0'
  70. }).mask(testmask);
  71. $("#testmask").val(3000.000);
  72. assert.equal(testmask.value, "3000.000", "Result " + testmask.value);
  73. });
  74. qunit.test(".inputmask('decimal',{ alias:\"decimal\",integerDigits:9,digits:3,digitsOptional: false,placeholder: '0' }); - '4000.00' - vijjj", function (assert) {
  75. var $fixture = $("#qunit-fixture");
  76. $fixture.append('<input type="text" id="testmask" />');
  77. var testmask = document.getElementById("testmask");
  78. Inputmask('decimal', {
  79. alias: "decimal",
  80. integerDigits: 9,
  81. digits: 3,
  82. digitsOptional: false,
  83. placeholder: '0'
  84. }).mask(testmask);
  85. $("#testmask").val('4000.00');
  86. assert.equal(testmask.value, "4000.000", "Result " + testmask.value);
  87. });
  88. qunit.test(".inputmask('decimal',{ alias:\"decimal\",integerDigits:9,digits:3,digitsOptional: false,placeholder: '0' }); - '5000.000' - vijjj", function (assert) {
  89. var $fixture = $("#qunit-fixture");
  90. $fixture.append('<input type="text" id="testmask" />');
  91. var testmask = document.getElementById("testmask");
  92. Inputmask('decimal', {
  93. alias: "decimal",
  94. integerDigits: 9,
  95. digits: 3,
  96. digitsOptional: false,
  97. placeholder: '0'
  98. }).mask(testmask);
  99. document.getElementById('testmask').value = '5000.000';
  100. assert.equal(testmask.value, "5000.000", "Result " + testmask.value);
  101. });
  102. qunit.test(".inputmask(\"mask\", {\"mask\": \"+7 (999) 999-99-99\"}); - \"+7 (705) 123-45-67\" - serious-andy", function (assert) {
  103. var $fixture = $("#qunit-fixture");
  104. $fixture.append('<input type="text" id="testmask" />');
  105. var testmask = document.getElementById("testmask");
  106. Inputmask("mask", {
  107. "mask": "+7 (999) 999-99-99"
  108. }).mask(testmask);
  109. $("#testmask").val('+7 (705) 123-45-67');
  110. assert.equal(testmask.value, "+7 (705) 123-45-67", "Result " + testmask.value);
  111. });
  112. qunit.test(".inputmask(\"mask\", {\"mask\": \"+375 (99) 999-99-99\"}); - \"+375 (37) 999-99-99\" - PavelTyk", function (assert) {
  113. var $fixture = $("#qunit-fixture");
  114. $fixture.append('<input type="text" id="testmask" />');
  115. var testmask = document.getElementById("testmask");
  116. Inputmask("mask", {
  117. "mask": "+375 (99) 999-99-99"
  118. }).mask(testmask);
  119. $("#testmask").val('+375 (37) 999-99-99');
  120. assert.equal(testmask.value, "+375 (37) 999-99-99", "Result " + testmask.value);
  121. });
  122. qunit.test(".inputmask(\"mask\", {\"mask\": \"+7(999)999-99-99\"}); - '7771231234' + '' - moongrate", function (assert) {
  123. var $fixture = $("#qunit-fixture"), done = assert.async();
  124. $fixture.append('<input type="text" id="testmask" />');
  125. var testmask = document.getElementById("testmask");
  126. Inputmask("mask", {
  127. "mask": "+7(999)999-99-99"
  128. }).mask(testmask);
  129. testmask.focus();
  130. setTimeout(function () {
  131. $("#testmask").Type('7771231234');
  132. $("#testmask").val(testmask.value);
  133. assert.equal(testmask.value, "+7(777)123-12-34", "Result " + testmask.value);
  134. done();
  135. }, 0);
  136. });
  137. };