jsf.js_next_gen 4.0.0-RC.2 → 4.0.0-RC.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/functions/myfaces.ab.html +2 -2
- package/dist/window/faces-development.js +2749 -2039
- package/dist/window/faces-development.js.br +0 -0
- package/dist/window/faces-development.js.gz +0 -0
- package/dist/window/faces-development.js.map +1 -1
- package/dist/window/faces.js +1 -1
- package/dist/window/faces.js.br +0 -0
- package/dist/window/faces.js.gz +0 -0
- package/dist/window/faces.js.map +1 -1
- package/dist/window/jsf-development.js +2754 -2044
- package/dist/window/jsf-development.js.br +0 -0
- package/dist/window/jsf-development.js.gz +0 -0
- package/dist/window/jsf-development.js.map +1 -1
- package/dist/window/jsf.js +1 -1
- package/dist/window/jsf.js.br +0 -0
- package/dist/window/jsf.js.gz +0 -0
- package/dist/window/jsf.js.map +1 -1
- package/package.json +7 -7
- package/src/main/typescript/@types/definitions/index.d.ts +16 -1
- package/src/main/typescript/api/_api.ts +1 -1
- package/src/main/typescript/impl/AjaxImpl.ts +22 -2
- package/src/main/typescript/impl/core/Const.ts +2 -0
- package/src/main/typescript/impl/util/AsyncQueue.ts +1 -1
- package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +2 -2
- package/src/main/typescript/myfaces/OamSubmit.ts +11 -10
- package/src/main/typescript/test/xhrCore/OamSubmitTest.spec.ts +117 -0
- package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +166 -8
- package/src/main/typescript/tsconfig.json +1 -1
- package/target/api/_api.js +25 -11
- package/target/api/_api.js.map +1 -1
- package/target/api/faces.js +4 -4
- package/target/api/faces.js.map +1 -1
- package/target/api/jsf.js +9 -9
- package/target/api/jsf.js.map +1 -1
- package/target/impl/AjaxImpl.js +79 -53
- package/target/impl/AjaxImpl.js.map +1 -1
- package/target/impl/PushImpl.js +48 -45
- package/target/impl/PushImpl.js.map +1 -1
- package/target/impl/core/Const.js +5 -4
- package/target/impl/core/Const.js.map +1 -1
- package/target/impl/core/ImplTypes.js +14 -9
- package/target/impl/core/ImplTypes.js.map +1 -1
- package/target/impl/i18n/Messages.js +4 -3
- package/target/impl/i18n/Messages.js.map +1 -1
- package/target/impl/util/Assertions.js +18 -9
- package/target/impl/util/Assertions.js.map +1 -1
- package/target/impl/util/AsyncQueue.js +36 -28
- package/target/impl/util/AsyncQueue.js.map +1 -1
- package/target/impl/util/ExtDomQuery.js +219 -144
- package/target/impl/util/ExtDomQuery.js.map +1 -1
- package/target/impl/util/Lang.js +28 -21
- package/target/impl/util/Lang.js.map +1 -1
- package/target/impl/xhrCore/ErrorData.js +61 -36
- package/target/impl/xhrCore/ErrorData.js.map +1 -1
- package/target/impl/xhrCore/EventData.js +13 -10
- package/target/impl/xhrCore/EventData.js.map +1 -1
- package/target/impl/xhrCore/RequestDataResolver.js +18 -16
- package/target/impl/xhrCore/RequestDataResolver.js.map +1 -1
- package/target/impl/xhrCore/ResonseDataResolver.js +16 -16
- package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
- package/target/impl/xhrCore/Response.js +16 -16
- package/target/impl/xhrCore/Response.js.map +1 -1
- package/target/impl/xhrCore/ResponseProcessor.js +133 -119
- package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
- package/target/impl/xhrCore/XhrFormData.js +106 -72
- package/target/impl/xhrCore/XhrFormData.js.map +1 -1
- package/target/impl/xhrCore/XhrRequest.js +95 -85
- package/target/impl/xhrCore/XhrRequest.js.map +1 -1
- package/target/myfaces/OamSubmit.js +24 -20
- package/target/myfaces/OamSubmit.js.map +1 -1
- package/target/test/frameworkBase/LangTest.spec.js +32 -46
- package/target/test/frameworkBase/LangTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +228 -238
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/LangTest.spec.js +31 -45
- package/target/test/frameworkBase/_ext/monadish/LangTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/MappingProbes.js +33 -24
- package/target/test/frameworkBase/_ext/monadish/MappingProbes.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/MappingTest.spec.js +8 -8
- package/target/test/frameworkBase/_ext/monadish/MappingTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js +31 -31
- package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/StreamTest.spec.js +48 -50
- package/target/test/frameworkBase/_ext/monadish/StreamTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/StandardInits.js +132 -247
- package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js +22 -199
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
- package/target/test/impl/ImplTest.spec.js +59 -32
- package/target/test/impl/ImplTest.spec.js.map +1 -1
- package/target/test/impl/ImplTest_23.spec.js +59 -32
- package/target/test/impl/ImplTest_23.spec.js.map +1 -1
- package/target/test/impl/SeparatorCharsTest.spec.js +17 -17
- package/target/test/impl/SeparatorCharsTest.spec.js.map +1 -1
- package/target/test/myfaces/OamSubmit.spec.js +25 -25
- package/target/test/myfaces/OamSubmit.spec.js.map +1 -1
- package/target/test/queue/AsynchronousProbe.js +29 -23
- package/target/test/queue/AsynchronousProbe.js.map +1 -1
- package/target/test/queue/AsynchronousQueueTest.spec.js +70 -39
- package/target/test/queue/AsynchronousQueueTest.spec.js.map +1 -1
- package/target/test/xhrCore/EventTests.spec.js +73 -42
- package/target/test/xhrCore/EventTests.spec.js.map +1 -1
- package/target/test/xhrCore/FakeWebsocket.js +16 -14
- package/target/test/xhrCore/FakeWebsocket.js.map +1 -1
- package/target/test/xhrCore/FileUploadTest.spec.js +77 -46
- package/target/test/xhrCore/FileUploadTest.spec.js.map +1 -1
- package/target/test/xhrCore/OamSubmitTest.spec.js +154 -0
- package/target/test/xhrCore/OamSubmitTest.spec.js.map +1 -0
- package/target/test/xhrCore/RequestParamsTest.spec.js +68 -37
- package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest.spec.js +264 -85
- package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest_23.spec.js +140 -93
- package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest.spec.js +91 -122
- package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest23.spec.js +83 -114
- package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
- package/target/test/xhrCore/ShadowDomTest.spec.js +61 -30
- package/target/test/xhrCore/ShadowDomTest.spec.js.map +1 -1
- package/target/test/xhrCore/WebsocketTest.js +93 -60
- package/target/test/xhrCore/WebsocketTest.js.map +1 -1
- package/target/test/xhrCore/XhrFormDataTest.spec.js +15 -41
- package/target/test/xhrCore/XhrFormDataTest.spec.js.map +1 -1
- package/target/classes/com/example/jsfs_js_ts/DecoratedFacesJS.class +0 -0
- package/target/classes/com/example/jsfs_js_ts/DecoratingResourceHandlerWrapper.class +0 -0
- package/target/classes/com/example/jsfs_js_ts/FacesJSMapFileResourceWrapper.class +0 -0
- package/target/classes/com/example/jsfs_js_ts/FacesJSMappingDecorator.class +0 -0
- package/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +0 -4
- package/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +0 -4
- package/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst +0 -1
- package/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst +0 -1
- package/target/surefire-reports/TEST-com.example.jsfs_js_ts.JsfsJsTsApplicationTests.xml +0 -78
- package/target/surefire-reports/com.example.jsfs_js_ts.JsfsJsTsApplicationTests.txt +0 -7
- package/target/test-classes/.gz +0 -0
- package/target/test-classes/com/example/jsfs_js_ts/JsfsJsTsApplicationTests.class +0 -0
- package/target/test-classes/fileuploadtest.html +0 -24
- package/target/test-classes/jsf-development.js +0 -3559
- package/target/test-classes/jsf-development.js.br +0 -0
- package/target/test-classes/jsf-development.js.gz +0 -0
- package/target/test-classes/jsf-development.js.map +0 -1
- package/target/test-classes/jsf.js +0 -3
- package/target/test-classes/jsf.js.br +0 -0
- package/target/test-classes/jsf.js.gz +0 -0
|
@@ -23,41 +23,53 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
23
23
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (_) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
26
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
54
|
+
var chai_1 = require("chai");
|
|
55
|
+
var mocha_1 = require("mocha");
|
|
56
|
+
var mona_dish_1 = require("mona-dish");
|
|
30
57
|
var trim = mona_dish_1.Lang.trim;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
58
|
+
var rxjs_1 = require("rxjs");
|
|
59
|
+
var jsdom = require("jsdom");
|
|
60
|
+
var JSDOM = jsdom.JSDOM;
|
|
34
61
|
global.window = {};
|
|
35
|
-
|
|
62
|
+
var dom = null;
|
|
36
63
|
(0, mocha_1.describe)('DOMQuery tests', function () {
|
|
37
64
|
beforeEach(function () {
|
|
38
65
|
// language=HTML
|
|
39
|
-
dom = new JSDOM(
|
|
40
|
-
<!DOCTYPE html>
|
|
41
|
-
<html lang="en">
|
|
42
|
-
<head>
|
|
43
|
-
<meta charset="UTF-8">
|
|
44
|
-
<title>Title</title>
|
|
45
|
-
</head>
|
|
46
|
-
<body>
|
|
47
|
-
<div id="id_1"></div>
|
|
48
|
-
<div id="id_2" booga="blarg" class="blarg2"></div>
|
|
49
|
-
<div id="id_3" class="blarg1 blarg2"></div>
|
|
50
|
-
<div id="id_4"></div>
|
|
51
|
-
</body>
|
|
52
|
-
</html>
|
|
53
|
-
|
|
54
|
-
`, {
|
|
66
|
+
dom = new JSDOM("\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <title>Title</title>\n </head>\n <body>\n <div id=\"id_1\"></div>\n <div id=\"id_2\" booga=\"blarg\" class=\"blarg2\"></div>\n <div id=\"id_3\" class=\"blarg1 blarg2\"></div>\n <div id=\"id_4\"></div>\n </body>\n </html>\n \n ", {
|
|
55
67
|
contentType: "text/html",
|
|
56
68
|
runScripts: "dangerously",
|
|
57
69
|
resources: "usable",
|
|
58
|
-
url:
|
|
70
|
+
url: "file://".concat(__dirname, "/index.html")
|
|
59
71
|
});
|
|
60
|
-
|
|
72
|
+
var window = dom.window;
|
|
61
73
|
global.dom = dom;
|
|
62
74
|
global.window = window;
|
|
63
75
|
global.body = window.document.body;
|
|
@@ -69,10 +81,10 @@ let dom = null;
|
|
|
69
81
|
this.afterEach(function () {
|
|
70
82
|
});
|
|
71
83
|
(0, mocha_1.it)('basic init', function () {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
84
|
+
var probe1 = new mona_dish_1.DomQuery(window.document.body);
|
|
85
|
+
var probe2 = mona_dish_1.DomQuery.querySelectorAll("div");
|
|
86
|
+
var probe3 = new mona_dish_1.DomQuery(probe1, probe2);
|
|
87
|
+
var probe4 = new mona_dish_1.DomQuery(window.document.body, probe3);
|
|
76
88
|
(0, chai_1.expect)(probe1.length).to.be.eq(1);
|
|
77
89
|
(0, chai_1.expect)(probe2.length == 4).to.be.true;
|
|
78
90
|
(0, chai_1.expect)(probe3.length == 5).to.be.true;
|
|
@@ -80,17 +92,17 @@ let dom = null;
|
|
|
80
92
|
(0, chai_1.expect)(probe4.length == 6).to.be.true;
|
|
81
93
|
});
|
|
82
94
|
(0, mocha_1.it)('proper iterator api and rxjs mapping', function () {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
o1.subscribe(()
|
|
95
|
+
var probe1 = new mona_dish_1.DomQuery(window.document.body);
|
|
96
|
+
var probe2 = mona_dish_1.DomQuery.querySelectorAll("div");
|
|
97
|
+
var o1 = (0, rxjs_1.from)(probe1.stream);
|
|
98
|
+
var o2 = (0, rxjs_1.from)(probe2.stream);
|
|
99
|
+
var cnt1 = 0;
|
|
100
|
+
var isDQuery = false;
|
|
101
|
+
var cnt2 = 0;
|
|
102
|
+
o1.subscribe(function () {
|
|
91
103
|
cnt1++;
|
|
92
104
|
});
|
|
93
|
-
o2.subscribe((item)
|
|
105
|
+
o2.subscribe(function (item) {
|
|
94
106
|
cnt2++;
|
|
95
107
|
isDQuery = (item.length == 1) && (item instanceof mona_dish_1.DomQuery);
|
|
96
108
|
});
|
|
@@ -99,17 +111,17 @@ let dom = null;
|
|
|
99
111
|
(0, chai_1.expect)(isDQuery).to.be.true;
|
|
100
112
|
});
|
|
101
113
|
(0, mocha_1.it)('proper iterator api and rxjs mapping with observable', function () {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
o1.subscribe(()
|
|
114
|
+
var probe1 = new mona_dish_1.DomQuery(window.document.body);
|
|
115
|
+
var probe2 = mona_dish_1.DomQuery.querySelectorAll("div");
|
|
116
|
+
var o1 = (0, rxjs_1.from)(probe1.stream);
|
|
117
|
+
var o2 = (0, rxjs_1.from)(probe2.stream);
|
|
118
|
+
var cnt1 = 0;
|
|
119
|
+
var isDQuery = false;
|
|
120
|
+
var cnt2 = 0;
|
|
121
|
+
o1.subscribe(function () {
|
|
110
122
|
cnt1++;
|
|
111
123
|
});
|
|
112
|
-
o2.subscribe((item)
|
|
124
|
+
o2.subscribe(function (item) {
|
|
113
125
|
cnt2++;
|
|
114
126
|
isDQuery = (item.length == 1) && (item instanceof mona_dish_1.DomQuery);
|
|
115
127
|
});
|
|
@@ -118,32 +130,32 @@ let dom = null;
|
|
|
118
130
|
(0, chai_1.expect)(isDQuery).to.be.true;
|
|
119
131
|
});
|
|
120
132
|
(0, mocha_1.it)('domquery ops test filter', function () {
|
|
121
|
-
|
|
122
|
-
probe2 = probe2.filter((item)
|
|
133
|
+
var probe2 = mona_dish_1.DomQuery.querySelectorAll("div");
|
|
134
|
+
probe2 = probe2.filter(function (item) { return item.id.match(function (id) { return id != "id_1"; }); });
|
|
123
135
|
(0, chai_1.expect)(probe2.length == 3);
|
|
124
136
|
});
|
|
125
137
|
(0, mocha_1.it)('global eval test', function () {
|
|
126
|
-
|
|
127
|
-
probe2 = probe2.filter((item)
|
|
138
|
+
var probe2 = mona_dish_1.DomQuery.querySelectorAll("div");
|
|
139
|
+
probe2 = probe2.filter(function (item) { return item.id.match(function (id) { return id != "id_1"; }); });
|
|
128
140
|
(0, chai_1.expect)(probe2.length == 3);
|
|
129
141
|
});
|
|
130
142
|
(0, mocha_1.it)('must detach', function () {
|
|
131
|
-
|
|
143
|
+
var probe2 = mona_dish_1.DomQuery.querySelectorAll("div#id_1");
|
|
132
144
|
probe2.detach();
|
|
133
145
|
(0, chai_1.expect)(mona_dish_1.DomQuery.querySelectorAll("div#id_1").isPresent()).to.be.false;
|
|
134
146
|
probe2.appendTo(mona_dish_1.DomQuery.querySelectorAll("body"));
|
|
135
147
|
(0, chai_1.expect)(mona_dish_1.DomQuery.querySelectorAll("div#id_1").isPresent()).to.be.true;
|
|
136
148
|
});
|
|
137
|
-
(0, mocha_1.it)('domquery ops test2 each', ()
|
|
138
|
-
|
|
149
|
+
(0, mocha_1.it)('domquery ops test2 each', function () {
|
|
150
|
+
var probe2 = mona_dish_1.DomQuery.querySelectorAll("div#id_1");
|
|
139
151
|
mona_dish_1.DomQuery.globalEval("document.getElementById('id_1').innerHTML = 'hello'");
|
|
140
152
|
(0, chai_1.expect)(probe2.html().value).to.eq("hello");
|
|
141
153
|
(0, chai_1.expect)(mona_dish_1.DomQuery.byId(document.head).innerHTML.indexOf("document.getElementById('id_1').innerHTML = 'hello'")).to.eq(-1);
|
|
142
154
|
mona_dish_1.DomQuery.globalEval("document.getElementById('id_1').innerHTML = 'hello2'", "nonci");
|
|
143
155
|
(0, chai_1.expect)(probe2.html().value).to.eq("hello2");
|
|
144
156
|
});
|
|
145
|
-
(0, mocha_1.it)('domquery ops test2 with sticky eval code', ()
|
|
146
|
-
|
|
157
|
+
(0, mocha_1.it)('domquery ops test2 with sticky eval code', function () {
|
|
158
|
+
var probe2 = mona_dish_1.DomQuery.querySelectorAll("div#id_1");
|
|
147
159
|
mona_dish_1.DomQuery.globalEvalSticky("document.getElementById('id_1').innerHTML = 'hello'");
|
|
148
160
|
(0, chai_1.expect)(probe2.html().value).to.eq("hello");
|
|
149
161
|
(0, chai_1.expect)(mona_dish_1.DomQuery.byId(document.head).innerHTML.indexOf("document.getElementById('id_1').innerHTML = 'hello'")).not.to.eq(-1);
|
|
@@ -152,9 +164,9 @@ let dom = null;
|
|
|
152
164
|
(0, chai_1.expect)(mona_dish_1.DomQuery.byId(document.head).innerHTML.indexOf("document.getElementById('id_1').innerHTML = 'hello2'")).not.to.eq(-1);
|
|
153
165
|
});
|
|
154
166
|
(0, mocha_1.it)('domquery ops test2 eachNode', function () {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
probe2.each((item, cnt)
|
|
167
|
+
var probe2 = mona_dish_1.DomQuery.querySelectorAll("div");
|
|
168
|
+
var noIter = 0;
|
|
169
|
+
probe2.each(function (item, cnt) {
|
|
158
170
|
(0, chai_1.expect)(item instanceof mona_dish_1.DomQuery).to.be.true;
|
|
159
171
|
(0, chai_1.expect)(noIter == cnt).to.be.true;
|
|
160
172
|
noIter++;
|
|
@@ -162,61 +174,54 @@ let dom = null;
|
|
|
162
174
|
(0, chai_1.expect)(noIter == 4).to.be.true;
|
|
163
175
|
});
|
|
164
176
|
(0, mocha_1.it)('domquery ops test2 byId', function () {
|
|
165
|
-
|
|
177
|
+
var probe2 = mona_dish_1.DomQuery.byId("id_1");
|
|
166
178
|
(0, chai_1.expect)(probe2.length == 1).to.be.true;
|
|
167
179
|
probe2 = mona_dish_1.DomQuery.byTagName("div");
|
|
168
180
|
(0, chai_1.expect)(probe2.length == 4).to.be.true;
|
|
169
181
|
});
|
|
170
182
|
(0, mocha_1.it)('outerhtml and eval tests', function () {
|
|
171
|
-
|
|
172
|
-
probe1.querySelectorAll("#id_1").outerHTML(
|
|
173
|
-
<div id='barg'>
|
|
174
|
-
|
|
175
|
-
</div>
|
|
176
|
-
<script type="text/javascript">
|
|
177
|
-
document.getElementById('blarg').innerHTML = 'hello world';
|
|
178
|
-
</script>
|
|
179
|
-
`, true, true);
|
|
183
|
+
var probe1 = new mona_dish_1.DomQuery(window.document.body);
|
|
184
|
+
probe1.querySelectorAll("#id_1").outerHTML("\n <div id='barg'>\n \n </div>\n <script type=\"text/javascript\">\n document.getElementById('blarg').innerHTML = 'hello world';\n </script>\n ", true, true);
|
|
180
185
|
(0, chai_1.expect)(window.document.body.innerHTML.indexOf("hello world") != -1).to.be.true;
|
|
181
186
|
(0, chai_1.expect)(window.document.head.innerHTML.indexOf("hello world") == -1).to.be.true;
|
|
182
187
|
(0, chai_1.expect)(window.document.body.innerHTML.indexOf("id_1") == -1).to.be.true;
|
|
183
188
|
(0, chai_1.expect)(window.document.body.innerHTML.indexOf("blarg") != -1).to.be.true;
|
|
184
189
|
});
|
|
185
190
|
(0, mocha_1.it)('attr test and eval tests', function () {
|
|
186
|
-
|
|
191
|
+
var probe1 = new mona_dish_1.DomQuery(document);
|
|
187
192
|
probe1.querySelectorAll("div#id_2").attr("style").value = "border=1;";
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
193
|
+
var blarg = probe1.querySelectorAll("div#id_2").attr("booga").value;
|
|
194
|
+
var style = probe1.querySelectorAll("div#id_2").attr("style").value;
|
|
195
|
+
var nonexistent = probe1.querySelectorAll("div#id_2").attr("buhaha").value;
|
|
191
196
|
(0, chai_1.expect)(blarg).to.be.eq("blarg");
|
|
192
197
|
(0, chai_1.expect)(style).to.be.eq("border=1;");
|
|
193
198
|
(0, chai_1.expect)(nonexistent).to.be.eq(null);
|
|
194
199
|
});
|
|
195
200
|
(0, mocha_1.it)('style must work ', function () {
|
|
196
|
-
|
|
197
|
-
|
|
201
|
+
var probe1 = new mona_dish_1.DomQuery(document);
|
|
202
|
+
var probe = probe1.querySelectorAll("div#id_2");
|
|
198
203
|
probe.style("border").value = "10px solid red";
|
|
199
204
|
probe.style("color").value = "blue";
|
|
200
|
-
|
|
205
|
+
var styleNodeLevel = probe.getAsElem(0).value.style['color'];
|
|
201
206
|
(0, chai_1.expect)(probe.style("border").value).to.eq("10px solid red");
|
|
202
207
|
(0, chai_1.expect)(probe.style("color").value).to.eq("blue");
|
|
203
208
|
(0, chai_1.expect)(styleNodeLevel).to.eq('blue');
|
|
204
209
|
});
|
|
205
210
|
(0, mocha_1.it)('must perform addClass and hasClass correctly', function () {
|
|
206
|
-
|
|
207
|
-
|
|
211
|
+
var probe1 = new mona_dish_1.DomQuery(document);
|
|
212
|
+
var element = probe1.querySelectorAll("div#id_2");
|
|
208
213
|
element.addClass("booga").addClass("Booga2");
|
|
209
|
-
|
|
214
|
+
var classdef = element.attr("class").value;
|
|
210
215
|
(0, chai_1.expect)(classdef).to.eq("blarg2 booga Booga2");
|
|
211
216
|
element.removeClass("booga2");
|
|
212
217
|
(0, chai_1.expect)(element.hasClass("booga2")).to.be.false;
|
|
213
218
|
(0, chai_1.expect)(element.hasClass("booga")).to.be.true;
|
|
214
219
|
});
|
|
215
220
|
(0, mocha_1.it)('must perform addClass and hasClass correctly 2', function () {
|
|
216
|
-
|
|
217
|
-
|
|
221
|
+
var probe1 = new mona_dish_1.DomQuery(document);
|
|
222
|
+
var element = probe1.querySelectorAll(".blarg2");
|
|
218
223
|
element.addClass("booga").addClass("Booga2");
|
|
219
|
-
|
|
224
|
+
var classdef = element.attr("class").value;
|
|
220
225
|
(0, chai_1.expect)(classdef).to.eq("blarg2 booga Booga2");
|
|
221
226
|
element.removeClass("booga2");
|
|
222
227
|
(0, chai_1.expect)(element.hasClass("booga2")).to.be.false;
|
|
@@ -224,15 +229,15 @@ let dom = null;
|
|
|
224
229
|
(0, chai_1.expect)(element.hasClass("blarg2")).to.be.true;
|
|
225
230
|
});
|
|
226
231
|
(0, mocha_1.it)('must perform addClass and hasClass correctly 2', function () {
|
|
227
|
-
|
|
228
|
-
|
|
232
|
+
var probe1 = new mona_dish_1.DomQuery(document);
|
|
233
|
+
var element = probe1.querySelectorAll(".blarg2");
|
|
229
234
|
element.addClass("booga").addClass("Booga2");
|
|
230
235
|
(0, chai_1.expect)(probe1.querySelectorAll(".Booga2").length).eq(2);
|
|
231
236
|
});
|
|
232
237
|
(0, mocha_1.it)('must perform insert before and insert after correctly', function () {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
238
|
+
var probe1 = new mona_dish_1.DomQuery(document).querySelectorAll("#id_2");
|
|
239
|
+
var insert = mona_dish_1.DomQuery.fromMarkup("<div id='insertedBefore'></div><div id='insertedBefore2'></div>");
|
|
240
|
+
var insert2 = mona_dish_1.DomQuery.fromMarkup("<div id='insertedAfter'></div><div id='insertedAfter2'></div>");
|
|
236
241
|
probe1.insertBefore(insert);
|
|
237
242
|
probe1.insertAfter(insert2);
|
|
238
243
|
(0, chai_1.expect)(mona_dish_1.DomQuery.querySelectorAll("#insertedBefore").isPresent()).to.be.true;
|
|
@@ -242,32 +247,32 @@ let dom = null;
|
|
|
242
247
|
(0, chai_1.expect)(mona_dish_1.DomQuery.querySelectorAll("#insertedAfter2").isPresent()).to.be.true;
|
|
243
248
|
});
|
|
244
249
|
(0, mocha_1.it)('it must stream', function () {
|
|
245
|
-
|
|
246
|
-
|
|
250
|
+
var probe1 = new mona_dish_1.DomQuery(document).querySelectorAll("div");
|
|
251
|
+
var coll = probe1.stream.collect(new mona_dish_1.ArrayCollector());
|
|
247
252
|
(0, chai_1.expect)(coll.length == 4).to.be.true;
|
|
248
253
|
coll = probe1.lazyStream.collect(new mona_dish_1.ArrayCollector());
|
|
249
254
|
(0, chai_1.expect)(coll.length == 4).to.be.true;
|
|
250
255
|
});
|
|
251
256
|
(0, mocha_1.it)('it must stream to a domquery', function () {
|
|
252
|
-
|
|
253
|
-
|
|
257
|
+
var probe1 = new mona_dish_1.DomQuery(document).querySelectorAll("div");
|
|
258
|
+
var coll = probe1.stream.collect(new mona_dish_1.DomQueryCollector());
|
|
254
259
|
(0, chai_1.expect)(coll.length == 4).to.be.true;
|
|
255
260
|
coll = probe1.lazyStream.collect(new mona_dish_1.DomQueryCollector());
|
|
256
261
|
(0, chai_1.expect)(coll.length == 4).to.be.true;
|
|
257
262
|
});
|
|
258
263
|
(0, mocha_1.it)('it must have parents', function () {
|
|
259
|
-
|
|
260
|
-
|
|
264
|
+
var probe1 = new mona_dish_1.DomQuery(document).querySelectorAll("div");
|
|
265
|
+
var coll = probe1.parents("body").stream.collect(new mona_dish_1.ArrayCollector());
|
|
261
266
|
(0, chai_1.expect)(coll.length == 1).to.be.true;
|
|
262
267
|
});
|
|
263
268
|
(0, mocha_1.it)("must have a working insertBefore and insertAfter", function () {
|
|
264
|
-
|
|
265
|
-
probe1.insertBefore(mona_dish_1.DomQuery.fromMarkup(
|
|
266
|
-
probe1.insertAfter(mona_dish_1.DomQuery.fromMarkup(
|
|
269
|
+
var probe1 = new mona_dish_1.DomQuery(document).byId("id_2");
|
|
270
|
+
probe1.insertBefore(mona_dish_1.DomQuery.fromMarkup(" <div id=\"id_x_0\"></div><div id=\"id_x_1\"></div>"));
|
|
271
|
+
probe1.insertAfter(mona_dish_1.DomQuery.fromMarkup(" <div id=\"id_x_0_1\"></div><div id=\"id_x_1_1\"></div>"));
|
|
267
272
|
(0, chai_1.expect)(mona_dish_1.DomQuery.querySelectorAll("div").length).to.eq(8);
|
|
268
273
|
mona_dish_1.DomQuery.querySelectorAll("body").innerHTML = trim(mona_dish_1.DomQuery.querySelectorAll("body").innerHTML.replace(/>\s*</gi, "><"));
|
|
269
274
|
(0, chai_1.expect)(mona_dish_1.DomQuery.querySelectorAll("body").childNodes.length).to.eq(8);
|
|
270
|
-
|
|
275
|
+
var innerHtml = mona_dish_1.DomQuery.querySelectorAll("body").innerHTML;
|
|
271
276
|
(0, chai_1.expect)(innerHtml.indexOf("id_x_0") < innerHtml.indexOf("id_x_1")).to.be.true;
|
|
272
277
|
(0, chai_1.expect)(innerHtml.indexOf("id_x_0") < innerHtml.indexOf("id_2")).to.be.true;
|
|
273
278
|
(0, chai_1.expect)(innerHtml.indexOf("id_x_0") > 0).to.be.true;
|
|
@@ -275,50 +280,27 @@ let dom = null;
|
|
|
275
280
|
(0, chai_1.expect)(innerHtml.indexOf("id_x_1_1") > innerHtml.indexOf("id_x_0_1")).to.be.true;
|
|
276
281
|
});
|
|
277
282
|
(0, mocha_1.it)("must have a working input handling", function () {
|
|
278
|
-
mona_dish_1.DomQuery.querySelectorAll("body").innerHTML =
|
|
279
|
-
|
|
280
|
-
<input type="text" id="id_1" name="id_1" value="id_1_val">
|
|
281
|
-
<input type="text" id="id_2" name="id_2" value="id_2_val" disabled="disabled">
|
|
282
|
-
<textarea id="id_3" name="id_3">textareaVal</textarea>
|
|
283
|
-
|
|
284
|
-
<fieldset>
|
|
285
|
-
<input type="radio" id="mc" name="cc_1" value="Mastercard" checked="checked">
|
|
286
|
-
<label for="mc"> Mastercard</label>
|
|
287
|
-
<input type="radio" id="vi" name="cc_1" value="Visa">
|
|
288
|
-
<label for="vi"> Visa</label>
|
|
289
|
-
<input type="radio" id="ae" name="cc_1" value="AmericanExpress">
|
|
290
|
-
<label for="ae"> American Express</label>
|
|
291
|
-
</fieldset>
|
|
292
|
-
<select id="val_5" name="val_5" size="5">
|
|
293
|
-
<option>barg</option>
|
|
294
|
-
<option>jjj</option>
|
|
295
|
-
<option selected>akaka</option>
|
|
296
|
-
<option>blon</option>
|
|
297
|
-
<option>slashs</option>
|
|
298
|
-
</select>
|
|
299
|
-
</div>
|
|
300
|
-
</form>
|
|
301
|
-
`;
|
|
302
|
-
let length = mona_dish_1.DomQuery.querySelectorAll("form").elements.length;
|
|
283
|
+
mona_dish_1.DomQuery.querySelectorAll("body").innerHTML = "<form id=\"blarg\">\n <div id=\"embed1\">\n <input type=\"text\" id=\"id_1\" name=\"id_1\" value=\"id_1_val\">\n <input type=\"text\" id=\"id_2\" name=\"id_2\" value=\"id_2_val\" disabled=\"disabled\">\n <textarea id=\"id_3\" name=\"id_3\">textareaVal</textarea>\n\n <fieldset>\n <input type=\"radio\" id=\"mc\" name=\"cc_1\" value=\"Mastercard\" checked=\"checked\">\n <label for=\"mc\"> Mastercard</label>\n <input type=\"radio\" id=\"vi\" name=\"cc_1\" value=\"Visa\">\n <label for=\"vi\"> Visa</label>\n <input type=\"radio\" id=\"ae\" name=\"cc_1\" value=\"AmericanExpress\">\n <label for=\"ae\"> American Express</label>\n </fieldset>\n <select id=\"val_5\" name=\"val_5\" size=\"5\">\n <option>barg</option>\n <option>jjj</option>\n <option selected>akaka</option>\n <option>blon</option>\n <option>slashs</option>\n </select>\n </div>\n</form>\n ";
|
|
284
|
+
var length = mona_dish_1.DomQuery.querySelectorAll("form").elements.length;
|
|
303
285
|
(0, chai_1.expect)(length == 8).to.be.true;
|
|
304
|
-
|
|
286
|
+
var length1 = mona_dish_1.DomQuery.querySelectorAll("body").elements.length;
|
|
305
287
|
(0, chai_1.expect)(length1 == 8).to.be.true;
|
|
306
|
-
|
|
288
|
+
var length2 = mona_dish_1.DomQuery.byId("embed1").elements.length;
|
|
307
289
|
(0, chai_1.expect)(length2 == 8).to.be.true;
|
|
308
|
-
|
|
309
|
-
.stream.map(item
|
|
310
|
-
.reduce((val1, val2)
|
|
290
|
+
var count = mona_dish_1.DomQuery.byId("embed1").elements
|
|
291
|
+
.stream.map(function (item) { return item.disabled ? 1 : 0; })
|
|
292
|
+
.reduce(function (val1, val2) { return val1 + val2; }, 0);
|
|
311
293
|
(0, chai_1.expect)(count.value).to.eq(1);
|
|
312
294
|
mona_dish_1.DomQuery.byId("embed1").elements
|
|
313
|
-
.stream.filter(item
|
|
314
|
-
.each(item
|
|
295
|
+
.stream.filter(function (item) { return item.disabled; })
|
|
296
|
+
.each(function (item) { return item.disabled = false; });
|
|
315
297
|
count = mona_dish_1.DomQuery.byId("embed1").elements
|
|
316
|
-
.stream.map(item
|
|
317
|
-
.reduce((val1, val2)
|
|
298
|
+
.stream.map(function (item) { return item.disabled ? 1 : 0; })
|
|
299
|
+
.reduce(function (val1, val2) { return val1 + val2; }, 0);
|
|
318
300
|
(0, chai_1.expect)(count.value).to.eq(0);
|
|
319
301
|
count = mona_dish_1.DomQuery.byId("embed1").elements
|
|
320
|
-
.stream.map(item
|
|
321
|
-
.reduce((val1, val2)
|
|
302
|
+
.stream.map(function (item) { return item.attr("checked").isPresent() ? 1 : 0; })
|
|
303
|
+
.reduce(function (val1, val2) { return val1 + val2; }, 0);
|
|
322
304
|
(0, chai_1.expect)(count.value).to.eq(1);
|
|
323
305
|
(0, chai_1.expect)(mona_dish_1.DomQuery.byId("id_1").inputValue.value == "id_1_val").to.be.true;
|
|
324
306
|
mona_dish_1.DomQuery.byId("id_1").inputValue.value = "booga";
|
|
@@ -326,7 +308,7 @@ let dom = null;
|
|
|
326
308
|
(0, chai_1.expect)(mona_dish_1.DomQuery.byId("id_3").inputValue.value).to.eq("textareaVal");
|
|
327
309
|
mona_dish_1.DomQuery.byId("id_3").inputValue.value = "hello world";
|
|
328
310
|
(0, chai_1.expect)(mona_dish_1.DomQuery.byId("id_3").inputValue.value).to.eq("hello world");
|
|
329
|
-
|
|
311
|
+
var cfg = mona_dish_1.DomQuery.querySelectorAll("form").elements.encodeFormElement();
|
|
330
312
|
(0, chai_1.expect)(cfg.getIf("id_1").value[0]).to.eq("booga");
|
|
331
313
|
(0, chai_1.expect)(cfg.getIf("id_2").value[0]).to.eq("id_2_val");
|
|
332
314
|
(0, chai_1.expect)(cfg.getIf("id_3").value[0]).to.eq("hello world");
|
|
@@ -335,7 +317,7 @@ let dom = null;
|
|
|
335
317
|
});
|
|
336
318
|
(0, mocha_1.it)("must have a proper loadScriptEval execution", function (done) {
|
|
337
319
|
mona_dish_1.DomQuery.byTagName("body").loadScriptEval("./fixtures/test.js");
|
|
338
|
-
setTimeout(()
|
|
320
|
+
setTimeout(function () {
|
|
339
321
|
(0, chai_1.expect)(mona_dish_1.DomQuery.byId("id_1").innerHTML == "hello world").to.be.true;
|
|
340
322
|
done();
|
|
341
323
|
}, 100);
|
|
@@ -344,38 +326,8 @@ let dom = null;
|
|
|
344
326
|
(0, chai_1.expect)(mona_dish_1.DomQuery.querySelectorAll("div").first().id.value).to.eq("id_1");
|
|
345
327
|
});
|
|
346
328
|
(0, mocha_1.it)("runscript runcss", function (done) {
|
|
347
|
-
mona_dish_1.DomQuery.byTagName("body").innerHTML =
|
|
348
|
-
|
|
349
|
-
<div id="second"></div>
|
|
350
|
-
<div id="third"></div>
|
|
351
|
-
<div id="fourth"></div>
|
|
352
|
-
|
|
353
|
-
<script type="text/javascript">
|
|
354
|
-
document.getElementById("first").innerHTML = "hello world";
|
|
355
|
-
</script>
|
|
356
|
-
<script type="text/javascript">
|
|
357
|
-
//<![CDATA[
|
|
358
|
-
document.getElementById("second").innerHTML = "hello world";
|
|
359
|
-
//]]>
|
|
360
|
-
</script>
|
|
361
|
-
<script type="text/javascript">
|
|
362
|
-
<!--
|
|
363
|
-
document.getElementById("third").innerHTML = "hello world";
|
|
364
|
-
//-->
|
|
365
|
-
</script>
|
|
366
|
-
<script type="text/javascript">
|
|
367
|
-
//<!--
|
|
368
|
-
document.getElementById("fourth").innerHTML = "hello world";
|
|
369
|
-
//-->
|
|
370
|
-
</script>
|
|
371
|
-
|
|
372
|
-
<style>
|
|
373
|
-
#first {
|
|
374
|
-
border: 1px solid black;
|
|
375
|
-
}
|
|
376
|
-
</style>
|
|
377
|
-
`;
|
|
378
|
-
let content = mona_dish_1.DomQuery.byTagName("body").runScripts().runCss();
|
|
329
|
+
mona_dish_1.DomQuery.byTagName("body").innerHTML = "\n <div id=\"first\"></div>\n <div id=\"second\"></div>\n <div id=\"third\"></div>\n <div id=\"fourth\"></div>\n \n <script type=\"text/javascript\">\n document.getElementById(\"first\").innerHTML = \"hello world\";\n </script>\n <script type=\"text/javascript\">\n //<![CDATA[\n document.getElementById(\"second\").innerHTML = \"hello world\";\n //]]> \n </script>\n <script type=\"text/javascript\">\n <!--\n document.getElementById(\"third\").innerHTML = \"hello world\";\n //--> \n </script>\n <script type=\"text/javascript\">\n //<!--\n document.getElementById(\"fourth\").innerHTML = \"hello world\";\n //--> \n </script>\n \n <style>\n #first {\n border: 1px solid black;\n }\n </style>\n ";
|
|
330
|
+
var content = mona_dish_1.DomQuery.byTagName("body").runScripts().runCss();
|
|
379
331
|
(0, chai_1.expect)(content.byId("first").innerHTML).to.eq("hello world");
|
|
380
332
|
(0, chai_1.expect)(content.byId("second").innerHTML).to.eq("hello world");
|
|
381
333
|
(0, chai_1.expect)(content.byId("third").innerHTML).to.eq("hello world");
|
|
@@ -385,20 +337,20 @@ let dom = null;
|
|
|
385
337
|
//TODO defer does not work in jsdom
|
|
386
338
|
(0, mocha_1.it)("must have a proper loadScriptEval deferred", function (done) {
|
|
387
339
|
mona_dish_1.DomQuery.byId(document.body).loadScriptEval("./fixtures/test2.js", 200);
|
|
388
|
-
setTimeout(()
|
|
340
|
+
setTimeout(function () {
|
|
389
341
|
(0, chai_1.expect)(mona_dish_1.DomQuery.byId("id_1").innerHTML == "hello world").to.be.false;
|
|
390
342
|
}, 100);
|
|
391
|
-
setTimeout(()
|
|
343
|
+
setTimeout(function () {
|
|
392
344
|
(0, chai_1.expect)(mona_dish_1.DomQuery.byId("id_1").innerHTML == "hello world").to.be.true;
|
|
393
345
|
done();
|
|
394
346
|
}, 1500);
|
|
395
347
|
});
|
|
396
348
|
(0, mocha_1.it)("it must handle events properly", function () {
|
|
397
|
-
|
|
398
|
-
|
|
349
|
+
var clicked = 0;
|
|
350
|
+
var listener = function () {
|
|
399
351
|
clicked++;
|
|
400
352
|
};
|
|
401
|
-
|
|
353
|
+
var eventReceiver = mona_dish_1.DomQuery.byId("id_1");
|
|
402
354
|
eventReceiver.addEventListener("click", listener);
|
|
403
355
|
eventReceiver.click();
|
|
404
356
|
(0, chai_1.expect)(clicked).to.eq(1);
|
|
@@ -409,35 +361,35 @@ let dom = null;
|
|
|
409
361
|
(0, mocha_1.it)("it must handle innerText properly", function () {
|
|
410
362
|
//jsdom bug
|
|
411
363
|
Object.defineProperty(Object.prototype, 'innerText', {
|
|
412
|
-
get() {
|
|
364
|
+
get: function () {
|
|
413
365
|
return this.textContent;
|
|
414
366
|
},
|
|
415
367
|
});
|
|
416
|
-
|
|
368
|
+
var probe = mona_dish_1.DomQuery.byId("id_1");
|
|
417
369
|
probe.innerHTML = "<div>hello</div><div>world</div>";
|
|
418
370
|
(0, chai_1.expect)(probe.innerText()).to.eq("helloworld");
|
|
419
371
|
});
|
|
420
372
|
(0, mocha_1.it)("it must handle textContent properly", function () {
|
|
421
|
-
|
|
373
|
+
var probe = mona_dish_1.DomQuery.byId("id_1");
|
|
422
374
|
probe.innerHTML = "<div>hello</div><div>world</div>";
|
|
423
375
|
(0, chai_1.expect)(probe.textContent()).to.eq("helloworld");
|
|
424
376
|
});
|
|
425
377
|
(0, mocha_1.it)("it must handle iterations properly", function () {
|
|
426
|
-
|
|
427
|
-
|
|
378
|
+
var probe = mona_dish_1.DomQuery.byTagName("div");
|
|
379
|
+
var resArr = probe.lazyStream.collect(new mona_dish_1.ArrayCollector());
|
|
428
380
|
(0, chai_1.expect)(resArr.length).to.eq(4);
|
|
429
381
|
probe.reset();
|
|
430
382
|
while (probe.hasNext()) {
|
|
431
|
-
|
|
383
|
+
var el = probe.next();
|
|
432
384
|
(0, chai_1.expect)(el.tagName.value.toLowerCase()).to.eq("div");
|
|
433
385
|
}
|
|
434
386
|
(0, chai_1.expect)(probe.next()).to.eq(null);
|
|
435
|
-
|
|
387
|
+
var probe2 = mona_dish_1.DomQuery.byTagName("div").limits(2);
|
|
436
388
|
resArr = mona_dish_1.LazyStream.ofStreamDataSource(probe2).collect(new mona_dish_1.ArrayCollector());
|
|
437
389
|
(0, chai_1.expect)(resArr.length).to.eq(2);
|
|
438
390
|
});
|
|
439
391
|
(0, mocha_1.it)("it must handle subnodes properly", function () {
|
|
440
|
-
|
|
392
|
+
var probe = mona_dish_1.DomQuery.byTagName("div");
|
|
441
393
|
(0, chai_1.expect)(probe.subNodes(1, 3).length).to.eq(2);
|
|
442
394
|
probe = mona_dish_1.DomQuery.byTagName("body").childNodes.subNodes(0, 2);
|
|
443
395
|
(0, chai_1.expect)(probe.length).to.eq(2);
|
|
@@ -445,11 +397,11 @@ let dom = null;
|
|
|
445
397
|
(0, chai_1.expect)(probe.length).to.eq(2);
|
|
446
398
|
});
|
|
447
399
|
(0, mocha_1.it)("it must ensure shadow dom creation works properly", function () {
|
|
448
|
-
|
|
400
|
+
var probe = mona_dish_1.DomQuery.byTagName("div");
|
|
449
401
|
try {
|
|
450
402
|
//probably not testable atm, mocha does not have shadow dom support
|
|
451
403
|
//we might be able to shim it in one way or the other
|
|
452
|
-
|
|
404
|
+
var element = probe.attachShadow();
|
|
453
405
|
(0, chai_1.expect)(element.length > 0).to.eq(true);
|
|
454
406
|
}
|
|
455
407
|
catch (e) {
|
|
@@ -458,61 +410,99 @@ let dom = null;
|
|
|
458
410
|
}
|
|
459
411
|
});
|
|
460
412
|
(0, mocha_1.it)('it must have a working wait for dom with mut observer and must detect condition after change', function () {
|
|
461
|
-
return __awaiter(this, void 0, void 0, function
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
413
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
414
|
+
var probe, ret;
|
|
415
|
+
return __generator(this, function (_a) {
|
|
416
|
+
switch (_a.label) {
|
|
417
|
+
case 0:
|
|
418
|
+
probe = mona_dish_1.DomQuery.byId('id_1');
|
|
419
|
+
probe.innerHTML = 'true';
|
|
420
|
+
return [4 /*yield*/, probe.waitUntilDom(function (element) { return element.innerHTML.indexOf('true') != -1; })];
|
|
421
|
+
case 1:
|
|
422
|
+
ret = _a.sent();
|
|
423
|
+
(0, chai_1.expect)(ret.isPresent());
|
|
424
|
+
probe = mona_dish_1.DomQuery.byId('bosushsdhs');
|
|
425
|
+
return [4 /*yield*/, probe.waitUntilDom(function (element) { return element.isAbsent(); })];
|
|
426
|
+
case 2:
|
|
427
|
+
ret = _a.sent();
|
|
428
|
+
(0, chai_1.expect)(ret.isAbsent());
|
|
429
|
+
return [2 /*return*/];
|
|
430
|
+
}
|
|
431
|
+
});
|
|
469
432
|
});
|
|
470
433
|
});
|
|
471
434
|
(0, mocha_1.it)('it must have a working wait for dom with mut observer', function () {
|
|
472
|
-
return __awaiter(this, void 0, void 0, function
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
435
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
436
|
+
var probe, ret, ret2;
|
|
437
|
+
return __generator(this, function (_a) {
|
|
438
|
+
switch (_a.label) {
|
|
439
|
+
case 0:
|
|
440
|
+
probe = mona_dish_1.DomQuery.byId('id_1');
|
|
441
|
+
setTimeout(function () { return probe.innerHTML = 'true'; }, 300);
|
|
442
|
+
return [4 /*yield*/, probe.waitUntilDom(function (element) { return element.innerHTML.indexOf('true') != -1; })];
|
|
443
|
+
case 1:
|
|
444
|
+
ret = _a.sent();
|
|
445
|
+
delete window.MutationObserver;
|
|
446
|
+
delete global.MutationObserver;
|
|
447
|
+
probe.innerHTML = "";
|
|
448
|
+
setTimeout(function () { return probe.innerHTML = 'true'; }, 300);
|
|
449
|
+
return [4 /*yield*/, probe.waitUntilDom(function (element) { return element.innerHTML.indexOf('true') != -1; })];
|
|
450
|
+
case 2:
|
|
451
|
+
ret2 = _a.sent();
|
|
452
|
+
(0, chai_1.expect)(ret.isPresent() && ret2.isPresent());
|
|
453
|
+
return [2 /*return*/];
|
|
454
|
+
}
|
|
455
|
+
});
|
|
482
456
|
});
|
|
483
457
|
});
|
|
484
458
|
(0, mocha_1.it)('it must have a timeout', function () {
|
|
485
|
-
return __awaiter(this, void 0, void 0, function
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
459
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
460
|
+
var probe, ex_1, ex2_1;
|
|
461
|
+
return __generator(this, function (_a) {
|
|
462
|
+
switch (_a.label) {
|
|
463
|
+
case 0:
|
|
464
|
+
probe = mona_dish_1.DomQuery.byId('booga');
|
|
465
|
+
_a.label = 1;
|
|
466
|
+
case 1:
|
|
467
|
+
_a.trys.push([1, 3, , 4]);
|
|
468
|
+
setTimeout(function () { return probe.innerHTML = 'true'; }, 300);
|
|
469
|
+
return [4 /*yield*/, probe.waitUntilDom(function (element) { return element.innerHTML.indexOf('true') != -1; })];
|
|
470
|
+
case 2:
|
|
471
|
+
_a.sent();
|
|
472
|
+
chai_1.expect.fail("must have a timeout");
|
|
473
|
+
return [3 /*break*/, 4];
|
|
474
|
+
case 3:
|
|
475
|
+
ex_1 = _a.sent();
|
|
476
|
+
(0, chai_1.expect)(!!ex_1);
|
|
477
|
+
return [3 /*break*/, 4];
|
|
478
|
+
case 4:
|
|
479
|
+
_a.trys.push([4, 6, , 7]);
|
|
480
|
+
delete window.MutationObserver;
|
|
481
|
+
delete global.MutationObserver;
|
|
482
|
+
probe.innerHTML = "";
|
|
483
|
+
setTimeout(function () { return probe.innerHTML = 'true'; }, 300);
|
|
484
|
+
return [4 /*yield*/, probe.waitUntilDom(function (element) { return element.innerHTML.indexOf('true') != -1; })];
|
|
485
|
+
case 5:
|
|
486
|
+
_a.sent();
|
|
487
|
+
chai_1.expect.fail("must have a timeout");
|
|
488
|
+
return [3 /*break*/, 7];
|
|
489
|
+
case 6:
|
|
490
|
+
ex2_1 = _a.sent();
|
|
491
|
+
(0, chai_1.expect)(!!ex2_1);
|
|
492
|
+
return [3 /*break*/, 7];
|
|
493
|
+
case 7: return [2 /*return*/];
|
|
494
|
+
}
|
|
495
|
+
});
|
|
506
496
|
});
|
|
507
497
|
});
|
|
508
498
|
(0, mocha_1.it)('must handle null inputs correctly', function () {
|
|
509
|
-
|
|
499
|
+
var dq = new mona_dish_1.DomQuery(null);
|
|
510
500
|
(0, chai_1.expect)(dq.isAbsent()).to.eq(true);
|
|
511
501
|
});
|
|
512
502
|
(0, mocha_1.it)('concat must work as expected resulting', function () {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
503
|
+
var probe = mona_dish_1.DomQuery.querySelectorAll("div");
|
|
504
|
+
var probe2 = mona_dish_1.DomQuery.querySelectorAll("body");
|
|
505
|
+
var result = probe.concat(probe2);
|
|
516
506
|
(0, chai_1.expect)(result.length).to.eq(probe.length + probe2.length);
|
|
517
507
|
//lets now check for filter double
|
|
518
508
|
probe2 = mona_dish_1.DomQuery.querySelectorAll('div');
|
|
@@ -520,34 +510,34 @@ let dom = null;
|
|
|
520
510
|
(0, chai_1.expect)(result.length).to.eq(probe.length);
|
|
521
511
|
});
|
|
522
512
|
(0, mocha_1.it)('must handle match correctly', function () {
|
|
523
|
-
|
|
524
|
-
|
|
513
|
+
var probe = mona_dish_1.DomQuery.querySelectorAll("div").first();
|
|
514
|
+
var probe2 = mona_dish_1.DomQuery.querySelectorAll("body").first();
|
|
525
515
|
(0, chai_1.expect)(probe.matchesSelector("div")).to.eq(true);
|
|
526
516
|
(0, chai_1.expect)(probe2.matchesSelector("body")).to.eq(true);
|
|
527
517
|
(0, chai_1.expect)(probe2.matchesSelector("div")).to.eq(false);
|
|
528
518
|
});
|
|
529
519
|
(0, mocha_1.it)('must by recycleable', function () {
|
|
530
|
-
|
|
531
|
-
|
|
520
|
+
var probe = mona_dish_1.DomQuery.querySelectorAll("div");
|
|
521
|
+
var res1 = probe.filter(function (item) { return item.matchesSelector("div"); });
|
|
532
522
|
(0, chai_1.expect)(res1.length).to.eq(4);
|
|
533
|
-
|
|
523
|
+
var res2 = probe.filter(function (item) { return item.matchesSelector("div"); });
|
|
534
524
|
(0, chai_1.expect)(res2.length).to.eq(4);
|
|
535
525
|
});
|
|
536
526
|
(0, mocha_1.it)('delete must work', function () {
|
|
537
|
-
|
|
538
|
-
|
|
527
|
+
var probe = mona_dish_1.DomQuery.querySelectorAll("body");
|
|
528
|
+
var probe2 = mona_dish_1.DomQuery.fromMarkup("<div id='deleteprobe1'>snafu</div>");
|
|
539
529
|
probe2.appendTo(probe);
|
|
540
530
|
(0, chai_1.expect)(probe.querySelectorAll("#deleteprobe1").isPresent()).to.eq(true);
|
|
541
531
|
probe2.delete();
|
|
542
532
|
(0, chai_1.expect)(probe.querySelectorAll("#deleteprobe1").isAbsent()).to.eq(true);
|
|
543
533
|
});
|
|
544
534
|
(0, mocha_1.it)('must work with rxjs and domquery', function () {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
(0, rxjs_1.from)(probe).subscribe(()
|
|
550
|
-
(0, rxjs_1.from)(probe2.stream).subscribe(()
|
|
535
|
+
var probe = mona_dish_1.DomQuery.querySelectorAll("div");
|
|
536
|
+
var probe2 = mona_dish_1.DomQuery.querySelectorAll("div");
|
|
537
|
+
var probeCnt = 0;
|
|
538
|
+
var probe2Cnt = 0;
|
|
539
|
+
(0, rxjs_1.from)(probe).subscribe(function () { return probeCnt++; });
|
|
540
|
+
(0, rxjs_1.from)(probe2.stream).subscribe(function () { return probe2Cnt++; });
|
|
551
541
|
(0, chai_1.expect)(probeCnt).to.be.above(0);
|
|
552
542
|
(0, chai_1.expect)(probeCnt).to.eq(probe2Cnt);
|
|
553
543
|
});
|