123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- export default function(qunit, $, Inputmask) {
- qunit.module("Value formatting");
- qunit.test("Inputmask.format(\"2331973\", { alias: \"date\"})", function(assert) {
- var formattedValue = Inputmask.format("2331973", {
- alias: "date"
- });
- assert.equal(formattedValue, "23/03/1973", "Result " + formattedValue);
- });
- qunit.test("Inputmask.format(\"016501030020001DE1015170\", { mask: \"99 999 999 999 9999 \\D\\E*** 9999\"})", function(assert) {
- var formattedValue = Inputmask.format("016501030020001DE1015170", {
- mask: "99 999 999 999 9999 \\D\\E*** 9999"
- });
- assert.equal(formattedValue, "01 650 103 002 0001 DE101 5170", "Result " + formattedValue);
- });
- qunit.test("Inputmask.format(\"12\", { mask: \"$ 999999\", numericInput: true, placeholder: \"0\" }); - gigermocas", function(assert) {
- var formattedValue = Inputmask.format("12", {
- mask: "$ 999999",
- numericInput: true,
- placeholder: "0"
- });
- assert.equal(formattedValue, "$ 000012", "Result " + formattedValue);
- });
- qunit.test("Inputmask.format(\"1111111.11\" - ... autoGroup: true - swd120", function(assert) {
- var formattedValue = Inputmask.format("1111111.11", {
- alias: "decimal",
- radixPoint: ".",
- digits: 2,
- autoGroup: true,
- groupSeparator: ",",
- groupSize: 3,
- allowMinus: true
- });
- assert.equal(formattedValue, "1,111,111.11", "Result " + formattedValue);
- });
- qunit.test("Inputmask.format(phone, { mask: '(999) 999-9999' })); - krivaten", function(assert) {
- var phone = '5551112222';
- var formattedValue = Inputmask.format(phone, {
- mask: '(999) 999-9999'
- });
- assert.equal(formattedValue, "(555) 111-2222", "Result " + formattedValue);
- });
- qunit.test("format(62.91, { alias: 'numeric' } - penihel", function(assert) {
- var formattedValue = Inputmask.format(62.91, { alias: 'numeric' });
- assert.equal(formattedValue, "62.91", "Result " + formattedValue);
- });
- qunit.module("Value Validating");
- qunit.test("Inputmask.isValid(\"23/03/1973\", { alias: \"date\"})", function(assert) {
- var isValid = Inputmask.isValid("23/03/1973", {
- alias: "date"
- });
- assert.equal(isValid, true, "Result " + isValid);
- });
- qunit.test("Inputmask.isValid(\"01 650 103 002 0001 DE101 5170\", { mask: \"99 999 999 999 9999 \\D\\E*** 9999\"})", function(assert) {
- var isValid = Inputmask.isValid("01 650 103 002 0001 DE101 5170", {
- mask: "99 999 999 999 9999 \\D\\E*** 9999"
- });
- assert.equal(isValid, true, "Result " + isValid);
- });
- qunit.test("Inputmask.isValid email => false", function(assert) {
- var isValid = Inputmask.isValid("some.body@mail.c", {
- alias: "email"
- });
- assert.equal(isValid, true, "Result " + isValid);
- });
- qunit.test("Inputmask.isValid email => true", function(assert) {
- var isValid = Inputmask.isValid("some.body@mail.com", {
- alias: "email"
- });
- assert.equal(isValid, true, "Result " + isValid);
- });
- qunit.test("Inputmask.isValid email greedy => false", function(assert) {
- var isValid = Inputmask.isValid("some.body@mail.c", {
- alias: "email",
- greedy: true
- });
- assert.equal(isValid, true, "Result " + isValid);
- });
- qunit.test("Inputmask.isValid email greedy => true", function(assert) {
- var isValid = Inputmask.isValid("some.body@mail.com", {
- alias: "email",
- greedy: true
- });
- assert.equal(isValid, true, "Result " + isValid);
- });
- qunit.test("YoussefTaghlabi isValid(\"100\", { alias: \"integer\" }", function(assert) {
- var isValid = Inputmask.isValid("100", {
- alias: "integer"
- });
- assert.equal(isValid, true, "Result " + isValid);
- });
- qunit.test("YoussefTaghlabi isValid(\"100.00\", { alias: \"integer\" }", function(assert) {
- var isValid = Inputmask.isValid("100.00", {
- alias: "integer"
- });
- assert.equal(isValid, false, "Result " + isValid);
- });
- qunit.test("YoussefTaghlabi isValid(\"123\", { alias: \"decimal\" }", function(assert) {
- var isValid = Inputmask.isValid("123", {
- alias: "decimal"
- });
- assert.equal(isValid, true, "Result " + isValid);
- });
- qunit.test("YoussefTaghlabi isValid(\"123.45\", { alias: \"decimal\" }", function(assert) {
- var isValid = Inputmask.isValid("123.45", {
- alias: "decimal"
- });
- assert.equal(isValid, true, "Result " + isValid);
- });
- qunit.test("YoussefTaghlabi isValid(\"123456.78\", { alias: \"decimal\" }", function(assert) {
- var isValid = Inputmask.isValid("123456.78", {
- alias: "decimal"
- });
- assert.equal(isValid, true, "Result " + isValid);
- });
- qunit.test("YoussefTaghlabi isValid(\"123,456.78\", { alias: \"decimal\" }", function(assert) {
- var isValid = Inputmask.isValid("123,456.78", {
- alias: "decimal",
- radixPoint: ".",
- groupSeparator: ",",
- groupSize: 3,
- autoGroup: true
- });
- assert.equal(isValid, true, "Result " + isValid);
- });
- qunit.test("YoussefTaghlabi isValid(\"12,\", { alias: \"decimal\" }", function(assert) {
- var isValid = Inputmask.isValid("12,", {
- alias: "decimal",
- radixPoint: ".",
- groupSeparator: ",",
- groupSize: 3
- });
- assert.equal(isValid, false, "Result " + isValid);
- });
- qunit.test("YoussefTaghlabi isValid(\"12,1.45\", { alias: \"decimal\" }", function(assert) {
- var isValid = Inputmask.isValid("12,1.45", {
- alias: "decimal",
- radixPoint: ".",
- groupSeparator: ",",
- groupSize: 3
- });
- assert.equal(isValid, false, "Result " + isValid);
- });
- qunit.test("YoussefTaghlabi isValid(\"12,345.67\", { alias: \"decimal\" }", function(assert) {
- var isValid = Inputmask.isValid("12,345.67", {
- alias: "decimal",
- radixPoint: ".",
- groupSeparator: ",",
- groupSize: 3,
- autoGroup: true
- });
- assert.equal(isValid, true, "Result " + isValid);
- });
- qunit.test("thomstark isValid(\"12lbs\", {mask:\"99[9]lb\\s\", greedy:false, skipOptionalPartCharacter: \"\", \"clearIncomplete\":true}", function(assert) {
- var isValid = Inputmask.isValid("12lbs", {
- mask: "99[9]lb\\s",
- greedy: false,
- skipOptionalPartCharacter: "",
- "clearIncomplete": true
- });
- assert.equal(isValid, true, "Result " + isValid);
- });
- qunit.test("thomstark isValid(\"1'2\"\", {mask:\"9'9[9]\"\", greedy:false, skipOptionalPartCharacter: \"\", \"clearIncomplete\":true}", function(assert) {
- var isValid = Inputmask.isValid("1'2\"", {
- mask: "9'9[9]\"",
- greedy: false,
- skipOptionalPartCharacter: "",
- "clearIncomplete": true
- });
- assert.equal(isValid, true, "Result " + isValid);
- });
- qunit.test("thomstark isValid(\"12lbs\", {mask:\"99{1,2}lb\\s\", greedy:false, skipOptionalPartCharacter: \"\", \"clearIncomplete\":true}", function(assert) {
- var isValid = Inputmask.isValid("12lbs", {
- mask: "99{1,2}lb\\s",
- greedy: false,
- skipOptionalPartCharacter: "",
- "clearIncomplete": true
- });
- assert.equal(isValid, true, "Result " + isValid);
- });
- qunit.test("thomstark isValid(\"9'9{1,2}\", {mask:\"9'9[9]\"\", greedy:false, skipOptionalPartCharacter: \"\", \"clearIncomplete\":true}", function(assert) {
- var isValid = Inputmask.isValid("1'2\"", {
- mask: "9'9{1,2}\"",
- greedy: false,
- skipOptionalPartCharacter: "",
- "clearIncomplete": true
- });
- assert.equal(isValid, true, "Result " + isValid);
- });
- qunit.test("a13x3y isValid(\"some_body@mail.com\", {alias:\"email\"}", function(assert) {
- var isValid = Inputmask.isValid("some_body@mail.com", {
- alias: "email"
- });
- assert.equal(isValid, true, "Result " + isValid);
- });
- qunit.test("Inputmask(\"99-99[ 99/99]\").isValid(\"03-11\") - pricejt", function(assert) {
- var isValid = Inputmask("99-99[ 99/99]").isValid("03-11");
- assert.equal(isValid, true, "Result " + isValid);
- });
- qunit.module("Value unmasking");
- qunit.test("inputmask.unmask(\"23/03/1973\", { alias: \"dd/mm/yyyy\" })", function(assert) {
- var unmasked = Inputmask.unmask("23/03/1973", {
- alias: "dd/mm/yyyy"
- });
- assert.equal(unmasked, "23031973", "Result " + unmasked);
- });
- };
|