jsf.js_next_gen 4.0.1-alpha.0 → 4.0.1-beta.2
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/README.md +0 -12
- package/dist/docs/assets/search.js +1 -1
- package/dist/docs/functions/faces.ajax.addOnError.html +4 -4
- package/dist/docs/functions/faces.ajax.request.html +7 -7
- package/dist/docs/functions/faces.ajax.response.html +0 -1
- package/dist/docs/functions/faces.util.chain.html +3 -3
- package/dist/docs/functions/myfaces.ab.html +1 -1
- package/dist/docs/functions/{myfaces.onDomReady.html → myfaces.onOnDomReady.html} +5 -5
- package/dist/docs/index.html +0 -14
- package/dist/docs/modules/myfaces.html +2 -2
- package/dist/docs/variables/myfaces.oam.html +1 -1
- package/dist/window/faces-development.js +1323 -1300
- 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 +1323 -1300
- 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 +3 -3
- package/pom.xml +1 -1
- package/src/main/typescript/@types/definitions/index.d.ts +5 -5
- package/src/main/typescript/api/_api.ts +12 -13
- package/src/main/typescript/impl/AjaxImpl.ts +68 -65
- package/src/main/typescript/impl/core/Const.ts +2 -5
- package/src/main/typescript/impl/util/AsyncQueue.ts +133 -0
- package/src/main/typescript/impl/util/AsyncRunnable.ts +6 -81
- package/src/main/typescript/impl/util/ExtDomQuery.ts +9 -7
- package/src/main/typescript/impl/util/FileUtils.ts +22 -26
- package/src/main/typescript/impl/util/HiddenInputBuilder.ts +3 -7
- package/src/main/typescript/impl/util/Lang.ts +4 -61
- package/src/main/typescript/impl/xhrCore/EventData.ts +3 -3
- package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +10 -12
- package/src/main/typescript/impl/xhrCore/XhrFormData.ts +19 -32
- package/src/main/typescript/impl/xhrCore/XhrRequest.ts +72 -51
- package/src/main/typescript/myfaces/OamSubmit.ts +6 -6
- package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +40 -179
- package/src/main/typescript/test/frameworkBase/_ext/monadish/MonadTest.spec.ts +4 -4
- package/src/main/typescript/test/frameworkBase/_ext/monadish/StreamTest.spec.ts +231 -0
- package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +4 -5
- package/src/main/typescript/test/queue/AsynchronousProbe.ts +5 -5
- package/src/main/typescript/test/queue/AsynchronousQueueTest.spec.ts +3 -4
- package/src/main/typescript/test/xhrCore/ClientWindow.spec.ts +78 -0
- package/src/main/typescript/test/xhrCore/EventTests.spec.ts +22 -28
- package/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.ts +4 -4
- package/src/main/typescript/test/xhrCore/RequestParamsTest.spec.ts +2 -2
- package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +6 -80
- package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +1 -6
- package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +22 -23
- package/src/main/typescript/test/xhrCore/TobagoFileUploadTest.spec.ts +5 -5
- package/target/api/_api.js +11 -12
- package/target/api/_api.js.map +1 -1
- package/target/impl/AjaxImpl.js +59 -55
- package/target/impl/AjaxImpl.js.map +1 -1
- package/target/impl/core/Const.js +5 -7
- package/target/impl/core/Const.js.map +1 -1
- package/target/impl/util/AsyncRunnable.js +0 -60
- package/target/impl/util/AsyncRunnable.js.map +1 -1
- package/target/impl/util/ExtDomQuery.js +8 -8
- package/target/impl/util/ExtDomQuery.js.map +1 -1
- package/target/impl/util/FileUtils.js +20 -21
- package/target/impl/util/FileUtils.js.map +1 -1
- package/target/impl/util/HiddenInputBuilder.js +3 -7
- package/target/impl/util/HiddenInputBuilder.js.map +1 -1
- package/target/impl/util/Lang.js +1 -52
- package/target/impl/util/Lang.js.map +1 -1
- package/target/impl/xhrCore/EventData.js +2 -2
- package/target/impl/xhrCore/EventData.js.map +1 -1
- package/target/impl/xhrCore/ResponseProcessor.js +7 -9
- package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
- package/target/impl/xhrCore/XhrFormData.js +15 -29
- package/target/impl/xhrCore/XhrFormData.js.map +1 -1
- package/target/impl/xhrCore/XhrRequest.js +64 -43
- package/target/impl/xhrCore/XhrRequest.js.map +1 -1
- package/target/myfaces/OamSubmit.js +3 -5
- package/target/myfaces/OamSubmit.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +37 -138
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js +4 -4
- package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/StandardInits.js +4 -5
- package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
- package/target/test/queue/AsynchronousQueueTest.spec.js +3 -3
- package/target/test/queue/AsynchronousQueueTest.spec.js.map +1 -1
- package/target/test/xhrCore/ClientWindow.spec.js +90 -0
- package/target/test/xhrCore/ClientWindow.spec.js.map +1 -0
- package/target/test/xhrCore/EventTests.spec.js +19 -26
- package/target/test/xhrCore/EventTests.spec.js.map +1 -1
- package/target/test/xhrCore/NamespacesRequestTest.spec.js +3 -3
- package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestParamsTest.spec.js +1 -1
- package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest.spec.js +4 -73
- package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest_23.spec.js +0 -6
- package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest.spec.js +15 -22
- package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
- package/target/test/xhrCore/TobagoFileUploadTest.spec.js +5 -5
- package/target/test/xhrCore/TobagoFileUploadTest.spec.js.map +1 -1
- package/plans for 4.0.1.txt +0 -8
- package/src/main/typescript/impl/util/XhrQueueController.ts +0 -112
- package/src/main/typescript/test/frameworkBase/_ext/monadish/fixtures/blank.css +0 -0
- package/src/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-with-header.ts +0 -921
- package/src/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-without-header.ts +0 -108
- package/src/main/typescript/test/frameworkBase/_ext/shared/fixtures/jakarta.faces.resource/faces.js.jsf +0 -0
- package/src/main/typescript/test/myfaces/OnLoadSpec.ts +0 -52
|
@@ -16,21 +16,20 @@
|
|
|
16
16
|
|
|
17
17
|
import {expect} from 'chai';
|
|
18
18
|
import {describe, it} from 'mocha';
|
|
19
|
+
import {ArrayCollector, DomQuery, DomQueryCollector, Lang, LazyStream} from "mona-dish";
|
|
20
|
+
import trim = Lang.trim;
|
|
19
21
|
import {from} from "rxjs";
|
|
20
|
-
|
|
21
|
-
import {tobagoSheetWithHeader} from "./markups/tobago-with-header";
|
|
22
|
-
import {tobagoSheetWithoutHeader} from "./markups/tobago-without-header";
|
|
22
|
+
|
|
23
23
|
|
|
24
24
|
const jsdom = require("jsdom");
|
|
25
25
|
const {JSDOM} = jsdom;
|
|
26
|
-
import trim = Lang.trim;
|
|
27
|
-
|
|
28
26
|
(global as any).window = {}
|
|
29
27
|
let dom = null;
|
|
30
28
|
describe('DOMQuery tests', function () {
|
|
31
29
|
|
|
32
30
|
beforeEach(function () {
|
|
33
31
|
|
|
32
|
+
// language=HTML
|
|
34
33
|
dom = new JSDOM(`
|
|
35
34
|
<!DOCTYPE html>
|
|
36
35
|
<html lang="en">
|
|
@@ -87,14 +86,14 @@ describe('DOMQuery tests', function () {
|
|
|
87
86
|
let probe1 = new DomQuery(window.document.body);
|
|
88
87
|
let probe2 = DomQuery.querySelectorAll("div");
|
|
89
88
|
|
|
90
|
-
let o1 = from(
|
|
91
|
-
let o2 = from(
|
|
89
|
+
let o1 = from(probe1.stream);
|
|
90
|
+
let o2 = from(probe2.stream);
|
|
92
91
|
|
|
93
92
|
let cnt1 = 0;
|
|
94
93
|
let isDQuery = false;
|
|
95
94
|
let cnt2 = 0;
|
|
96
95
|
|
|
97
|
-
o1.subscribe((
|
|
96
|
+
o1.subscribe(() => {
|
|
98
97
|
cnt1++;
|
|
99
98
|
});
|
|
100
99
|
|
|
@@ -113,14 +112,14 @@ describe('DOMQuery tests', function () {
|
|
|
113
112
|
let probe1 = new DomQuery(window.document.body);
|
|
114
113
|
let probe2 = DomQuery.querySelectorAll("div");
|
|
115
114
|
|
|
116
|
-
let o1 = from(
|
|
117
|
-
let o2 = from(
|
|
115
|
+
let o1 = from(probe1.stream);
|
|
116
|
+
let o2 = from(probe2.stream);
|
|
118
117
|
|
|
119
118
|
let cnt1 = 0;
|
|
120
119
|
let isDQuery = false;
|
|
121
120
|
let cnt2 = 0;
|
|
122
121
|
|
|
123
|
-
o1.subscribe((
|
|
122
|
+
o1.subscribe(() => {
|
|
124
123
|
cnt1++;
|
|
125
124
|
});
|
|
126
125
|
|
|
@@ -184,7 +183,7 @@ describe('DOMQuery tests', function () {
|
|
|
184
183
|
it('domquery ops test2 eachNode', function () {
|
|
185
184
|
let probe2 = DomQuery.querySelectorAll("div");
|
|
186
185
|
let noIter = 0;
|
|
187
|
-
probe2
|
|
186
|
+
probe2.each((item, cnt) => {
|
|
188
187
|
expect(item instanceof DomQuery).to.be.true;
|
|
189
188
|
expect(noIter == cnt).to.be.true;
|
|
190
189
|
noIter++;
|
|
@@ -299,61 +298,28 @@ describe('DOMQuery tests', function () {
|
|
|
299
298
|
expect(DomQuery.querySelectorAll("#insertedAfter2").isPresent()).to.be.true;
|
|
300
299
|
});
|
|
301
300
|
|
|
302
|
-
it('do not create new <html> tag on <header', function () {
|
|
303
|
-
|
|
304
|
-
const fromMarkupWithHeader = DomQuery.fromMarkup(tobagoSheetWithHeader);
|
|
305
|
-
const fromMarkupWithoutHeader = DomQuery.fromMarkup(tobagoSheetWithoutHeader);
|
|
306
|
-
|
|
307
|
-
expect(fromMarkupWithHeader.tagName.value === "HTML").to.be.false;
|
|
308
|
-
expect(fromMarkupWithoutHeader.tagName.value === "HTML").to.be.false;
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
it('do not falsely assume standard tag', function () {
|
|
313
|
-
|
|
314
|
-
const fromMarkup1 = DomQuery.fromMarkup(`
|
|
315
|
-
<head-mine>booga</head-mine>
|
|
316
|
-
`);
|
|
317
|
-
|
|
318
|
-
const fromMarkup2 = DomQuery.fromMarkup(`
|
|
319
|
-
<body_mine>booga</body_mine>
|
|
320
|
-
|
|
321
|
-
`);
|
|
322
|
-
expect(fromMarkup1.tagName.value === "HTML").to.be.false;
|
|
323
|
-
expect(fromMarkup1.tagName.value === "HTML").to.be.false;
|
|
324
|
-
expect(fromMarkup1.tagName.value === "HEAD").to.be.false;
|
|
325
|
-
expect(fromMarkup2.tagName.value === "BODY").to.be.false;
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
|
|
329
301
|
it('it must stream', function () {
|
|
330
302
|
let probe1 = new DomQuery(document).querySelectorAll("div");
|
|
331
|
-
let coll: Array<any> =
|
|
303
|
+
let coll: Array<any> = probe1.stream.collect(new ArrayCollector());
|
|
332
304
|
expect(coll.length == 4).to.be.true;
|
|
333
305
|
|
|
334
|
-
coll =
|
|
306
|
+
coll = probe1.lazyStream.collect(new ArrayCollector());
|
|
335
307
|
expect(coll.length == 4).to.be.true;
|
|
336
308
|
|
|
337
309
|
});
|
|
338
310
|
|
|
339
|
-
it('it must stream - DQ API (dynamically added)', function () {
|
|
340
|
-
let probe1 = new DomQuery(document).querySelectorAll("div");
|
|
341
|
-
let coll: Array<any> = probe1.asArray;
|
|
342
|
-
expect(coll.length == 4).to.be.true;
|
|
343
|
-
});
|
|
344
|
-
|
|
345
311
|
it('it must stream to a domquery', function () {
|
|
346
312
|
let probe1 = new DomQuery(document).querySelectorAll("div");
|
|
347
|
-
let coll: DomQuery =
|
|
313
|
+
let coll: DomQuery = probe1.stream.collect(new DomQueryCollector());
|
|
348
314
|
expect(coll.length == 4).to.be.true;
|
|
349
|
-
|
|
350
|
-
coll =
|
|
315
|
+
|
|
316
|
+
coll = probe1.lazyStream.collect(new DomQueryCollector());
|
|
351
317
|
expect(coll.length == 4).to.be.true;
|
|
352
318
|
});
|
|
353
319
|
|
|
354
320
|
it('it must have parents', function () {
|
|
355
321
|
let probe1 = new DomQuery(document).querySelectorAll("div");
|
|
356
|
-
let coll: Array<any> =
|
|
322
|
+
let coll: Array<any> = probe1.firstParent("body").stream.collect(new ArrayCollector());
|
|
357
323
|
expect(coll.length == 1).to.be.true;
|
|
358
324
|
|
|
359
325
|
});
|
|
@@ -376,90 +342,22 @@ describe('DOMQuery tests', function () {
|
|
|
376
342
|
expect(innerHtml.indexOf("id_x_1_1") > innerHtml.indexOf("id_x_0_1")).to.be.true;
|
|
377
343
|
})
|
|
378
344
|
|
|
379
|
-
|
|
380
|
-
it("must have a working replace", function () {
|
|
381
|
-
let probe1 = new DomQuery(document).byId("id_1");
|
|
382
|
-
probe1.replace(DomQuery.fromMarkup(` <div id="id_x_0"></div><div id="id_x_1"></div>`));
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
expect(DomQuery.querySelectorAll("div").length).to.eq(5);
|
|
386
|
-
|
|
387
|
-
let innerHtml = DomQuery.querySelectorAll("body").innerHTML;
|
|
388
|
-
|
|
389
|
-
expect(innerHtml.indexOf("id_x_0") > 0).to.be.true;
|
|
390
|
-
expect(innerHtml.indexOf("id_x_0") < innerHtml.indexOf("id_2")).to.be.true;
|
|
391
|
-
expect(innerHtml.indexOf("id_x_0") < innerHtml.indexOf("id_3")).to.be.true;
|
|
392
|
-
|
|
393
|
-
expect(innerHtml.indexOf("id_x_0") < innerHtml.indexOf("id_x_1")).to.be.true;
|
|
394
|
-
|
|
395
|
-
expect(innerHtml.indexOf("id_x_1") > 0).to.be.true;
|
|
396
|
-
expect(innerHtml.indexOf("id_x_1") < innerHtml.indexOf("id_2")).to.be.true;
|
|
397
|
-
expect(innerHtml.indexOf("id_x_1") < innerHtml.indexOf("id_3")).to.be.true;
|
|
398
|
-
|
|
399
|
-
expect(innerHtml.indexOf("id_1") == -1).to.be.true;
|
|
400
|
-
})
|
|
401
|
-
|
|
402
|
-
it("must have a working replace - 2", function () {
|
|
403
|
-
let probe1 = new DomQuery(document).byId("id_2");
|
|
404
|
-
probe1.replace(DomQuery.fromMarkup(` <div id="id_x_0"></div><div id="id_x_1"></div>`));
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
expect(DomQuery.querySelectorAll("div").length).to.eq(5);
|
|
408
|
-
|
|
409
|
-
let innerHtml = DomQuery.querySelectorAll("body").innerHTML;
|
|
410
|
-
expect(innerHtml.indexOf("id_x_0") > innerHtml.indexOf("id_1")).to.be.true;
|
|
411
|
-
|
|
412
|
-
expect(innerHtml.indexOf("id_x_0") > 0).to.be.true;
|
|
413
|
-
expect(innerHtml.indexOf("id_x_0") > innerHtml.indexOf("id_0")).to.be.true;
|
|
414
|
-
expect(innerHtml.indexOf("id_x_0") < innerHtml.indexOf("id_3")).to.be.true;
|
|
415
|
-
|
|
416
|
-
expect(innerHtml.indexOf("id_x_1") > 0).to.be.true;
|
|
417
|
-
expect(innerHtml.indexOf("id_x_1") > innerHtml.indexOf("id_0")).to.be.true;
|
|
418
|
-
expect(innerHtml.indexOf("id_x_1") < innerHtml.indexOf("id_3")).to.be.true;
|
|
419
|
-
|
|
420
|
-
expect(innerHtml.indexOf("id_2") == -1).to.be.true;
|
|
421
|
-
})
|
|
422
|
-
|
|
423
|
-
it("must have a working replace - 3", function () {
|
|
424
|
-
let probe1 = new DomQuery(document).byId("id_4");
|
|
425
|
-
probe1.replace(DomQuery.fromMarkup(` <div id="id_x_0"></div><div id="id_x_1"></div>`));
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
expect(DomQuery.querySelectorAll("div").length).to.eq(5);
|
|
429
|
-
|
|
430
|
-
let innerHtml = DomQuery.querySelectorAll("body").innerHTML;
|
|
431
|
-
|
|
432
|
-
expect(innerHtml.indexOf("id_x_0") > 0).to.be.true;
|
|
433
|
-
expect(innerHtml.indexOf("id_x_0") > innerHtml.indexOf("id_1")).to.be.true;
|
|
434
|
-
expect(innerHtml.indexOf("id_x_0") > innerHtml.indexOf("id_2")).to.be.true;
|
|
435
|
-
expect(innerHtml.indexOf("id_x_0") > innerHtml.indexOf("id_3")).to.be.true;
|
|
436
|
-
|
|
437
|
-
expect(innerHtml.indexOf("id_x_0") < innerHtml.indexOf("id_x_1")).to.be.true;
|
|
438
|
-
|
|
439
|
-
expect(innerHtml.indexOf("id_x_1") > 0).to.be.true;
|
|
440
|
-
expect(innerHtml.indexOf("id_x_1") > innerHtml.indexOf("id_1")).to.be.true;
|
|
441
|
-
expect(innerHtml.indexOf("id_x_1") > innerHtml.indexOf("id_2")).to.be.true;
|
|
442
|
-
expect(innerHtml.indexOf("id_x_1") > innerHtml.indexOf("id_3")).to.be.true;
|
|
443
|
-
|
|
444
|
-
expect(innerHtml.indexOf("id_4") == -1).to.be.true;
|
|
445
|
-
})
|
|
446
|
-
|
|
447
345
|
it("must have a working input handling", function () {
|
|
448
346
|
DomQuery.querySelectorAll("body").innerHTML = `<form id="blarg">
|
|
449
347
|
<div id="embed1">
|
|
450
|
-
<input type="text" id="id_1" name="id_1" value="id_1_val"
|
|
451
|
-
<input type="text" id="id_2" name="id_2" value="id_2_val" disabled="disabled">
|
|
452
|
-
<textarea
|
|
348
|
+
<input type="text" id="id_1" name="id_1" value="id_1_val">
|
|
349
|
+
<input type="text" id="id_2" name="id_2" value="id_2_val" disabled="disabled">
|
|
350
|
+
<textarea id="id_3" name="id_3">textareaVal</textarea>
|
|
453
351
|
|
|
454
352
|
<fieldset>
|
|
455
|
-
<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">
|
|
456
354
|
<label for="mc"> Mastercard</label>
|
|
457
|
-
<input type="radio" id="vi" name="cc_1" value="Visa"
|
|
355
|
+
<input type="radio" id="vi" name="cc_1" value="Visa">
|
|
458
356
|
<label for="vi"> Visa</label>
|
|
459
|
-
<input type="radio" id="ae" name="cc_1" value="AmericanExpress"
|
|
357
|
+
<input type="radio" id="ae" name="cc_1" value="AmericanExpress">
|
|
460
358
|
<label for="ae"> American Express</label>
|
|
461
359
|
</fieldset>
|
|
462
|
-
<select id="val_5" name="val_5"
|
|
360
|
+
<select id="val_5" name="val_5" size="5">
|
|
463
361
|
<option>barg</option>
|
|
464
362
|
<option>jjj</option>
|
|
465
363
|
<option selected>akaka</option>
|
|
@@ -477,22 +375,22 @@ describe('DOMQuery tests', function () {
|
|
|
477
375
|
let length2 = DomQuery.byId("embed1").elements.length;
|
|
478
376
|
expect(length2 == 8).to.be.true;
|
|
479
377
|
|
|
480
|
-
let count =
|
|
481
|
-
.map
|
|
378
|
+
let count = DomQuery.byId("embed1").elements
|
|
379
|
+
.stream.map(item => item.disabled ? 1 : 0)
|
|
482
380
|
.reduce((val1, val2) => val1 + val2, 0);
|
|
483
381
|
expect(count.value).to.eq(1);
|
|
484
382
|
|
|
485
|
-
|
|
486
|
-
.filter(item => item.disabled)
|
|
383
|
+
DomQuery.byId("embed1").elements
|
|
384
|
+
.stream.filter(item => item.disabled)
|
|
487
385
|
.each(item => item.disabled = false);
|
|
488
386
|
|
|
489
|
-
count =
|
|
490
|
-
.map
|
|
387
|
+
count = DomQuery.byId("embed1").elements
|
|
388
|
+
.stream.map(item => item.disabled ? 1 : 0)
|
|
491
389
|
.reduce((val1, val2) => val1 + val2, 0);
|
|
492
390
|
expect(count.value).to.eq(0);
|
|
493
391
|
|
|
494
|
-
count =
|
|
495
|
-
.map
|
|
392
|
+
count = DomQuery.byId("embed1").elements
|
|
393
|
+
.stream.map(item => item.attr("checked").isPresent() ? 1 : 0)
|
|
496
394
|
.reduce((val1, val2) => val1 + val2, 0);
|
|
497
395
|
expect(count.value).to.eq(1);
|
|
498
396
|
|
|
@@ -505,7 +403,7 @@ describe('DOMQuery tests', function () {
|
|
|
505
403
|
DomQuery.byId("id_3").inputValue.value = "hello world";
|
|
506
404
|
expect(DomQuery.byId("id_3").inputValue.value).to.eq("hello world");
|
|
507
405
|
|
|
508
|
-
let cfg =
|
|
406
|
+
let cfg = DomQuery.querySelectorAll("form").elements.encodeFormElement();
|
|
509
407
|
expect(cfg.getIf("id_1").value[0]).to.eq("booga");
|
|
510
408
|
expect(cfg.getIf("id_2").value[0]).to.eq("id_2_val");
|
|
511
409
|
expect(cfg.getIf("id_3").value[0]).to.eq("hello world");
|
|
@@ -553,22 +451,17 @@ describe('DOMQuery tests', function () {
|
|
|
553
451
|
//-->
|
|
554
452
|
</script>
|
|
555
453
|
|
|
556
|
-
<style
|
|
454
|
+
<style>
|
|
557
455
|
#first {
|
|
558
456
|
border: 1px solid black;
|
|
559
457
|
}
|
|
560
458
|
</style>
|
|
561
|
-
|
|
562
|
-
<link rel="stylesheet" href="./fixtures/blank.css"></link>
|
|
563
459
|
`;
|
|
564
460
|
let content = DomQuery.byTagName("body").runScripts().runCss();
|
|
565
461
|
expect(content.byId("first").innerHTML).to.eq("hello world");
|
|
566
462
|
expect(content.byId("second").innerHTML).to.eq("hello world");
|
|
567
463
|
expect(content.byId("third").innerHTML).to.eq("hello world");
|
|
568
464
|
expect(content.byId("fourth").innerHTML).to.eq("hello world");
|
|
569
|
-
|
|
570
|
-
expect(DomQuery.byTagName("head")
|
|
571
|
-
.querySelectorAll("link[rel='stylesheet'][href='./fixtures/blank.css']").length).to.eq(1);
|
|
572
465
|
done();
|
|
573
466
|
|
|
574
467
|
});
|
|
@@ -589,7 +482,7 @@ describe('DOMQuery tests', function () {
|
|
|
589
482
|
|
|
590
483
|
it("it must handle events properly", function () {
|
|
591
484
|
let clicked = 0;
|
|
592
|
-
let listener = (
|
|
485
|
+
let listener = () => {
|
|
593
486
|
clicked++;
|
|
594
487
|
};
|
|
595
488
|
let eventReceiver = DomQuery.byId("id_1");
|
|
@@ -605,7 +498,7 @@ describe('DOMQuery tests', function () {
|
|
|
605
498
|
|
|
606
499
|
});
|
|
607
500
|
|
|
608
|
-
it("it must handle innerText properly", function (
|
|
501
|
+
it("it must handle innerText properly", function () {
|
|
609
502
|
|
|
610
503
|
//jsdom bug
|
|
611
504
|
Object.defineProperty(Object.prototype, 'innerText', {
|
|
@@ -617,7 +510,6 @@ describe('DOMQuery tests', function () {
|
|
|
617
510
|
let probe = DomQuery.byId("id_1");
|
|
618
511
|
probe.innerHTML = "<div>hello</div><div>world</div>";
|
|
619
512
|
expect(probe.innerText()).to.eq("helloworld");
|
|
620
|
-
done();
|
|
621
513
|
});
|
|
622
514
|
it("it must handle textContent properly", function () {
|
|
623
515
|
let probe = DomQuery.byId("id_1");
|
|
@@ -627,7 +519,7 @@ describe('DOMQuery tests', function () {
|
|
|
627
519
|
|
|
628
520
|
it("it must handle iterations properly", function () {
|
|
629
521
|
let probe = DomQuery.byTagName("div");
|
|
630
|
-
let resArr =
|
|
522
|
+
let resArr = probe.lazyStream.collect(new ArrayCollector());
|
|
631
523
|
expect(resArr.length).to.eq(4);
|
|
632
524
|
|
|
633
525
|
probe.reset();
|
|
@@ -666,21 +558,6 @@ describe('DOMQuery tests', function () {
|
|
|
666
558
|
})
|
|
667
559
|
|
|
668
560
|
|
|
669
|
-
it("parent must break shadow barriers", function () {
|
|
670
|
-
let probe = DomQuery.fromMarkup("<div id='shadowItem'>hello</div>'");
|
|
671
|
-
try {
|
|
672
|
-
//probably not testable atm, mocha does not have shadow dom support
|
|
673
|
-
//we might be able to shim it in one way or the other
|
|
674
|
-
let element = DomQuery.byId("id_1").attachShadow();
|
|
675
|
-
element.append(probe);
|
|
676
|
-
expect(probe.firstParent("#id_1").length > 0).to.eq(true);
|
|
677
|
-
} catch (e) {
|
|
678
|
-
//not supported we still need to get an error here
|
|
679
|
-
expect(e.message.indexOf("not supported") != -1).to.be.true;
|
|
680
|
-
}
|
|
681
|
-
})
|
|
682
|
-
|
|
683
|
-
|
|
684
561
|
it('it must have a working wait for dom with mut observer and must detect condition after change', async function () {
|
|
685
562
|
let probe = DomQuery.byId('id_1');
|
|
686
563
|
probe.innerHTML = 'true';
|
|
@@ -752,14 +629,11 @@ describe('DOMQuery tests', function () {
|
|
|
752
629
|
|
|
753
630
|
it('must by recycleable', function () {
|
|
754
631
|
let probe = DomQuery.querySelectorAll("div");
|
|
755
|
-
let probe2 = DomQuery.querySelectorAll("body");
|
|
756
632
|
|
|
757
633
|
let res1 = probe.filter(item => item.matchesSelector("div"));
|
|
758
634
|
expect(res1.length).to.eq(4);
|
|
759
635
|
let res2 = probe.filter(item => item.matchesSelector("div"));
|
|
760
636
|
expect(res2.length).to.eq(4);
|
|
761
|
-
|
|
762
|
-
|
|
763
637
|
})
|
|
764
638
|
|
|
765
639
|
it('delete must work', function () {
|
|
@@ -777,22 +651,9 @@ describe('DOMQuery tests', function () {
|
|
|
777
651
|
let probe2 = DomQuery.querySelectorAll("div");
|
|
778
652
|
let probeCnt = 0;
|
|
779
653
|
let probe2Cnt = 0;
|
|
780
|
-
from(probe).subscribe(
|
|
781
|
-
from(
|
|
654
|
+
from(probe).subscribe(() => probeCnt++);
|
|
655
|
+
from(probe2.stream).subscribe(() => probe2Cnt++);
|
|
782
656
|
expect(probeCnt).to.be.above(0);
|
|
783
657
|
expect(probeCnt).to.eq(probe2Cnt);
|
|
784
|
-
})
|
|
785
|
-
|
|
786
|
-
it('must handle closest properly', function() {
|
|
787
|
-
let probe = DomQuery.byId("id_1");
|
|
788
|
-
probe.innerHTML = "<div id='inner_elem'>hello world<div id='inner_elem2'></div></div>";
|
|
789
|
-
|
|
790
|
-
let probe2 = DomQuery.byId("inner_elem");
|
|
791
|
-
expect(probe2.closest("div#id_1").id.value).to.eq("id_1");
|
|
792
|
-
expect(probe2.parent().closest("div").id.value).to.eq("id_1");
|
|
793
|
-
probe2 = DomQuery.byId("inner_elem2");
|
|
794
|
-
expect(probe2.closest("div").id.value).to.eq("inner_elem2");
|
|
795
|
-
expect(probe2.closest("div#id_1").id.value).to.eq("id_1");
|
|
796
|
-
expect(probe2.parent().parent().closest("div").id.value).to.eq("id_1");
|
|
797
|
-
});
|
|
658
|
+
})
|
|
798
659
|
});
|
|
@@ -125,7 +125,7 @@ describe('Config tests', () => {
|
|
|
125
125
|
});
|
|
126
126
|
|
|
127
127
|
it('array config2', () => {
|
|
128
|
-
let config =
|
|
128
|
+
let config = setup();
|
|
129
129
|
config.assign("[5]", "world[3]", "from").value = "me";
|
|
130
130
|
expect(config.getIf("[5]", "world[3]", "from").value).to.be.eq("me");
|
|
131
131
|
expect(config.value[5].world[3].from).to.be.eq("me");
|
|
@@ -133,7 +133,7 @@ describe('Config tests', () => {
|
|
|
133
133
|
});
|
|
134
134
|
|
|
135
135
|
it('array config3', () => {
|
|
136
|
-
let config =
|
|
136
|
+
let config = setup();
|
|
137
137
|
config.assign("[5]", "[3]", "from").value = "me";
|
|
138
138
|
expect(config.getIf("[5]", "[3]", "from").value).to.be.eq("me");
|
|
139
139
|
expect(config.value[5][3].from).to.be.eq("me");
|
|
@@ -141,7 +141,7 @@ describe('Config tests', () => {
|
|
|
141
141
|
});
|
|
142
142
|
|
|
143
143
|
it('array config4', () => {
|
|
144
|
-
let config =
|
|
144
|
+
let config = setup();
|
|
145
145
|
config.assign("[5]", "[3]", "[2]").value = "me";
|
|
146
146
|
expect(config.getIf("[5]", "[3]", "[2]").value).to.be.eq("me");
|
|
147
147
|
expect(config.value[5][3][2]).to.be.eq("me");
|
|
@@ -149,7 +149,7 @@ describe('Config tests', () => {
|
|
|
149
149
|
});
|
|
150
150
|
|
|
151
151
|
it('array config5', () => {
|
|
152
|
-
let config =
|
|
152
|
+
let config = setup();
|
|
153
153
|
config.assign("[5]", "world[3]", "from[2]").value = "me";
|
|
154
154
|
expect(config.getIf("[5]", "world[3]", "from[2]").value).to.be.eq("me");
|
|
155
155
|
expect(config.value[5].world[3].from[2]).to.be.eq("me");
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/*! Licensed to the Apache Software Foundation (ASF) under one or more
|
|
2
|
+
* contributor license agreements. See the NOTICE file distributed with
|
|
3
|
+
* this work for additional information regarding copyright ownership.
|
|
4
|
+
* The ASF licenses this file to you under the Apache License, Version 2.0
|
|
5
|
+
* (the "License"); you may not use this file except in compliance with
|
|
6
|
+
* the License. You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import {describe} from "mocha";
|
|
18
|
+
import {expect} from "chai";
|
|
19
|
+
import {ArrayCollector, LazyStream, Stream} from "mona-dish";
|
|
20
|
+
|
|
21
|
+
describe('early stream tests', () => {
|
|
22
|
+
|
|
23
|
+
beforeEach(function () {
|
|
24
|
+
this.probe = [1, 2, 3, 4, 5];
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("must iterate normal", function () {
|
|
28
|
+
let stream = Stream.of<number>(...this.probe);
|
|
29
|
+
let sum = 0;
|
|
30
|
+
stream.each((data) => {
|
|
31
|
+
sum = sum + data;
|
|
32
|
+
});
|
|
33
|
+
expect(sum).to.eq(15);
|
|
34
|
+
|
|
35
|
+
let stream2 = LazyStream.of<number>(...this.probe);
|
|
36
|
+
sum = 0;
|
|
37
|
+
stream2.each((data: number) => {
|
|
38
|
+
sum = sum + data;
|
|
39
|
+
});
|
|
40
|
+
expect(sum).to.eq(15);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("must iterate filtered", function () {
|
|
44
|
+
let stream = Stream.of<number>(...this.probe);
|
|
45
|
+
let sum = 0;
|
|
46
|
+
stream.filter((data) => data != 5).each((data) => {
|
|
47
|
+
sum = sum + data;
|
|
48
|
+
});
|
|
49
|
+
expect(sum).to.eq(10);
|
|
50
|
+
|
|
51
|
+
let stream2 = LazyStream.of<number>(...this.probe);
|
|
52
|
+
sum = 0;
|
|
53
|
+
stream2.filter((data) => data != 5).each((data: number) => {
|
|
54
|
+
sum = sum + data;
|
|
55
|
+
});
|
|
56
|
+
expect(sum).to.eq(10);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("must onElem", function () {
|
|
60
|
+
let stream = Stream.of<number>(...this.probe);
|
|
61
|
+
let sum = 0;
|
|
62
|
+
let sum2: number = stream.filter((data) => data != 5).onElem((data) => {
|
|
63
|
+
sum = sum + data;
|
|
64
|
+
}).reduce<number>((el1, el2) => el1 + el2).value;
|
|
65
|
+
expect(sum).to.eq(10);
|
|
66
|
+
expect(sum2).to.eq(10);
|
|
67
|
+
|
|
68
|
+
let stream2 = LazyStream.of<number>(...this.probe);
|
|
69
|
+
sum = 0;
|
|
70
|
+
sum2 = stream2.filter((data) => data != 5).onElem((data: number) => {
|
|
71
|
+
sum = sum + data;
|
|
72
|
+
}).reduce((el1: number, el2: number) => el1 + el2).value;
|
|
73
|
+
expect(sum).to.eq(10);
|
|
74
|
+
expect(sum2).to.eq(10);
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it("must have a correct first last", function () {
|
|
78
|
+
let first = Stream.of<number>(...this.probe).filter((data) => data != 5).onElem(() => {
|
|
79
|
+
}).first().value;
|
|
80
|
+
let last = Stream.of<number>(...this.probe).filter((data) => data != 5).onElem(() => {
|
|
81
|
+
}).last().value;
|
|
82
|
+
expect(first).to.eq(1);
|
|
83
|
+
expect(last).to.eq(4);
|
|
84
|
+
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("must have a correct first last lazy", function () {
|
|
88
|
+
let first = LazyStream.of<number>(...this.probe).filter((data) => data != 5).onElem((data) => {
|
|
89
|
+
data;
|
|
90
|
+
}).first().value;
|
|
91
|
+
let last = Stream.of<number>(...this.probe).filter((data) => data != 5).onElem((data) => {
|
|
92
|
+
data;
|
|
93
|
+
}).last().value;
|
|
94
|
+
expect(first).to.eq(1);
|
|
95
|
+
expect(last).to.eq(4);
|
|
96
|
+
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("must have a correct limits", function () {
|
|
100
|
+
let cnt = 0;
|
|
101
|
+
let last = Stream.of<number>(...this.probe).filter((data) => data != 5).limits(2).onElem(() => {
|
|
102
|
+
cnt++;
|
|
103
|
+
}).last().value;
|
|
104
|
+
|
|
105
|
+
expect(last).to.eq(2);
|
|
106
|
+
expect(cnt).to.eq(2);
|
|
107
|
+
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("must initialize correctly from assoc array", function () {
|
|
111
|
+
let probe = {
|
|
112
|
+
key1: "val1",
|
|
113
|
+
key2: 2,
|
|
114
|
+
key3: "val3"
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
let arr1: Array<string | number> = [];
|
|
118
|
+
let arr2: Array<string | number> = [];
|
|
119
|
+
|
|
120
|
+
Stream.ofAssoc(probe).each(item => {
|
|
121
|
+
expect(item.length).to.eq(2);
|
|
122
|
+
arr1.push(item[0]);
|
|
123
|
+
arr2.push(item[1]);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
expect(arr1.join(",")).to.eq("key1,key2,key3");
|
|
127
|
+
expect(arr2.join(",")).to.eq("val1,2,val3");
|
|
128
|
+
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("must have a correct lazy limits", function () {
|
|
132
|
+
let last = LazyStream.of<number>(...this.probe).filter((data) => data != 5).limits(2).onElem((data) => {
|
|
133
|
+
data;
|
|
134
|
+
}).last().value;
|
|
135
|
+
|
|
136
|
+
expect(last).to.eq(2);
|
|
137
|
+
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
it("must correctly lazily flatmap", function () {
|
|
141
|
+
|
|
142
|
+
let resultingArr = LazyStream.of<number>(...this.probe).flatMap((data) => LazyStream.of(...[data, 2])).value;
|
|
143
|
+
|
|
144
|
+
expect(resultingArr.length == 10).to.be.true;
|
|
145
|
+
expect(resultingArr.join(",")).to.eq("1,2,2,2,3,2,4,2,5,2");
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("must correctly lazily flatmap with arrays", function () {
|
|
149
|
+
|
|
150
|
+
let resultingArr = LazyStream.of<number>(...this.probe).flatMap((data) => [data, 2]).value;
|
|
151
|
+
|
|
152
|
+
expect(resultingArr.length == 10).to.be.true;
|
|
153
|
+
expect(resultingArr.join(",")).to.eq("1,2,2,2,3,2,4,2,5,2");
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it("must correctly early flatmap", function () {
|
|
157
|
+
|
|
158
|
+
let resultingArr = Stream.of<number>(...this.probe).flatMap((data) => Stream.of(...[data, 2])).value;
|
|
159
|
+
|
|
160
|
+
expect(resultingArr.length == 10).to.be.true;
|
|
161
|
+
expect(resultingArr.join(",")).to.eq("1,2,2,2,3,2,4,2,5,2");
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("must correctly early flatmap with arrays", function () {
|
|
165
|
+
|
|
166
|
+
let resultingArr = Stream.of<number>(...this.probe).flatMap((data) => [data, 2]).value;
|
|
167
|
+
|
|
168
|
+
expect(resultingArr.length == 10).to.be.true;
|
|
169
|
+
expect(resultingArr.join(",")).to.eq("1,2,2,2,3,2,4,2,5,2");
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("must correctly flatmap intermixed", function () {
|
|
173
|
+
|
|
174
|
+
let resultingArr = LazyStream.of<number>(...this.probe).flatMap((data) => Stream.of(...[data, 2])).value;
|
|
175
|
+
|
|
176
|
+
expect(resultingArr.length == 10).to.be.true;
|
|
177
|
+
expect(resultingArr.join(",")).to.eq("1,2,2,2,3,2,4,2,5,2");
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("must correctly flatmap intermixed2", function () {
|
|
181
|
+
|
|
182
|
+
let resultingArr = Stream.of<number>(...this.probe).flatMap((data) => LazyStream.of(...[data, 2])).value;
|
|
183
|
+
|
|
184
|
+
expect(resultingArr.length == 10).to.be.true;
|
|
185
|
+
expect(resultingArr.join(",")).to.eq("1,2,2,2,3,2,4,2,5,2");
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it("must correctly pass anyMatch allMatch noneMatch", function () {
|
|
189
|
+
let anyMatch = LazyStream.of<number>(...this.probe).anyMatch((item) => item == 3);
|
|
190
|
+
let allMatch = LazyStream.of<number>(...this.probe).allMatch((item) => item < 6);
|
|
191
|
+
let noneMatch = LazyStream.of<number>(...this.probe).noneMatch((item) => item > 5);
|
|
192
|
+
|
|
193
|
+
expect(anyMatch).to.be.true;
|
|
194
|
+
expect(allMatch).to.be.true;
|
|
195
|
+
expect(noneMatch).to.be.true;
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
it("must correctly pass anyMatch allMatch noneMatch early", function () {
|
|
199
|
+
let anyMatch = Stream.of<number>(...this.probe).anyMatch((item) => item == 3);
|
|
200
|
+
let allMatch = Stream.of<number>(...this.probe).allMatch((item) => item < 6);
|
|
201
|
+
let noneMatch = Stream.of<number>(...this.probe).noneMatch((item) => item > 5);
|
|
202
|
+
|
|
203
|
+
expect(anyMatch).to.be.true;
|
|
204
|
+
expect(allMatch).to.be.true;
|
|
205
|
+
expect(noneMatch).to.be.true;
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
it("must sort correctly", function () {
|
|
209
|
+
|
|
210
|
+
let probe: Array<number> = [1, 5, 3, 2, 4];
|
|
211
|
+
|
|
212
|
+
let res = Stream.of<number>(...probe)
|
|
213
|
+
.sort((el1: number, el2: number) => el1 - el2)
|
|
214
|
+
.collect(new ArrayCollector());
|
|
215
|
+
|
|
216
|
+
expect(res.join(",")).to.eq("1,2,3,4,5");
|
|
217
|
+
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
it("must sort correctly lazy", function () {
|
|
221
|
+
|
|
222
|
+
let probe: Array<number> = [1, 5, 3, 2, 4];
|
|
223
|
+
|
|
224
|
+
let res = LazyStream.of<number>(...probe)
|
|
225
|
+
.sort((el1: number, el2: number) => el1 - el2)
|
|
226
|
+
.collect(new ArrayCollector());
|
|
227
|
+
|
|
228
|
+
expect(res.join(",")).to.eq("1,2,3,4,5");
|
|
229
|
+
|
|
230
|
+
})
|
|
231
|
+
});
|