1 |
www |
1 |
"use strict";
|
|
|
2 |
|
|
|
3 |
describe("dropdownContainer:", function() {
|
|
|
4 |
|
|
|
5 |
beforeEach(function() {
|
|
|
6 |
intlSetup();
|
|
|
7 |
// insert input into the DOM so our visibility tests will work
|
|
|
8 |
input = $("<input>").appendTo("body");
|
|
|
9 |
});
|
|
|
10 |
|
|
|
11 |
afterEach(function() {
|
|
|
12 |
intlTeardown();
|
|
|
13 |
});
|
|
|
14 |
|
|
|
15 |
describe("init plugin with dropdownContainer=null", function() {
|
|
|
16 |
|
|
|
17 |
beforeEach(function() {
|
|
|
18 |
iti = window.intlTelInput(input[0], {
|
|
|
19 |
dropdownContainer: null,
|
|
|
20 |
});
|
|
|
21 |
});
|
|
|
22 |
|
|
|
23 |
it("adds the dropdown markup next to the input", function() {
|
|
|
24 |
expect(getListElement()).toExist();
|
|
|
25 |
});
|
|
|
26 |
|
|
|
27 |
describe("clicking the selected flag", function() {
|
|
|
28 |
|
|
|
29 |
beforeEach(function() {
|
|
|
30 |
getSelectedFlagContainer().click();
|
|
|
31 |
});
|
|
|
32 |
|
|
|
33 |
it("shows the dropdown", function() {
|
|
|
34 |
expect(getListElement()).toBeVisible();
|
|
|
35 |
});
|
|
|
36 |
|
|
|
37 |
it("clicking-off removes the markup again", function() {
|
|
|
38 |
$("body").click();
|
|
|
39 |
expect(getListElement()).not.toBeVisible();
|
|
|
40 |
});
|
|
|
41 |
|
|
|
42 |
});
|
|
|
43 |
|
|
|
44 |
});
|
|
|
45 |
|
|
|
46 |
describe("init plugin with dropdownContainer=document.body", function() {
|
|
|
47 |
|
|
|
48 |
beforeEach(function() {
|
|
|
49 |
iti = window.intlTelInput(input[0], {
|
|
|
50 |
dropdownContainer: document.body,
|
|
|
51 |
});
|
|
|
52 |
});
|
|
|
53 |
|
|
|
54 |
it("doesnt immediately add the markup to the DOM", function() {
|
|
|
55 |
expect($(".iti--container")).not.toExist();
|
|
|
56 |
});
|
|
|
57 |
|
|
|
58 |
describe("triggering the dropdown", function() {
|
|
|
59 |
|
|
|
60 |
beforeEach(function() {
|
|
|
61 |
getSelectedFlagContainer().click();
|
|
|
62 |
});
|
|
|
63 |
|
|
|
64 |
it("adds the markup to that element and makes it visible in the document", function() {
|
|
|
65 |
expect($("body>.iti--container")).toBeVisible();
|
|
|
66 |
});
|
|
|
67 |
|
|
|
68 |
it("selecting a country removes the markup again", function() {
|
|
|
69 |
$("body>.iti--container").find("li[data-country-code='gb']").click();
|
|
|
70 |
expect($("body>.iti--container")).not.toExist();
|
|
|
71 |
});
|
|
|
72 |
|
|
|
73 |
it("clicking-off removes the markup again", function() {
|
|
|
74 |
$("body").click();
|
|
|
75 |
expect($("body>.iti--container")).not.toExist();
|
|
|
76 |
});
|
|
|
77 |
|
|
|
78 |
});
|
|
|
79 |
|
|
|
80 |
});
|
|
|
81 |
|
|
|
82 |
});
|