1 |
www |
1 |
"use strict";
|
|
|
2 |
|
|
|
3 |
describe("excludeCountries option:", function() {
|
|
|
4 |
|
|
|
5 |
beforeEach(function() {
|
|
|
6 |
intlSetup();
|
|
|
7 |
input = $("<input>").wrap("div");
|
|
|
8 |
});
|
|
|
9 |
|
|
|
10 |
afterEach(function() {
|
|
|
11 |
intlTeardown();
|
|
|
12 |
});
|
|
|
13 |
|
|
|
14 |
it("init the plugin with excludeCountries=[] has all countries", function() {
|
|
|
15 |
iti = window.intlTelInput(input[0], {
|
|
|
16 |
excludeCountries: [],
|
|
|
17 |
});
|
|
|
18 |
expect(getListLength()).toEqual(totalCountries + defaultPreferredCountries);
|
|
|
19 |
});
|
|
|
20 |
|
|
|
21 |
describe("init the plugin with excludeCountries=[us, ca]", function() {
|
|
|
22 |
|
|
|
23 |
var excludeCountries = ["us", "ca"];
|
|
|
24 |
|
|
|
25 |
beforeEach(function() {
|
|
|
26 |
iti = window.intlTelInput(input[0], {
|
|
|
27 |
excludeCountries: excludeCountries,
|
|
|
28 |
preferredCountries: [],
|
|
|
29 |
});
|
|
|
30 |
});
|
|
|
31 |
|
|
|
32 |
it("excludes the US and Canada", function() {
|
|
|
33 |
var listItems = getListElement().find("li.country");
|
|
|
34 |
expect(listItems.filter("[data-country-code=us]")).not.toExist();
|
|
|
35 |
expect(listItems.filter("[data-country-code=ca]")).not.toExist();
|
|
|
36 |
expect(getListLength()).toEqual(totalCountries - excludeCountries.length);
|
|
|
37 |
});
|
|
|
38 |
|
|
|
39 |
it("defaults to the next in the list", function() {
|
|
|
40 |
expect(getSelectedFlagElement()).toHaveClass("iti__af");
|
|
|
41 |
});
|
|
|
42 |
|
|
|
43 |
it("typing +1 sets the flag to Dominican Republic", function() {
|
|
|
44 |
input.val("+");
|
|
|
45 |
triggerKeyOnInput("1");
|
|
|
46 |
expect(getSelectedFlagElement()).toHaveClass("iti__do");
|
|
|
47 |
});
|
|
|
48 |
|
|
|
49 |
});
|
|
|
50 |
|
|
|
51 |
});
|