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("autoHideDialCode option:", function() {
4
 
5
  var defaultDialCode = "+1";
6
 
7
  beforeEach(function() {
8
    intlSetup();
9
 
10
    // must be in DOM for focus to work
11
    input = $("<input>").appendTo("body");
12
  });
13
 
14
  afterEach(function() {
15
    intlTeardown();
16
  });
17
 
18
 
19
  describe("init plugin with autoHideDialCode=true and nationalMode=false", function() {
20
 
21
    beforeEach(function() {
22
      iti = window.intlTelInput(input[0], {
23
        autoHideDialCode: true,
24
        nationalMode: false
25
      });
26
    });
27
 
28
    it("does not automatically insert the default dial code", function() {
29
      expect(getInputVal()).toEqual("");
30
    });
31
 
32
    describe("selecting a country", function() {
33
 
34
      beforeEach(function() {
35
        selectFlag("gb");
36
      });
37
 
38
      it("adds the dial code", function() {
39
        expect(getInputVal()).toEqual("+44");
40
      });
41
 
42
      it("blurring the input removes it again", function() {
43
        triggerInputEvent("blur");
44
        expect(getInputVal()).toEqual("");
45
      });
46
 
47
    });
48
 
49
 
50
 
51
    describe("with a phone number", function() {
52
 
53
      var number = "+1 702 987 2345";
54
 
55
      beforeEach(function() {
56
        input.val(number);
57
      });
58
 
59
      it("focusing and blurring the input doesn't change it", function() {
60
        triggerInputEvent("focus");
61
        expect(getInputVal()).toEqual(number);
62
        triggerInputEvent("blur");
63
        expect(getInputVal()).toEqual(number);
64
      });
65
 
66
    });
67
 
68
  });
69
 
70
 
71
  describe("init plugin with autoHideDialCode=false and nationalMode=false", function() {
72
 
73
    beforeEach(function() {
74
      iti = window.intlTelInput(input[0], {
75
        autoHideDialCode: false,
76
        nationalMode: false
77
      });
78
    });
79
 
80
    it("automatically inserts the default dial code", function() {
81
      expect(getInputVal()).toEqual(defaultDialCode);
82
    });
83
 
84
    it("focusing and bluring the input dont change the val", function() {
85
      triggerInputEvent("focus");
86
      expect(getInputVal()).toEqual(defaultDialCode);
87
      triggerInputEvent("blur");
88
      expect(getInputVal()).toEqual(defaultDialCode);
89
    });
90
 
91
 
92
    describe("with a phone number", function() {
93
 
94
      var number = "+1 702 987 2345";
95
 
96
      beforeEach(function() {
97
        input.val(number);
98
      });
99
 
100
      it("focusing and blurring the input doesn't change it", function() {
101
        triggerInputEvent("focus");
102
        expect(getInputVal()).toEqual(number);
103
        triggerInputEvent("blur");
104
        expect(getInputVal()).toEqual(number);
105
      });
106
 
107
    });
108
 
109
  });
110
 
111
});