tests_escape.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. export default function(qunit, $, Inputmask) {
  2. qunit.module("Escape character");
  3. qunit.test("inputmask(\"9\\|9\")", function(assert) {
  4. var $fixture = $("#qunit-fixture");
  5. $fixture.append('<input type="text" id="testmask" />');
  6. var testmask = document.getElementById("testmask");
  7. var input = $("#testmask");
  8. Inputmask("9\\|9").mask(testmask);
  9. testmask.focus();
  10. $("#testmask").Type("23");
  11. assert.equal(testmask.value, "2|3", "Result " + testmask.value);
  12. });
  13. qunit.test("inputmask(\"9\\[9\\]\")", function(assert) {
  14. var $fixture = $("#qunit-fixture");
  15. $fixture.append('<input type="text" id="testmask" />');
  16. var testmask = document.getElementById("testmask");
  17. var input = $("#testmask");
  18. Inputmask("9\\[9\\]").mask(testmask);
  19. testmask.focus();
  20. $("#testmask").Type("23");
  21. assert.equal(testmask.value, "2[3]", "Result " + testmask.value);
  22. });
  23. qunit.test("inputmask(\"9\\\\9\")", function(assert) {
  24. var $fixture = $("#qunit-fixture");
  25. $fixture.append('<input type="text" id="testmask" />');
  26. var testmask = document.getElementById("testmask");
  27. var input = $("#testmask");
  28. Inputmask("9\\\\9").mask(testmask);
  29. testmask.focus();
  30. $("#testmask").Type("23");
  31. assert.equal(testmask.value, "2\\3", "Result " + testmask.value);
  32. });
  33. qunit.test("inputmask(\"9\\{9\\}\")", function(assert) {
  34. var $fixture = $("#qunit-fixture");
  35. $fixture.append('<input type="text" id="testmask" />');
  36. var testmask = document.getElementById("testmask");
  37. Inputmask("9\\{9\\}").mask(testmask);
  38. testmask.focus();
  39. $("#testmask").Type("23");
  40. assert.equal(testmask.value, "2{3}", "Result " + testmask.value);
  41. });
  42. qunit.test("inputmask(\"9\\(9\\)\")", function(assert) {
  43. var $fixture = $("#qunit-fixture");
  44. $fixture.append('<input type="text" id="testmask" />');
  45. var testmask = document.getElementById("testmask");
  46. Inputmask("9\\(9\\)").mask(testmask);
  47. testmask.focus();
  48. $("#testmask").Type("23");
  49. assert.equal(testmask.value, "2(3)", "Result " + testmask.value);
  50. });
  51. qunit.test("inputmask(\"9\\?9\")", function(assert) {
  52. var $fixture = $("#qunit-fixture");
  53. $fixture.append('<input type="text" id="testmask" />');
  54. var testmask = document.getElementById("testmask");
  55. Inputmask("9\\?9").mask(testmask);
  56. testmask.focus();
  57. $("#testmask").Type("23");
  58. assert.equal(testmask.value, "2?3", "Result " + testmask.value);
  59. });
  60. qunit.test("inputmask(\"\\9999\") value not mask", function(assert) {
  61. var $fixture = $("#qunit-fixture");
  62. $fixture.append('<input type="text" value="999" id="testmask" />');
  63. var testmask = document.getElementById("testmask");
  64. Inputmask("\\9999", {
  65. autoUnmask: true
  66. }).mask(testmask);
  67. testmask.focus();
  68. assert.equal(testmask.inputmask._valueGet(), "9999", "Result " + testmask.inputmask._valueGet());
  69. });
  70. };