1 |
www |
1 |
"use strict";
|
|
|
2 |
|
|
|
3 |
describe("autoPlaceholder: testing input with no placeholder", function() {
|
|
|
4 |
|
|
|
5 |
beforeEach(function() {
|
|
|
6 |
intlSetup(true);
|
|
|
7 |
input = $("<input>").wrap("div");
|
|
|
8 |
});
|
|
|
9 |
|
|
|
10 |
afterEach(function() {
|
|
|
11 |
intlTeardown();
|
|
|
12 |
});
|
|
|
13 |
|
|
|
14 |
it("init plugin with autoPlaceholder=off leaves the placeholder empty", function() {
|
|
|
15 |
iti = window.intlTelInput(input[0], {
|
|
|
16 |
autoPlaceholder: "off"
|
|
|
17 |
});
|
|
|
18 |
expect(input.attr("placeholder")).toBeUndefined();
|
|
|
19 |
});
|
|
|
20 |
|
|
|
21 |
describe("init plugin with autoPlaceholder=polite and nationalMode=true", function() {
|
|
|
22 |
|
|
|
23 |
beforeEach(function() {
|
|
|
24 |
iti = window.intlTelInput(input[0], {
|
|
|
25 |
autoPlaceholder: "polite",
|
|
|
26 |
nationalMode: true
|
|
|
27 |
});
|
|
|
28 |
});
|
|
|
29 |
|
|
|
30 |
it("sets the placeholder to an example national number for the US", function() {
|
|
|
31 |
expect(input.attr("placeholder")).toEqual("(201) 555-0123");
|
|
|
32 |
});
|
|
|
33 |
|
|
|
34 |
describe("changing the country to the UK", function() {
|
|
|
35 |
|
|
|
36 |
beforeEach(function() {
|
|
|
37 |
selectFlag("gb");
|
|
|
38 |
});
|
|
|
39 |
|
|
|
40 |
it("updates the placeholder to an example national number for the UK", function() {
|
|
|
41 |
expect(input.attr("placeholder")).toEqual("07400 123456");
|
|
|
42 |
});
|
|
|
43 |
|
|
|
44 |
});
|
|
|
45 |
|
|
|
46 |
});
|
|
|
47 |
|
|
|
48 |
describe("init plugin with autoPlaceholder=polite and nationalMode=false", function() {
|
|
|
49 |
|
|
|
50 |
beforeEach(function() {
|
|
|
51 |
iti = window.intlTelInput(input[0], {
|
|
|
52 |
autoPlaceholder: "polite",
|
|
|
53 |
nationalMode: false
|
|
|
54 |
});
|
|
|
55 |
});
|
|
|
56 |
|
|
|
57 |
it("sets the placeholder to an example international number for the US", function() {
|
|
|
58 |
expect(input.attr("placeholder")).toEqual("+1 201-555-0123");
|
|
|
59 |
});
|
|
|
60 |
|
|
|
61 |
describe("changing the country to the UK", function() {
|
|
|
62 |
|
|
|
63 |
beforeEach(function() {
|
|
|
64 |
selectFlag("gb");
|
|
|
65 |
});
|
|
|
66 |
|
|
|
67 |
it("updates the placeholder to an example national number for the UK", function() {
|
|
|
68 |
expect(input.attr("placeholder")).toEqual("+44 7400 123456");
|
|
|
69 |
});
|
|
|
70 |
|
|
|
71 |
});
|
|
|
72 |
|
|
|
73 |
});
|
|
|
74 |
|
|
|
75 |
});
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
describe("autoPlaceholder: testing input with an initial placeholder", function() {
|
|
|
81 |
|
|
|
82 |
var placeholder = "lol";
|
|
|
83 |
|
|
|
84 |
beforeEach(function() {
|
|
|
85 |
intlSetup(true);
|
|
|
86 |
input = $("<input placeholder='"+placeholder+"'>");
|
|
|
87 |
});
|
|
|
88 |
|
|
|
89 |
afterEach(function() {
|
|
|
90 |
intlTeardown();
|
|
|
91 |
});
|
|
|
92 |
|
|
|
93 |
it("init plugin with autoPlaceholder=off leaves the placeholder the same", function() {
|
|
|
94 |
iti = window.intlTelInput(input[0], {
|
|
|
95 |
autoPlaceholder: "off"
|
|
|
96 |
});
|
|
|
97 |
expect(input.attr("placeholder")).toEqual(placeholder);
|
|
|
98 |
});
|
|
|
99 |
|
|
|
100 |
it("init plugin with autoPlaceholder=polite leaves the placeholder the same", function() {
|
|
|
101 |
iti = window.intlTelInput(input[0], {
|
|
|
102 |
autoPlaceholder: "polite"
|
|
|
103 |
});
|
|
|
104 |
expect(input.attr("placeholder")).toEqual(placeholder);
|
|
|
105 |
});
|
|
|
106 |
|
|
|
107 |
it("init plugin with autoPlaceholder=aggressive overwrites the placeholder", function() {
|
|
|
108 |
iti = window.intlTelInput(input[0], {
|
|
|
109 |
autoPlaceholder: "aggressive"
|
|
|
110 |
});
|
|
|
111 |
expect(input.attr("placeholder")).toEqual("(201) 555-0123");
|
|
|
112 |
});
|
|
|
113 |
|
|
|
114 |
});
|