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("using input: ", function() {
4
 
5
  beforeEach(function() {
6
    intlSetup();
7
  });
8
 
9
  afterEach(function() {
10
    intlTeardown();
11
  });
12
 
13
 
14
 
15
  describe("init plugin with nationalMode=false", function() {
16
 
17
    beforeEach(function() {
18
      input = $("<input>").wrap("div");
19
      // nationalMode=false because we want to play with dial codes
20
      iti = window.intlTelInput(input[0], {
21
        nationalMode: false
22
      });
23
    });
24
 
25
 
26
 
27
    describe("typing a number with a different dial code", function() {
28
 
29
      beforeEach(function() {
30
        input.val("+44 1234567");
31
        triggerKeyOnInput(" ");
32
      });
33
 
34
      it("updates the selected flag", function() {
35
        expect(getSelectedFlagElement()).toHaveClass("iti__gb");
36
      });
37
 
38
      // this was a bug
39
      it("clearing the input again does not change the selected flag", function() {
40
        input.val("");
41
        triggerKeyOnInput(" ");
42
        expect(getSelectedFlagElement()).toHaveClass("iti__gb");
43
      });
44
 
45
    });
46
 
47
 
48
 
49
    describe("typing a dial code containing a space", function() {
50
 
51
      var telNo = "98765432",
52
        key = "1";
53
 
54
      beforeEach(function() {
55
        input.val("+4 4 " + telNo);
56
        triggerKeyOnInput(key);
57
      });
58
 
59
      it("still updates the flag correctly", function() {
60
        expect(getSelectedFlagElement()).toHaveClass("iti__gb");
61
      });
62
 
63
      it("then changing the flag updates the number correctly", function() {
64
        selectFlag("zw");
65
        expect(getInputVal()).toEqual("+263 " + telNo + key);
66
      });
67
 
68
    });
69
 
70
 
71
 
72
    describe("typing a dial code containing a dot", function() {
73
 
74
      var telNo = "98765432",
75
        key = "1";
76
 
77
      beforeEach(function() {
78
        input.val("+4.4 " + telNo);
79
        triggerKeyOnInput(key);
80
      });
81
 
82
      it("still updates the flag correctly", function() {
83
        expect(getSelectedFlagElement()).toHaveClass("iti__gb");
84
      });
85
 
86
      it("then changing the flag updates the number correctly", function() {
87
        selectFlag("zw");
88
        expect(getInputVal()).toEqual("+263 " + telNo + key);
89
      });
90
 
91
    });
92
 
93
 
94
 
95
    describe("typing a bangladesh intl dial code", function() {
96
 
97
      beforeEach(function() {
98
        input.val("+880");
99
        triggerKeyOnInput(" ");
100
      });
101
 
102
      it("selects the bangladesh flag", function() {
103
        expect(getSelectedFlagElement()).toHaveClass("iti__bd");
104
      });
105
 
106
      // this was a bug: https://github.com/jackocnr/intl-tel-input/issues/533
107
      describe("adding a 1 at the beginning", function() {
108
 
109
        beforeEach(function() {
110
          input.val("+1880");
111
          triggerKeyOnInput(" ");
112
        });
113
 
114
        it("changes to US flag", function() {
115
          expect(getSelectedFlagElement()).toHaveClass("iti__us");
116
        });
117
 
118
      });
119
 
120
    });
121
 
122
  });
123
 
124
 
125
 
126
 
127
  describe("init plugin", function() {
128
 
129
    beforeEach(function() {
130
      input = $("<input>").wrap("div");
131
      iti = window.intlTelInput(input[0]);
132
    });
133
 
134
    describe("selecting Canada and then typing a regionless number", function() {
135
 
136
      beforeEach(function() {
137
        selectFlag("ca");
138
        input.val("8005551212").keyup();
139
      });
140
 
141
      it("leaves canada selected", function() {
142
        expect(getSelectedFlagElement()).toHaveClass("iti__ca");
143
      });
144
 
145
    });
146
 
147
  });
148
 
149
});