1 |
www |
1 |
"use strict";
|
|
|
2 |
|
|
|
3 |
describe("utilsScript:", function() {
|
|
|
4 |
|
|
|
5 |
var url = "build/js/utils.js";
|
|
|
6 |
|
|
|
7 |
beforeEach(function() {
|
|
|
8 |
intlSetup();
|
|
|
9 |
input = $("<input>").wrap("div");
|
|
|
10 |
});
|
|
|
11 |
|
|
|
12 |
afterEach(function() {
|
|
|
13 |
intlTeardown();
|
|
|
14 |
});
|
|
|
15 |
|
|
|
16 |
it("init vanilla plugin does not inject the script", function() {
|
|
|
17 |
iti = window.intlTelInput(input[0]);
|
|
|
18 |
expect($("script.iti-load-utils")).not.toExist();
|
|
|
19 |
});
|
|
|
20 |
|
|
|
21 |
it("init plugin with utilsScript before window.load event does not inject the script", function() {
|
|
|
22 |
window.intlTelInputGlobals.documentReady = () => false;
|
|
|
23 |
iti = window.intlTelInput(input[0], {
|
|
|
24 |
utilsScript: url,
|
|
|
25 |
});
|
|
|
26 |
expect($("script.iti-load-utils")).not.toExist();
|
|
|
27 |
});
|
|
|
28 |
|
|
|
29 |
it("faking window.load then init plugin with utilsScript does inject the script", function() {
|
|
|
30 |
window.intlTelInputGlobals.documentReady = () => true;
|
|
|
31 |
iti = window.intlTelInput(input[0], {
|
|
|
32 |
utilsScript: url,
|
|
|
33 |
});
|
|
|
34 |
expect($("script.iti-load-utils")).toExist();
|
|
|
35 |
});
|
|
|
36 |
|
|
|
37 |
});
|