Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 www 1
"use strict";
2
 
3
describe("formatOnDisplay: testing input containing valid US number", function() {
4
 
5
  var validUsNumber = "+17024181234";
6
 
7
  beforeEach(function() {
8
    intlSetup(true);
9
    input = $("<input value='"+validUsNumber+"'>");
10
  });
11
 
12
  afterEach(function() {
13
    intlTeardown();
14
  });
15
 
16
  describe("init plugin with formatOnDisplay=false", function() {
17
 
18
    beforeEach(function() {
19
      iti = window.intlTelInput(input[0], {
20
        formatOnDisplay: false
21
      });
22
    });
23
 
24
    it("doesnt format the number on init", function() {
25
      expect(getInputVal()).toEqual(validUsNumber);
26
    });
27
 
28
    it("calling setNumber doesnt format the number", function() {
29
      var anotherNumber = "+14154181234";
30
      iti.setNumber(anotherNumber);
31
      expect(getInputVal()).toEqual(anotherNumber);
32
    });
33
 
34
  });
35
 
36
  describe("init plugin with formatOnDisplay=true and nationalMode=true", function() {
37
 
38
    beforeEach(function() {
39
      iti = window.intlTelInput(input[0], {
40
        formatOnDisplay: true,
41
        nationalMode: true
42
      });
43
    });
44
 
45
    it("sets the number to national format on init", function() {
46
      expect(getInputVal()).toEqual("(702) 418-1234");
47
    });
48
 
49
    it("calling setNumber formats the number to national format", function() {
50
      iti.setNumber("+14154181234");
51
      expect(getInputVal()).toEqual("(415) 418-1234");
52
    });
53
 
54
  });
55
 
56
  describe("init plugin with formatOnDisplay=true and nationalMode=false", function() {
57
 
58
    beforeEach(function() {
59
      iti = window.intlTelInput(input[0], {
60
        formatOnDisplay: true,
61
        nationalMode: false
62
      });
63
    });
64
 
65
    it("sets the number to intl format on init", function() {
66
      expect(getInputVal()).toEqual("+1 702-418-1234");
67
    });
68
 
69
    it("calling setNumber formats the number to international format", function() {
70
      iti.setNumber("+14154181234");
71
      expect(getInputVal()).toEqual("+1 415-418-1234");
72
    });
73
 
74
  });
75
 
76
});