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 dropdown: init plugin with nationalMode=false", function() {
4
 
5
  beforeEach(function() {
6
    intlSetup();
7
    input = $("<input>").appendTo("body");
8
    // nationalMode=false because we're playing with dial codes
9
    iti = window.intlTelInput(input[0], {
10
      nationalMode: false
11
    });
12
  });
13
 
14
  afterEach(function() {
15
    intlTeardown();
16
  });
17
 
18
  it("normal input: clicking the selected flag opens the dropdown", function() {
19
    getSelectedFlagContainer()[0].click();
20
    expect(getListElement()).toBeVisible();
21
  });
22
 
23
  it("disabled input: clicking the selected flag does not open the dropdown", function() {
24
    input.prop("disabled", true);
25
    getSelectedFlagContainer()[0].click();
26
    expect(getListElement()).not.toBeVisible();
27
  });
28
 
29
 
30
 
31
  describe("clicking the selected flag to open the dropdown", function() {
32
 
33
    beforeEach(function() {
34
      getSelectedFlagContainer()[0].click();
35
    });
36
 
37
    it("opens the dropdown with the top item marked as active and highlighted", function() {
38
      expect(getListElement()).toBeVisible();
39
      var topItem = getListElement().find("li.iti__country:first");
40
      expect(topItem).toHaveClass("iti__active iti__highlight");
41
    });
42
 
43
    it("clicking it again closes the dropdown", function() {
44
      getSelectedFlagContainer()[0].click();
45
      expect(getListElement()).not.toBeVisible();
46
    });
47
 
48
    it("clicking off closes the dropdown", function() {
49
      $("body")[0].click();
50
      expect(getListElement()).not.toBeVisible();
51
    });
52
 
53
 
54
 
55
    describe("selecting a new country item", function() {
56
 
57
      var countryCode = "ca";
58
 
59
      beforeEach(function() {
60
        getListElement().find("li[data-country-code='" + countryCode + "']")[0].click();
61
      });
62
 
63
      it("updates the selected flag", function() {
64
        expect(getSelectedFlagElement()).toHaveClass(`iti__${countryCode}`);
65
      });
66
 
67
      it("updates the dial code", function() {
68
        expect(getInputVal()).toEqual("+1");
69
      });
70
 
71
      // this was a bug
72
      it("adding a space doesnt reset to the default country for that dial code", function() {
73
        triggerKeyOnInput(" ");
74
        expect(getSelectedFlagElement()).toHaveClass(`iti__${countryCode}`);
75
      });
76
 
77
    });
78
 
79
  });
80
 
81
});