1 |
www |
1 |
"use strict";
|
|
|
2 |
|
|
|
3 |
describe("destroy: init plugin to test public method destroy", function() {
|
|
|
4 |
|
|
|
5 |
beforeEach(function() {
|
|
|
6 |
intlSetup();
|
|
|
7 |
input = $("<input>").wrap("div");
|
|
|
8 |
iti = window.intlTelInput(input[0]);
|
|
|
9 |
});
|
|
|
10 |
|
|
|
11 |
afterEach(function() {
|
|
|
12 |
intlTeardown();
|
|
|
13 |
});
|
|
|
14 |
|
|
|
15 |
it("adds the markup", function() {
|
|
|
16 |
expect(getParentElement()).toHaveClass("iti");
|
|
|
17 |
expect(getSelectedFlagContainer()).toExist();
|
|
|
18 |
expect(getListElement()).toExist();
|
|
|
19 |
});
|
|
|
20 |
|
|
|
21 |
// this is currently impossible in pure JS, until getEventListeners becomes standard
|
|
|
22 |
// it("binds the event listeners", function() {
|
|
|
23 |
// var listeners = getEventListeners(input[0]);
|
|
|
24 |
// expect("cut" in listeners).toBeTruthy();
|
|
|
25 |
// expect("paste" in listeners).toBeTruthy();
|
|
|
26 |
// expect("keyup" in listeners).toBeTruthy();
|
|
|
27 |
// });
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
describe("calling destroy", function() {
|
|
|
31 |
|
|
|
32 |
beforeEach(function() {
|
|
|
33 |
iti.destroy();
|
|
|
34 |
});
|
|
|
35 |
|
|
|
36 |
it("removes the markup", function() {
|
|
|
37 |
expect(getParentElement()).not.toHaveClass("iti");
|
|
|
38 |
expect(getSelectedFlagContainer()).not.toExist();
|
|
|
39 |
expect(getListElement()).not.toExist();
|
|
|
40 |
});
|
|
|
41 |
|
|
|
42 |
// this is currently impossible in pure JS, until getEventListeners becomes standard
|
|
|
43 |
// it("unbinds the event listeners", function() {
|
|
|
44 |
// var listeners = getEventListeners(input[0]);
|
|
|
45 |
// expect(listeners).toBeUndefined();
|
|
|
46 |
// });
|
|
|
47 |
|
|
|
48 |
});
|
|
|
49 |
|
|
|
50 |
});
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
describe("destroy: init plugin with nationalMode=false and autoHideDialCode=true", function() {
|
|
|
56 |
|
|
|
57 |
beforeEach(function() {
|
|
|
58 |
intlSetup();
|
|
|
59 |
input = $("<input>").wrap("div");
|
|
|
60 |
iti = window.intlTelInput(input[0], {
|
|
|
61 |
nationalMode: false,
|
|
|
62 |
autoHideDialCode: true
|
|
|
63 |
});
|
|
|
64 |
});
|
|
|
65 |
|
|
|
66 |
afterEach(function() {
|
|
|
67 |
intlTeardown();
|
|
|
68 |
});
|
|
|
69 |
|
|
|
70 |
// this is currently impossible in pure JS, until getEventListeners becomes standard
|
|
|
71 |
// it("binds the events listeners", function() {
|
|
|
72 |
// var listeners = getEventListeners(input[0]);
|
|
|
73 |
// expect("blur" in listeners).toBeTruthy();
|
|
|
74 |
// expect("focus" in listeners).toBeTruthy();
|
|
|
75 |
// expect("mousedown" in listeners).toBeTruthy();
|
|
|
76 |
// });
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
describe("calling destroy", function() {
|
|
|
80 |
|
|
|
81 |
beforeEach(function() {
|
|
|
82 |
input.intlTelInput("destroy");
|
|
|
83 |
});
|
|
|
84 |
|
|
|
85 |
// this is currently impossible in pure JS, until getEventListeners becomes standard
|
|
|
86 |
// it("unbinds the event listeners", function() {
|
|
|
87 |
// var listeners = getEventListeners(input[0]);
|
|
|
88 |
// expect(listeners).toBeUndefined();
|
|
|
89 |
// });
|
|
|
90 |
|
|
|
91 |
});
|
|
|
92 |
|
|
|
93 |
});
|