jsf.js_next_gen 4.0.0-beta-19 → 4.0.0-beta-21
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/faces.ajax.addOnError.html +1 -1
- package/dist/docs/functions/faces.ajax.addOnEvent.html +1 -1
- package/dist/docs/functions/faces.ajax.request.html +1 -1
- package/dist/docs/functions/faces.ajax.response.html +1 -1
- package/dist/docs/functions/faces.getClientWindow.html +1 -1
- package/dist/docs/functions/faces.getProjectStage.html +1 -1
- package/dist/docs/functions/faces.getViewState.html +1 -1
- package/dist/docs/functions/faces.push.close.html +1 -1
- package/dist/docs/functions/faces.push.init.html +1 -1
- package/dist/docs/functions/faces.push.open.html +1 -1
- package/dist/docs/functions/faces.util.chain.html +1 -1
- package/dist/docs/functions/myfaces.ab.html +1 -1
- package/dist/docs/index.html +1 -1
- package/dist/docs/modules/faces.ajax.html +1 -1
- package/dist/docs/modules/faces.html +1 -1
- package/dist/docs/modules/faces.push.html +1 -1
- package/dist/docs/modules/faces.util.html +1 -1
- package/dist/docs/modules/myfaces.html +1 -1
- package/dist/docs/modules.html +1 -1
- package/dist/docs/variables/faces.contextpath.html +1 -1
- package/dist/docs/variables/faces.implversion.html +1 -1
- package/dist/docs/variables/faces.separatorchar.html +1 -1
- package/dist/docs/variables/faces.specversion.html +1 -1
- package/dist/docs/variables/myfaces.oam.html +1 -1
- package/dist/window/faces-development.js +282 -47
- 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 +282 -47
- 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 +6 -6
- package/src/main/typescript/impl/core/Const.ts +6 -0
- package/src/main/typescript/impl/util/ExtDomQuery.ts +61 -3
- package/src/main/typescript/impl/xhrCore/IResponseProcessor.ts +8 -0
- package/src/main/typescript/impl/xhrCore/ResonseDataResolver.ts +3 -1
- package/src/main/typescript/impl/xhrCore/Response.ts +6 -2
- package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +26 -4
- package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +283 -68
- package/src/main/typescript/test/frameworkBase/_ext/monadish/fixtures/test.js +1 -0
- package/src/main/typescript/test/frameworkBase/_ext/monadish/fixtures/test2.js +1 -0
- package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +15 -2
- package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +34 -0
- package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +47 -2
- package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +1 -1
- package/src/main/typescript/test/xhrCore/fixtures/addedViewHead1.js +1 -0
- package/src/main/typescript/test/xhrCore/fixtures/addedViewHead2.css +3 -0
- package/src/main/typescript/test/xhrCore/fixtures/addedViewHead2.js +1 -0
- package/src/main/typescript/test/xhrCore/fixtures/addedViewHead3.js +3 -0
- package/src/test.html +75 -0
- package/target/impl/core/Const.js +7 -3
- package/target/impl/core/Const.js.map +1 -1
- package/target/impl/util/ExtDomQuery.js +49 -2
- package/target/impl/util/ExtDomQuery.js.map +1 -1
- package/target/impl/xhrCore/ResonseDataResolver.js +1 -0
- package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
- package/target/impl/xhrCore/Response.js +3 -0
- package/target/impl/xhrCore/Response.js.map +1 -1
- package/target/impl/xhrCore/ResponseProcessor.js +18 -3
- package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +243 -83
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/StandardInits.js +15 -2
- package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js +32 -0
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
- package/target/test/xhrCore/ResponseTest.spec.js +38 -2
- package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest23.spec.js +0 -1
- package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/*! Licensed to the Apache Software Foundation (ASF) under one or more
|
|
1
|
+
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
4
2
|
* contributor license agreements. See the NOTICE file distributed with
|
|
5
3
|
* this work for additional information regarding copyright ownership.
|
|
6
4
|
* The ASF licenses this file to you under the Apache License, Version 2.0
|
|
@@ -18,21 +16,21 @@
|
|
|
18
16
|
|
|
19
17
|
import {expect} from 'chai';
|
|
20
18
|
import {describe, it} from 'mocha';
|
|
21
|
-
import {ArrayCollector, DomQuery, Lang, LazyStream} from "mona-dish";
|
|
22
|
-
import * as sinon from 'sinon';
|
|
19
|
+
import {ArrayCollector, DomQuery, DomQueryCollector, Lang, LazyStream} from "mona-dish";
|
|
23
20
|
import trim = Lang.trim;
|
|
24
21
|
import {ExtDomquery} from "../../../../impl/util/ExtDomQuery";
|
|
22
|
+
import {from} from "rxjs";
|
|
25
23
|
|
|
26
24
|
|
|
27
25
|
const jsdom = require("jsdom");
|
|
28
26
|
const {JSDOM} = jsdom;
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
(global as any).window = {}
|
|
28
|
+
let dom = null;
|
|
31
29
|
describe('DOMQuery tests', function () {
|
|
32
30
|
|
|
33
31
|
beforeEach(function () {
|
|
34
32
|
|
|
35
|
-
|
|
33
|
+
dom = new JSDOM(`
|
|
36
34
|
<!DOCTYPE html>
|
|
37
35
|
<html lang="en">
|
|
38
36
|
<head>
|
|
@@ -41,19 +39,22 @@ describe('DOMQuery tests', function () {
|
|
|
41
39
|
</head>
|
|
42
40
|
<body>
|
|
43
41
|
<div id="id_1"></div>
|
|
44
|
-
<div id="id_2" booga="blarg"></div>
|
|
45
|
-
<div id="id_3"></div>
|
|
42
|
+
<div id="id_2" booga="blarg" class="blarg2"></div>
|
|
43
|
+
<div id="id_3" class="blarg1 blarg2"></div>
|
|
46
44
|
<div id="id_4"></div>
|
|
47
45
|
</body>
|
|
48
46
|
</html>
|
|
49
47
|
|
|
50
48
|
`, {
|
|
51
49
|
contentType: "text/html",
|
|
52
|
-
runScripts: "dangerously"
|
|
50
|
+
runScripts: "dangerously",
|
|
51
|
+
resources: "usable",
|
|
52
|
+
url: `file://${__dirname}/index.html`
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
let window = dom.window;
|
|
56
56
|
|
|
57
|
+
(<any>global).dom = dom;
|
|
57
58
|
(<any>global).window = window;
|
|
58
59
|
(<any>global).body = window.document.body;
|
|
59
60
|
(<any>global).document = window.document;
|
|
@@ -61,17 +62,11 @@ describe('DOMQuery tests', function () {
|
|
|
61
62
|
language: "en-En"
|
|
62
63
|
};
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
this.requests = [];
|
|
66
|
-
this.xhr.onCreate = (xhr: any) => {
|
|
67
|
-
this.requests.push(xhr);
|
|
68
|
-
};
|
|
69
|
-
(<any>global).XMLHttpRequest = this.xhr;
|
|
70
|
-
window.XMLHttpRequest = this.xhr;
|
|
65
|
+
|
|
71
66
|
});
|
|
72
67
|
|
|
73
68
|
this.afterEach(function () {
|
|
74
|
-
|
|
69
|
+
|
|
75
70
|
});
|
|
76
71
|
|
|
77
72
|
it('basic init', function () {
|
|
@@ -87,6 +82,58 @@ describe('DOMQuery tests', function () {
|
|
|
87
82
|
expect(probe4.length == 6).to.be.true;
|
|
88
83
|
});
|
|
89
84
|
|
|
85
|
+
it('proper iterator api and rxjs mapping', function () {
|
|
86
|
+
let probe1 = new DomQuery(window.document.body);
|
|
87
|
+
let probe2 = DomQuery.querySelectorAll("div");
|
|
88
|
+
|
|
89
|
+
let o1 = from(probe1.stream);
|
|
90
|
+
let o2 = from(probe2.stream);
|
|
91
|
+
|
|
92
|
+
let cnt1 = 0;
|
|
93
|
+
let isDQuery = false;
|
|
94
|
+
let cnt2 = 0;
|
|
95
|
+
|
|
96
|
+
o1.subscribe((item: any) => {
|
|
97
|
+
cnt1++;
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
o2.subscribe((item: any) => {
|
|
101
|
+
cnt2++;
|
|
102
|
+
isDQuery = (item.length == 1) && (item instanceof DomQuery)
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
expect(probe1.length).to.be.eq(1);
|
|
106
|
+
expect(probe2.length == 4).to.be.true;
|
|
107
|
+
expect(isDQuery).to.be.true;
|
|
108
|
+
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('proper iterator api and rxjs mapping with observable', function () {
|
|
112
|
+
let probe1 = new DomQuery(window.document.body);
|
|
113
|
+
let probe2 = DomQuery.querySelectorAll("div");
|
|
114
|
+
|
|
115
|
+
let o1 = from(probe1.stream);
|
|
116
|
+
let o2 = from(probe2.stream);
|
|
117
|
+
|
|
118
|
+
let cnt1 = 0;
|
|
119
|
+
let isDQuery = false;
|
|
120
|
+
let cnt2 = 0;
|
|
121
|
+
|
|
122
|
+
o1.subscribe((item: any) => {
|
|
123
|
+
cnt1++;
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
o2.subscribe((item: any) => {
|
|
127
|
+
cnt2++;
|
|
128
|
+
isDQuery = (item.length == 1) && (item instanceof DomQuery)
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
expect(probe1.length).to.be.eq(1);
|
|
132
|
+
expect(probe2.length == 4).to.be.true;
|
|
133
|
+
expect(isDQuery).to.be.true;
|
|
134
|
+
|
|
135
|
+
});
|
|
136
|
+
|
|
90
137
|
it('domquery ops test filter', function () {
|
|
91
138
|
let probe2 = DomQuery.querySelectorAll("div");
|
|
92
139
|
probe2 = probe2.filter((item: DomQuery) => item.id.match((id) => id != "id_1"));
|
|
@@ -113,15 +160,30 @@ describe('DOMQuery tests', function () {
|
|
|
113
160
|
|
|
114
161
|
DomQuery.globalEval("document.getElementById('id_1').innerHTML = 'hello'");
|
|
115
162
|
expect(probe2.html().value).to.eq("hello");
|
|
163
|
+
expect(DomQuery.byId(document.head).innerHTML.indexOf("document.getElementById('id_1').innerHTML = 'hello'")).to.eq(-1);
|
|
116
164
|
|
|
117
165
|
DomQuery.globalEval("document.getElementById('id_1').innerHTML = 'hello2'", "nonci");
|
|
118
166
|
expect(probe2.html().value).to.eq("hello2");
|
|
119
167
|
});
|
|
120
168
|
|
|
169
|
+
|
|
170
|
+
it('domquery ops test2 with sticky eval code', () => {
|
|
171
|
+
let probe2 = DomQuery.querySelectorAll("div#id_1");
|
|
172
|
+
|
|
173
|
+
DomQuery.globalEvalSticky("document.getElementById('id_1').innerHTML = 'hello'");
|
|
174
|
+
expect(probe2.html().value).to.eq("hello");
|
|
175
|
+
expect(DomQuery.byId(document.head).innerHTML.indexOf("document.getElementById('id_1').innerHTML = 'hello'")).not.to.eq(-1);
|
|
176
|
+
|
|
177
|
+
DomQuery.globalEvalSticky("document.getElementById('id_1').innerHTML = 'hello2'", "nonci");
|
|
178
|
+
expect(probe2.html().value).to.eq("hello2");
|
|
179
|
+
expect(DomQuery.byId(document.head).innerHTML.indexOf("document.getElementById('id_1').innerHTML = 'hello2'")).not.to.eq(-1);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
|
|
121
183
|
it('domquery ops test2 eachNode', function () {
|
|
122
184
|
let probe2 = DomQuery.querySelectorAll("div");
|
|
123
185
|
let noIter = 0;
|
|
124
|
-
probe2.each((item, cnt) => {
|
|
186
|
+
probe2 = probe2.each((item, cnt) => {
|
|
125
187
|
expect(item instanceof DomQuery).to.be.true;
|
|
126
188
|
expect(noIter == cnt).to.be.true;
|
|
127
189
|
noIter++;
|
|
@@ -137,7 +199,7 @@ describe('DOMQuery tests', function () {
|
|
|
137
199
|
});
|
|
138
200
|
|
|
139
201
|
it('outerhtml and eval tests', function () {
|
|
140
|
-
let probe1 = new
|
|
202
|
+
let probe1 = new DomQuery(window.document.body);
|
|
141
203
|
probe1.querySelectorAll("#id_1").outerHTML(`
|
|
142
204
|
<div id='barg'>
|
|
143
205
|
|
|
@@ -152,7 +214,7 @@ describe('DOMQuery tests', function () {
|
|
|
152
214
|
expect(window.document.body.innerHTML.indexOf("blarg") != -1).to.be.true;
|
|
153
215
|
});
|
|
154
216
|
|
|
155
|
-
it('
|
|
217
|
+
it('attr test and eval tests', function () {
|
|
156
218
|
|
|
157
219
|
let probe1 = new DomQuery(document);
|
|
158
220
|
probe1.querySelectorAll("div#id_2").attr("style").value = "border=1;";
|
|
@@ -163,6 +225,20 @@ describe('DOMQuery tests', function () {
|
|
|
163
225
|
expect(blarg).to.be.eq("blarg");
|
|
164
226
|
expect(style).to.be.eq("border=1;");
|
|
165
227
|
expect(nonexistent).to.be.eq(null);
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it('style must work ', function () {
|
|
233
|
+
let probe1 = new DomQuery(document);
|
|
234
|
+
let probe = probe1.querySelectorAll("div#id_2");
|
|
235
|
+
probe.style("border").value = "10px solid red";
|
|
236
|
+
probe.style("color").value = "blue";
|
|
237
|
+
let styleNodeLevel = (probe.getAsElem(0).value as HTMLElement).style['color'];
|
|
238
|
+
expect(probe.style("border").value).to.eq("10px solid red")
|
|
239
|
+
expect(probe.style("color").value).to.eq("blue");
|
|
240
|
+
expect(styleNodeLevel).to.eq('blue');
|
|
241
|
+
|
|
166
242
|
});
|
|
167
243
|
|
|
168
244
|
it('must perform addClass and hasClass correctly', function () {
|
|
@@ -171,7 +247,7 @@ describe('DOMQuery tests', function () {
|
|
|
171
247
|
element.addClass("booga").addClass("Booga2");
|
|
172
248
|
|
|
173
249
|
let classdef = element.attr("class").value;
|
|
174
|
-
expect(classdef).to.eq("booga Booga2");
|
|
250
|
+
expect(classdef).to.eq("blarg2 booga Booga2");
|
|
175
251
|
|
|
176
252
|
element.removeClass("booga2")
|
|
177
253
|
expect(element.hasClass("booga2")).to.be.false;
|
|
@@ -179,6 +255,34 @@ describe('DOMQuery tests', function () {
|
|
|
179
255
|
|
|
180
256
|
});
|
|
181
257
|
|
|
258
|
+
it('must perform addClass and hasClass correctly 2', function () {
|
|
259
|
+
let probe1 = new DomQuery(document);
|
|
260
|
+
let element = probe1.querySelectorAll(".blarg2");
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
element.addClass("booga").addClass("Booga2");
|
|
264
|
+
|
|
265
|
+
let classdef = element.attr("class").value;
|
|
266
|
+
expect(classdef).to.eq("blarg2 booga Booga2");
|
|
267
|
+
|
|
268
|
+
element.removeClass("booga2")
|
|
269
|
+
expect(element.hasClass("booga2")).to.be.false;
|
|
270
|
+
expect(element.hasClass("booga")).to.be.true;
|
|
271
|
+
expect(element.hasClass("blarg2")).to.be.true;
|
|
272
|
+
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
it('must perform addClass and hasClass correctly 2', function () {
|
|
276
|
+
let probe1 = new DomQuery(document);
|
|
277
|
+
let element = probe1.querySelectorAll(".blarg2");
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
element.addClass("booga").addClass("Booga2");
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
expect(probe1.querySelectorAll(".Booga2").length).eq(2);
|
|
284
|
+
});
|
|
285
|
+
|
|
182
286
|
it('must perform insert before and insert after correctly', function () {
|
|
183
287
|
let probe1 = new DomQuery(document).querySelectorAll("#id_2");
|
|
184
288
|
let insert = DomQuery.fromMarkup("<div id='insertedBefore'></div><div id='insertedBefore2'></div>")
|
|
@@ -204,6 +308,15 @@ describe('DOMQuery tests', function () {
|
|
|
204
308
|
|
|
205
309
|
});
|
|
206
310
|
|
|
311
|
+
it('it must stream to a domquery', function () {
|
|
312
|
+
let probe1 = new DomQuery(document).querySelectorAll("div");
|
|
313
|
+
let coll: DomQuery = probe1.stream.collect(new DomQueryCollector());
|
|
314
|
+
expect(coll.length == 4).to.be.true;
|
|
315
|
+
|
|
316
|
+
coll = probe1.lazyStream.collect(new DomQueryCollector());
|
|
317
|
+
expect(coll.length == 4).to.be.true;
|
|
318
|
+
});
|
|
319
|
+
|
|
207
320
|
it('it must have parents', function () {
|
|
208
321
|
let probe1 = new DomQuery(document).querySelectorAll("div");
|
|
209
322
|
let coll: Array<any> = probe1.parents("body").stream.collect(new ArrayCollector());
|
|
@@ -217,10 +330,10 @@ describe('DOMQuery tests', function () {
|
|
|
217
330
|
probe1.insertAfter(DomQuery.fromMarkup(` <div id="id_x_0_1"></div><div id="id_x_1_1"></div>`));
|
|
218
331
|
|
|
219
332
|
expect(DomQuery.querySelectorAll("div").length).to.eq(8);
|
|
220
|
-
DomQuery.querySelectorAll("body").
|
|
333
|
+
DomQuery.querySelectorAll("body").innerHTML = trim(DomQuery.querySelectorAll("body").innerHTML.replace(/>\s*</gi, "><"));
|
|
221
334
|
expect(DomQuery.querySelectorAll("body").childNodes.length).to.eq(8);
|
|
222
335
|
|
|
223
|
-
let innerHtml = DomQuery.querySelectorAll("body").
|
|
336
|
+
let innerHtml = DomQuery.querySelectorAll("body").innerHTML;
|
|
224
337
|
expect(innerHtml.indexOf("id_x_0") < innerHtml.indexOf("id_x_1")).to.be.true;
|
|
225
338
|
expect(innerHtml.indexOf("id_x_0") < innerHtml.indexOf("id_2")).to.be.true;
|
|
226
339
|
expect(innerHtml.indexOf("id_x_0") > 0).to.be.true;
|
|
@@ -230,21 +343,21 @@ describe('DOMQuery tests', function () {
|
|
|
230
343
|
})
|
|
231
344
|
|
|
232
345
|
it("must have a working input handling", function () {
|
|
233
|
-
DomQuery.querySelectorAll("body").
|
|
346
|
+
DomQuery.querySelectorAll("body").innerHTML = `<form id="blarg">
|
|
234
347
|
<div id="embed1">
|
|
235
|
-
<input type="text" id="id_1" name="id_1" value="id_1_val"
|
|
236
|
-
<input type="text" id="id_2" name="id_2" value="id_2_val" disabled="disabled"
|
|
348
|
+
<input type="text" id="id_1" name="id_1" value="id_1_val"></input>
|
|
349
|
+
<input type="text" id="id_2" name="id_2" value="id_2_val" disabled="disabled"> </input>
|
|
237
350
|
<textarea type="text" id="id_3" name="id_3">textareaVal</textarea>
|
|
238
351
|
|
|
239
352
|
<fieldset>
|
|
240
|
-
<input type="radio" id="mc" name="cc_1" value="Mastercard" checked="checked"
|
|
353
|
+
<input type="radio" id="mc" name="cc_1" value="Mastercard" checked="checked"></input>
|
|
241
354
|
<label for="mc"> Mastercard</label>
|
|
242
|
-
<input type="radio" id="vi" name="cc_1" value="Visa"
|
|
355
|
+
<input type="radio" id="vi" name="cc_1" value="Visa"></input>
|
|
243
356
|
<label for="vi"> Visa</label>
|
|
244
|
-
<input type="radio" id="ae" name="cc_1" value="AmericanExpress"
|
|
357
|
+
<input type="radio" id="ae" name="cc_1" value="AmericanExpress"></input>
|
|
245
358
|
<label for="ae"> American Express</label>
|
|
246
359
|
</fieldset>
|
|
247
|
-
<select id="val_5" name="val_5" size="5">
|
|
360
|
+
<select id="val_5" name="val_5" name="top5" size="5">
|
|
248
361
|
<option>barg</option>
|
|
249
362
|
<option>jjj</option>
|
|
250
363
|
<option selected>akaka</option>
|
|
@@ -255,8 +368,7 @@ describe('DOMQuery tests', function () {
|
|
|
255
368
|
</form>
|
|
256
369
|
`;
|
|
257
370
|
|
|
258
|
-
let
|
|
259
|
-
let length = elements.length;
|
|
371
|
+
let length = DomQuery.querySelectorAll("form").elements.length;
|
|
260
372
|
expect(length == 8).to.be.true;
|
|
261
373
|
let length1 = DomQuery.querySelectorAll("body").elements.length;
|
|
262
374
|
expect(length1 == 8).to.be.true;
|
|
@@ -301,16 +413,9 @@ describe('DOMQuery tests', function () {
|
|
|
301
413
|
|
|
302
414
|
it("must have a proper loadScriptEval execution", function (done) {
|
|
303
415
|
|
|
304
|
-
DomQuery.byTagName("body").loadScriptEval("test.js");
|
|
305
|
-
|
|
306
|
-
let xhr = this.requests[0];
|
|
307
|
-
xhr.respond(200, {
|
|
308
|
-
"content-type": "application/javascript",
|
|
309
|
-
}, `
|
|
310
|
-
document.getElementById('id_1').innerHTML = "hello world";
|
|
311
|
-
`);
|
|
416
|
+
DomQuery.byTagName("body").loadScriptEval("./fixtures/test.js");
|
|
312
417
|
setTimeout(() => {
|
|
313
|
-
expect(DomQuery.byId("id_1").
|
|
418
|
+
expect(DomQuery.byId("id_1").innerHTML == "hello world").to.be.true;
|
|
314
419
|
done();
|
|
315
420
|
}, 100)
|
|
316
421
|
|
|
@@ -320,8 +425,8 @@ describe('DOMQuery tests', function () {
|
|
|
320
425
|
expect(DomQuery.querySelectorAll("div").first().id.value).to.eq("id_1");
|
|
321
426
|
});
|
|
322
427
|
|
|
323
|
-
it("runscript runcss", function () {
|
|
324
|
-
DomQuery.byTagName("body").
|
|
428
|
+
it("runscript runcss", function (done) {
|
|
429
|
+
DomQuery.byTagName("body").innerHTML = `
|
|
325
430
|
<div id="first"></div>
|
|
326
431
|
<div id="second"></div>
|
|
327
432
|
<div id="third"></div>
|
|
@@ -346,44 +451,38 @@ describe('DOMQuery tests', function () {
|
|
|
346
451
|
//-->
|
|
347
452
|
</script>
|
|
348
453
|
|
|
349
|
-
<style>
|
|
454
|
+
<style type="text/css">
|
|
350
455
|
#first {
|
|
351
456
|
border: 1px solid black;
|
|
352
457
|
}
|
|
353
458
|
</style>
|
|
354
459
|
`;
|
|
355
460
|
let content = DomQuery.byTagName("body").runScripts().runCss();
|
|
356
|
-
expect(content.byId("first").
|
|
357
|
-
expect(content.byId("second").
|
|
358
|
-
expect(content.byId("third").
|
|
359
|
-
expect(content.byId("fourth").
|
|
461
|
+
expect(content.byId("first").innerHTML).to.eq("hello world");
|
|
462
|
+
expect(content.byId("second").innerHTML).to.eq("hello world");
|
|
463
|
+
expect(content.byId("third").innerHTML).to.eq("hello world");
|
|
464
|
+
expect(content.byId("fourth").innerHTML).to.eq("hello world");
|
|
465
|
+
done();
|
|
360
466
|
|
|
361
467
|
});
|
|
362
468
|
|
|
469
|
+
//TODO defer does not work in jsdom
|
|
363
470
|
it("must have a proper loadScriptEval deferred", function (done) {
|
|
364
|
-
|
|
365
|
-
DomQuery.byTagName("body").loadScriptEval("test.js", 700);
|
|
366
|
-
|
|
367
|
-
let xhr = this.requests[0];
|
|
368
|
-
xhr.respond(200, {
|
|
369
|
-
"content-type": "application/javascript",
|
|
370
|
-
}, `
|
|
371
|
-
document.getElementById('id_1').innerHTML = "hello world";
|
|
372
|
-
`);
|
|
471
|
+
DomQuery.byId(document.body).loadScriptEval("./fixtures/test2.js", 200);
|
|
373
472
|
setTimeout(() => {
|
|
374
|
-
expect(DomQuery.byId("id_1").
|
|
375
|
-
|
|
473
|
+
expect(DomQuery.byId("id_1").innerHTML == "hello world").to.be.false;
|
|
376
474
|
}, 100)
|
|
377
475
|
|
|
476
|
+
|
|
378
477
|
setTimeout(() => {
|
|
379
|
-
expect(DomQuery.byId("id_1").
|
|
478
|
+
expect(DomQuery.byId("id_1").innerHTML == "hello world").to.be.true;
|
|
380
479
|
done();
|
|
381
|
-
},
|
|
480
|
+
}, 1500)
|
|
382
481
|
})
|
|
383
482
|
|
|
384
483
|
it("it must handle events properly", function () {
|
|
385
484
|
let clicked = 0;
|
|
386
|
-
let listener = () => {
|
|
485
|
+
let listener = (evt: any) => {
|
|
387
486
|
clicked++;
|
|
388
487
|
};
|
|
389
488
|
let eventReceiver = DomQuery.byId("id_1");
|
|
@@ -409,12 +508,12 @@ describe('DOMQuery tests', function () {
|
|
|
409
508
|
});
|
|
410
509
|
|
|
411
510
|
let probe = DomQuery.byId("id_1");
|
|
412
|
-
probe.
|
|
511
|
+
probe.innerHTML = "<div>hello</div><div>world</div>";
|
|
413
512
|
expect(probe.innerText()).to.eq("helloworld");
|
|
414
513
|
});
|
|
415
514
|
it("it must handle textContent properly", function () {
|
|
416
515
|
let probe = DomQuery.byId("id_1");
|
|
417
|
-
probe.
|
|
516
|
+
probe.innerHTML = "<div>hello</div><div>world</div>";
|
|
418
517
|
expect(probe.textContent()).to.eq("helloworld");
|
|
419
518
|
});
|
|
420
519
|
|
|
@@ -436,12 +535,128 @@ describe('DOMQuery tests', function () {
|
|
|
436
535
|
|
|
437
536
|
it("it must handle subnodes properly", function () {
|
|
438
537
|
let probe = DomQuery.byTagName("div");
|
|
439
|
-
expect(probe.subNodes(1,3).length).to.eq(2);
|
|
440
|
-
probe = DomQuery.byTagName("body").childNodes.subNodes(0,2);
|
|
538
|
+
expect(probe.subNodes(1, 3).length).to.eq(2);
|
|
539
|
+
probe = DomQuery.byTagName("body").childNodes.subNodes(0, 2);
|
|
441
540
|
expect(probe.length).to.eq(2);
|
|
442
541
|
|
|
443
542
|
probe = DomQuery.byTagName("div").subNodes(2);
|
|
444
543
|
expect(probe.length).to.eq(2);
|
|
445
544
|
})
|
|
446
545
|
|
|
546
|
+
|
|
547
|
+
it("it must ensure shadow dom creation works properly", function () {
|
|
548
|
+
let probe = DomQuery.byTagName("div");
|
|
549
|
+
try {
|
|
550
|
+
//probably not testable atm, mocha does not have shadow dom support
|
|
551
|
+
//we might be able to shim it in one way or the other
|
|
552
|
+
let element = probe.attachShadow();
|
|
553
|
+
expect(element.length > 0).to.eq(true);
|
|
554
|
+
} catch (e) {
|
|
555
|
+
//not supported we still need to get an error here
|
|
556
|
+
expect(e.message.indexOf("not supported") != -1).to.be.true;
|
|
557
|
+
}
|
|
558
|
+
})
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
it('it must have a working wait for dom with mut observer and must detect condition after change', async function () {
|
|
562
|
+
let probe = DomQuery.byId('id_1');
|
|
563
|
+
probe.innerHTML = 'true';
|
|
564
|
+
let ret = await probe.waitUntilDom((element) => element.innerHTML.indexOf('true') != -1);
|
|
565
|
+
expect(ret.isPresent());
|
|
566
|
+
probe = DomQuery.byId('bosushsdhs');
|
|
567
|
+
ret = await probe.waitUntilDom((element) => element.isAbsent());
|
|
568
|
+
expect(ret.isAbsent());
|
|
569
|
+
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
it('it must have a working wait for dom with mut observer', async function () {
|
|
573
|
+
let probe = DomQuery.byId('id_1');
|
|
574
|
+
setTimeout(() => probe.innerHTML = 'true', 300);
|
|
575
|
+
let ret = await probe.waitUntilDom((element) => element.innerHTML.indexOf('true') != -1);
|
|
576
|
+
delete window.MutationObserver;
|
|
577
|
+
delete global.MutationObserver;
|
|
578
|
+
probe.innerHTML = "";
|
|
579
|
+
setTimeout(() => probe.innerHTML = 'true', 300);
|
|
580
|
+
let ret2 = await probe.waitUntilDom((element) => element.innerHTML.indexOf('true') != -1);
|
|
581
|
+
expect(ret.isPresent() && ret2.isPresent());
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
it('it must have a timeout', async function () {
|
|
585
|
+
let probe = DomQuery.byId('booga');
|
|
586
|
+
try {
|
|
587
|
+
setTimeout(() => probe.innerHTML = 'true', 300);
|
|
588
|
+
await probe.waitUntilDom((element) => element.innerHTML.indexOf('true') != -1);
|
|
589
|
+
expect.fail("must have a timeout");
|
|
590
|
+
} catch (ex) {
|
|
591
|
+
expect(!!ex);
|
|
592
|
+
}
|
|
593
|
+
try {
|
|
594
|
+
delete window.MutationObserver;
|
|
595
|
+
delete global.MutationObserver;
|
|
596
|
+
probe.innerHTML = "";
|
|
597
|
+
setTimeout(() => probe.innerHTML = 'true', 300);
|
|
598
|
+
await probe.waitUntilDom((element) => element.innerHTML.indexOf('true') != -1);
|
|
599
|
+
expect.fail("must have a timeout");
|
|
600
|
+
} catch (ex2) {
|
|
601
|
+
expect(!!ex2);
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
it('must handle null inputs correctly', function () {
|
|
605
|
+
const dq = new DomQuery(null);
|
|
606
|
+
expect(dq.isAbsent()).to.eq(true);
|
|
607
|
+
})
|
|
608
|
+
|
|
609
|
+
it('concat must work as expected resulting', function () {
|
|
610
|
+
let probe = DomQuery.querySelectorAll("div");
|
|
611
|
+
let probe2 = DomQuery.querySelectorAll("body");
|
|
612
|
+
let result = probe.concat(probe2);
|
|
613
|
+
expect(result.length).to.eq(probe.length + probe2.length);
|
|
614
|
+
|
|
615
|
+
//lets now check for filter double
|
|
616
|
+
probe2 = DomQuery.querySelectorAll('div');
|
|
617
|
+
result = probe.concat(probe2);
|
|
618
|
+
expect(result.length).to.eq(probe.length);
|
|
619
|
+
})
|
|
620
|
+
|
|
621
|
+
it('must handle match correctly', function () {
|
|
622
|
+
let probe = DomQuery.querySelectorAll("div").first();
|
|
623
|
+
let probe2 = DomQuery.querySelectorAll("body").first();
|
|
624
|
+
|
|
625
|
+
expect(probe.matchesSelector("div")).to.eq(true);
|
|
626
|
+
expect(probe2.matchesSelector("body")).to.eq(true);
|
|
627
|
+
expect(probe2.matchesSelector("div")).to.eq(false);
|
|
628
|
+
})
|
|
629
|
+
|
|
630
|
+
it('must by recycleable', function () {
|
|
631
|
+
let probe = DomQuery.querySelectorAll("div");
|
|
632
|
+
let probe2 = DomQuery.querySelectorAll("body");
|
|
633
|
+
|
|
634
|
+
let res1 = probe.filter(item => item.matchesSelector("div"));
|
|
635
|
+
expect(res1.length).to.eq(4);
|
|
636
|
+
let res2 = probe.filter(item => item.matchesSelector("div"));
|
|
637
|
+
expect(res2.length).to.eq(4);
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
})
|
|
641
|
+
|
|
642
|
+
it('delete must work', function () {
|
|
643
|
+
let probe = DomQuery.querySelectorAll("body");
|
|
644
|
+
let probe2 = DomQuery.fromMarkup("<div id='deleteprobe1'>snafu</div>");
|
|
645
|
+
|
|
646
|
+
probe2.appendTo(probe);
|
|
647
|
+
|
|
648
|
+
expect(probe.querySelectorAll("#deleteprobe1").isPresent()).to.eq(true);
|
|
649
|
+
probe2.delete();
|
|
650
|
+
expect(probe.querySelectorAll("#deleteprobe1").isAbsent()).to.eq(true);
|
|
651
|
+
})
|
|
652
|
+
it('must work with rxjs and domquery', function () {
|
|
653
|
+
let probe = DomQuery.querySelectorAll("div");
|
|
654
|
+
let probe2 = DomQuery.querySelectorAll("div");
|
|
655
|
+
let probeCnt = 0;
|
|
656
|
+
let probe2Cnt = 0;
|
|
657
|
+
from(probe).subscribe(el => probeCnt++);
|
|
658
|
+
from(probe2.stream).subscribe(el => probe2Cnt++);
|
|
659
|
+
expect(probeCnt).to.be.above(0);
|
|
660
|
+
expect(probeCnt).to.eq(probe2Cnt);
|
|
661
|
+
})
|
|
447
662
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
document.getElementById('id_1').innerHTML = "hello world";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
document.getElementById('id_1').innerHTML = "hello world";
|
|
@@ -179,7 +179,9 @@ export module StandardInits {
|
|
|
179
179
|
|
|
180
180
|
<div id="attributeChange">attributes changes area</div>
|
|
181
181
|
|
|
182
|
-
|
|
182
|
+
<div id="resource_area_1"></div>
|
|
183
|
+
<div id="resource_area_2"></div>
|
|
184
|
+
<div id="resource_area_3"></div>
|
|
183
185
|
|
|
184
186
|
</div>
|
|
185
187
|
|
|
@@ -194,6 +196,15 @@ export module StandardInits {
|
|
|
194
196
|
|
|
195
197
|
<input type="button" id="cmd_update_insert" value="update insert"
|
|
196
198
|
onclick="emitPPR(this, ('undefined' == typeof event)? null: event, 'updateinsert1');"/>
|
|
199
|
+
|
|
200
|
+
<input type="button" id="cmd_simple_resource" value="simple resource"
|
|
201
|
+
onclick="emitPPR(this, ('undefined' == typeof event)? null: event, 'simpleresource');"/>
|
|
202
|
+
|
|
203
|
+
<input type="button" id="cmd_complex_resource" value="complex resource"
|
|
204
|
+
onclick="emitPPR(this, ('undefined' == typeof event)? null: event, 'complex_resource');"/>
|
|
205
|
+
|
|
206
|
+
<input type="button" id="cmd_complex_resource2" value="complex resource2"
|
|
207
|
+
onclick="emitPPR(this, ('undefined' == typeof event)? null: event, 'complex_resource2');"/>
|
|
197
208
|
|
|
198
209
|
<input type="button" id="cmd_update_insert2" value="update insert second protocol path"
|
|
199
210
|
onclick="emitPPR(this, ('undefined' == typeof event)? null: event, 'updateinsert2');"/>
|
|
@@ -344,7 +355,9 @@ export module StandardInits {
|
|
|
344
355
|
return import('jsdom-global').then((domIt) => {
|
|
345
356
|
let params = {
|
|
346
357
|
contentType: "text/html",
|
|
347
|
-
runScripts: "dangerously"
|
|
358
|
+
runScripts: "dangerously",
|
|
359
|
+
resources: "usable",
|
|
360
|
+
url: `file://${__dirname}/index.html`
|
|
348
361
|
};
|
|
349
362
|
//we have two different apis depending whether we allow module interop with sinon or not
|
|
350
363
|
return (domIt?.default ?? domIt)?.(template, params) ;
|
|
@@ -170,5 +170,39 @@ export class XmlResponses {
|
|
|
170
170
|
</partial-response>
|
|
171
171
|
`;
|
|
172
172
|
|
|
173
|
+
static SIMPLE_RESOURCE_RESPONSE = `
|
|
174
|
+
<partial-response>
|
|
175
|
+
<changes>
|
|
176
|
+
<update id="jakarta.faces.Resource">
|
|
177
|
+
<![CDATA[<script src="../../../xhrCore/fixtures/addedViewHead1.js"></script>]]>
|
|
178
|
+
</update>
|
|
179
|
+
</changes>
|
|
180
|
+
</partial-response>
|
|
181
|
+
`;
|
|
182
|
+
static MULTIPLE_RESOURCE_RESPONSE = `
|
|
183
|
+
<partial-response id="j_id__v_0"><changes><update id="jakarta.faces.Resource">
|
|
184
|
+
<![CDATA[
|
|
185
|
+
<script src="../../../xhrCore/fixtures/addedViewHead2.js"></script>
|
|
186
|
+
<style type="text/css" rel="../../../xhrCore/fixtures/addedViewHead2.css"></style>
|
|
187
|
+
]]>
|
|
188
|
+
</update>
|
|
189
|
+
</changes>
|
|
190
|
+
</partial-response>
|
|
191
|
+
`
|
|
192
|
+
|
|
193
|
+
static EMBEDDED_SCRIPTS_RESOURCE_RESPONSE = `
|
|
194
|
+
<partial-response id="j_id__v_0"><changes><update id="jakarta.faces.Resource">
|
|
195
|
+
<![CDATA[
|
|
196
|
+
<script src="../../../xhrCore/fixtures/addedViewHead3.js"></script>
|
|
197
|
+
<style type="text/css" rel="../../../xhrCore/fixtures/addedViewHead2.css"></style>
|
|
198
|
+
<script type="text/javascript">
|
|
199
|
+
document.getElementById('resource_area_1').innerHTML = 'booga';
|
|
200
|
+
</script>
|
|
201
|
+
]]>
|
|
202
|
+
</update>
|
|
203
|
+
</changes>
|
|
204
|
+
</partial-response>
|
|
205
|
+
`
|
|
206
|
+
|
|
173
207
|
static ILLEGAL_RESP = `>>>> xxxx >YYYY-!->>>`;
|
|
174
208
|
}
|