jsf.js_next_gen 4.0.0-beta-23 → 4.0.1-alpha.0
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/.nyc_output/09ca9ebc-2305-4357-8db9-48ddfc7dfde2.json +1 -0
- package/.nyc_output/7c496a14-166e-4aa5-85b9-47b22b055ad8.json +1 -0
- package/.nyc_output/processinfo/09ca9ebc-2305-4357-8db9-48ddfc7dfde2.json +1 -0
- package/.nyc_output/processinfo/7c496a14-166e-4aa5-85b9-47b22b055ad8.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/README.md +13 -21
- package/dist/docs/assets/main.js +56 -52
- package/dist/docs/assets/search.js +1 -1
- package/dist/docs/assets/style.css +23 -0
- package/dist/docs/functions/faces.ajax.addOnError.html +2 -0
- package/dist/docs/functions/faces.ajax.addOnEvent.html +2 -0
- package/dist/docs/functions/faces.push.close.html +4 -2
- package/dist/docs/functions/faces.push.init.html +19 -7
- package/dist/docs/functions/faces.push.open.html +4 -2
- package/dist/docs/functions/myfaces.ab.html +9 -4
- package/dist/docs/functions/myfaces.onDomReady.html +72 -0
- package/dist/docs/index.html +16 -18
- package/dist/docs/modules/myfaces.html +3 -1
- package/dist/docs/variables/myfaces.oam.html +2 -1
- package/dist/window/faces-development.js +2846 -2085
- 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.LICENSE.txt +17 -2
- 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 +2856 -2084
- 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.LICENSE.txt +17 -2
- 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 +19 -18
- package/plans for 4.0.1.txt +8 -0
- package/src/main/test.xml +23 -0
- package/src/main/typescript/@types/definitions/index.d.ts +19 -2
- package/src/main/typescript/api/_api.ts +68 -25
- package/src/main/typescript/api/jsf.ts +18 -0
- package/src/main/typescript/impl/AjaxImpl.ts +204 -100
- package/src/main/typescript/impl/PushImpl.ts +63 -38
- package/src/main/typescript/impl/core/Const.ts +56 -40
- package/src/main/typescript/impl/util/Assertions.ts +16 -8
- package/src/main/typescript/impl/util/AsyncRunnable.ts +85 -10
- package/src/main/typescript/impl/util/ExtDomQuery.ts +65 -54
- package/src/main/typescript/impl/util/FileUtils.ts +108 -0
- package/src/main/typescript/impl/util/HiddenInputBuilder.ts +93 -0
- package/src/main/typescript/impl/util/Lang.ts +91 -35
- package/src/main/typescript/impl/util/XhrQueueController.ts +112 -0
- package/src/main/typescript/impl/xhrCore/ErrorData.ts +15 -10
- package/src/main/typescript/impl/xhrCore/EventData.ts +3 -3
- package/src/main/typescript/impl/xhrCore/IResponseProcessor.ts +25 -11
- package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +78 -32
- package/src/main/typescript/impl/xhrCore/ResonseDataResolver.ts +10 -10
- package/src/main/typescript/impl/xhrCore/Response.ts +66 -49
- package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +211 -138
- package/src/main/typescript/impl/xhrCore/XhrFormData.ts +92 -166
- package/src/main/typescript/impl/xhrCore/XhrRequest.ts +111 -120
- package/src/main/typescript/myfaces/OamSubmit.ts +30 -14
- package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +163 -27
- package/src/main/typescript/test/frameworkBase/_ext/monadish/MonadTest.spec.ts +4 -4
- 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 +921 -0
- package/src/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-without-header.ts +108 -0
- package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +111 -3
- package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +40 -1
- package/src/main/typescript/test/frameworkBase/_ext/shared/fixtures/jakarta.faces.resource/faces.js.jsf +0 -0
- package/src/main/typescript/test/impl/ImplTest.spec.ts +3 -3
- package/src/main/typescript/test/impl/ImplTest_23.spec.ts +3 -7
- package/src/main/typescript/test/myfaces/OnLoadSpec.ts +52 -0
- package/src/main/typescript/test/queue/AsynchronousProbe.ts +5 -5
- package/src/main/typescript/test/queue/AsynchronousQueueTest.spec.ts +4 -3
- package/src/main/typescript/test/xhrCore/EventTests.spec.ts +28 -22
- package/src/main/typescript/test/xhrCore/FileUploadTest.spec.ts +5 -2
- package/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.ts +203 -0
- package/src/main/typescript/test/xhrCore/OamSubmitTest.spec.ts +177 -0
- package/src/main/typescript/test/xhrCore/RequestParamsTest.spec.ts +158 -17
- package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +320 -15
- package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +45 -4
- package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +374 -35
- package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +43 -9
- package/src/main/typescript/test/xhrCore/TobagoFileUploadTest.spec.ts +109 -0
- package/src/main/typescript/test/xhrCore/XhrFormDataTest.spec.ts +67 -49
- package/src/main/typescript/test.xml +6 -0
- package/src/main/typescript/tsconfig.json +1 -1
- package/src/test/resources/jsf-development.js +1 -1
- package/src/tmp/test.html +12 -88
- package/target/api/_api.js +63 -21
- package/target/api/_api.js.map +1 -1
- package/target/api/jsf.js +11 -0
- package/target/api/jsf.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/impl/AjaxImpl.js +177 -81
- package/target/impl/AjaxImpl.js.map +1 -1
- package/target/impl/PushImpl.js +66 -35
- package/target/impl/PushImpl.js.map +1 -1
- package/target/impl/core/Const.js +54 -39
- package/target/impl/core/Const.js.map +1 -1
- package/target/impl/core/Context.js +10 -0
- package/target/impl/core/Context.js.map +1 -0
- package/target/impl/util/Assertions.js +12 -7
- package/target/impl/util/Assertions.js.map +1 -1
- package/target/impl/util/AsyncQueue.js.map +1 -1
- package/target/impl/util/AsyncRunnable.js +60 -0
- package/target/impl/util/AsyncRunnable.js.map +1 -1
- package/target/impl/util/ExtDomQuery.js +66 -48
- package/target/impl/util/ExtDomQuery.js.map +1 -1
- package/target/impl/util/FileUtils.js +97 -0
- package/target/impl/util/FileUtils.js.map +1 -0
- package/target/impl/util/HiddenElementBuilder.js +7 -0
- package/target/impl/util/HiddenElementBuilder.js.map +1 -0
- package/target/impl/util/HiddenInputBuilder.js +83 -0
- package/target/impl/util/HiddenInputBuilder.js.map +1 -0
- package/target/{types/index.js → impl/util/IAsyncRunnable.js} +11 -2
- package/target/impl/util/IAsyncRunnable.js.map +1 -0
- package/target/impl/util/Lang.js +81 -31
- package/target/impl/util/Lang.js.map +1 -1
- package/target/impl/util/URLCodec.js +77 -0
- package/target/impl/util/URLCodec.js.map +1 -0
- package/target/impl/util/XhrQueueController.js +107 -0
- package/target/impl/util/XhrQueueController.js.map +1 -0
- package/target/impl/xhrCore/ErrorData.js +10 -8
- package/target/impl/xhrCore/ErrorData.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/RequestContext.js +11 -0
- package/target/impl/xhrCore/RequestContext.js.map +1 -0
- package/target/impl/xhrCore/RequestDataResolver.js +70 -23
- package/target/impl/xhrCore/RequestDataResolver.js.map +1 -1
- package/target/impl/xhrCore/ResonseDataResolver.js +9 -9
- package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
- package/target/impl/xhrCore/Response.js +44 -29
- package/target/impl/xhrCore/Response.js.map +1 -1
- package/target/impl/xhrCore/ResponseProcessor.js +187 -119
- package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
- package/target/impl/xhrCore/XhrFormData.js +82 -156
- package/target/impl/xhrCore/XhrFormData.js.map +1 -1
- package/target/impl/xhrCore/XhrQueHandler.js +11 -0
- package/target/impl/xhrCore/XhrQueHandler.js.map +1 -0
- package/target/impl/xhrCore/XhrQueueController.js +62 -0
- package/target/impl/xhrCore/XhrQueueController.js.map +1 -0
- package/target/impl/xhrCore/XhrRequest.js +94 -106
- package/target/impl/xhrCore/XhrRequest.js.map +1 -1
- package/target/myfaces/OamSubmit.js +25 -14
- package/target/myfaces/OamSubmit.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +124 -23
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/ExtendedArrayTest.spec.js +76 -0
- package/target/test/frameworkBase/_ext/monadish/ExtendedArrayTest.spec.js.map +1 -0
- 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/monadish/markups/tobago-with-header.js +925 -0
- package/target/test/frameworkBase/_ext/monadish/markups/tobago-with-header.js.map +1 -0
- package/target/test/frameworkBase/_ext/monadish/markups/tobago-without-header.js +112 -0
- package/target/test/frameworkBase/_ext/monadish/markups/tobago-without-header.js.map +1 -0
- package/target/test/frameworkBase/_ext/shared/StandardInits.js +103 -3
- package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js +37 -1
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
- package/target/test/impl/ImplTest.spec.js +2 -2
- package/target/test/impl/ImplTest.spec.js.map +1 -1
- package/target/test/impl/ImplTest_23.spec.js +2 -2
- package/target/test/impl/ImplTest_23.spec.js.map +1 -1
- package/target/test/myfaces/OnLoadSpec.js +57 -0
- package/target/test/myfaces/OnLoadSpec.js.map +1 -0
- package/target/test/queue/AsynchronousQueueTest.spec.js +3 -3
- package/target/test/queue/AsynchronousQueueTest.spec.js.map +1 -1
- package/target/test/xhrCore/EventTests.spec.js +26 -19
- package/target/test/xhrCore/EventTests.spec.js.map +1 -1
- package/target/test/xhrCore/FileUploadTest.spec.js +2 -1
- package/target/test/xhrCore/FileUploadTest.spec.js.map +1 -1
- package/target/test/xhrCore/NamespacesRequestTest.spec.js +204 -0
- package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -0
- package/target/test/xhrCore/OamSubmitTest.spec.js +180 -0
- package/target/test/xhrCore/OamSubmitTest.spec.js.map +1 -0
- package/target/test/xhrCore/RequestParamsTest.spec.js +142 -10
- package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest.spec.js +288 -11
- package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest_23.spec.js +40 -2
- package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest.spec.js +315 -24
- package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest23.spec.js +38 -8
- package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
- package/target/test/xhrCore/TobagoFileUploadTest.spec.js +128 -0
- package/target/test/xhrCore/TobagoFileUploadTest.spec.js.map +1 -0
- package/target/test/xhrCore/XhrFormDataTest.spec.js +57 -34
- package/target/test/xhrCore/XhrFormDataTest.spec.js.map +1 -1
- 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 +24 -0
- package/target/test-classes/jsf-development.js +3559 -0
- 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 +1 -0
- package/target/test-classes/jsf.js +3 -0
- package/target/test-classes/jsf.js.br +0 -0
- package/target/test-classes/jsf.js.gz +0 -0
- package/tmp.xml +36 -0
- package/.nyc_output/2303b649-59d9-485c-9228-73b0ec8787a7.json +0 -1
- package/.nyc_output/756f2f03-c85b-4cdb-9b92-5799eb45ef1e.json +0 -1
- package/.nyc_output/processinfo/2303b649-59d9-485c-9228-73b0ec8787a7.json +0 -1
- package/.nyc_output/processinfo/756f2f03-c85b-4cdb-9b92-5799eb45ef1e.json +0 -1
- package/src/main/typescript/impl/util/AsyncQueue.ts +0 -133
- package/src/main/typescript/test/frameworkBase/_ext/monadish/StreamTest.spec.ts +0 -231
- package/target/types/index.js.map +0 -1
|
@@ -16,14 +16,15 @@
|
|
|
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;
|
|
21
|
-
import {ExtDomquery} from "../../../../impl/util/ExtDomQuery";
|
|
22
19
|
import {from} from "rxjs";
|
|
23
|
-
|
|
20
|
+
import {ArrayCollector, Config, DomQuery, DomQueryCollector, Lang, LazyStream, Stream} from "mona-dish";
|
|
21
|
+
import {tobagoSheetWithHeader} from "./markups/tobago-with-header";
|
|
22
|
+
import {tobagoSheetWithoutHeader} from "./markups/tobago-without-header";
|
|
24
23
|
|
|
25
24
|
const jsdom = require("jsdom");
|
|
26
25
|
const {JSDOM} = jsdom;
|
|
26
|
+
import trim = Lang.trim;
|
|
27
|
+
|
|
27
28
|
(global as any).window = {}
|
|
28
29
|
let dom = null;
|
|
29
30
|
describe('DOMQuery tests', function () {
|
|
@@ -86,8 +87,8 @@ describe('DOMQuery tests', function () {
|
|
|
86
87
|
let probe1 = new DomQuery(window.document.body);
|
|
87
88
|
let probe2 = DomQuery.querySelectorAll("div");
|
|
88
89
|
|
|
89
|
-
let o1 = from(probe1
|
|
90
|
-
let o2 = from(probe2
|
|
90
|
+
let o1 = from(Stream.ofDataSource(probe1));
|
|
91
|
+
let o2 = from(Stream.ofDataSource(probe2));
|
|
91
92
|
|
|
92
93
|
let cnt1 = 0;
|
|
93
94
|
let isDQuery = false;
|
|
@@ -112,8 +113,8 @@ describe('DOMQuery tests', function () {
|
|
|
112
113
|
let probe1 = new DomQuery(window.document.body);
|
|
113
114
|
let probe2 = DomQuery.querySelectorAll("div");
|
|
114
115
|
|
|
115
|
-
let o1 = from(probe1
|
|
116
|
-
let o2 = from(probe2
|
|
116
|
+
let o1 = from(Stream.ofDataSource(probe1));
|
|
117
|
+
let o2 = from(Stream.ofDataSource(probe2));
|
|
117
118
|
|
|
118
119
|
let cnt1 = 0;
|
|
119
120
|
let isDQuery = false;
|
|
@@ -298,28 +299,61 @@ describe('DOMQuery tests', function () {
|
|
|
298
299
|
expect(DomQuery.querySelectorAll("#insertedAfter2").isPresent()).to.be.true;
|
|
299
300
|
});
|
|
300
301
|
|
|
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
|
+
|
|
301
329
|
it('it must stream', function () {
|
|
302
330
|
let probe1 = new DomQuery(document).querySelectorAll("div");
|
|
303
|
-
let coll: Array<any> = probe1.
|
|
331
|
+
let coll: Array<any> = Stream.ofDomQuery(probe1).collect(new ArrayCollector());
|
|
304
332
|
expect(coll.length == 4).to.be.true;
|
|
305
333
|
|
|
306
|
-
coll = probe1.
|
|
334
|
+
coll = LazyStream.ofDomQuery(probe1).collect(new ArrayCollector());
|
|
307
335
|
expect(coll.length == 4).to.be.true;
|
|
308
336
|
|
|
309
337
|
});
|
|
310
338
|
|
|
311
|
-
it('it must stream
|
|
339
|
+
it('it must stream - DQ API (dynamically added)', function () {
|
|
312
340
|
let probe1 = new DomQuery(document).querySelectorAll("div");
|
|
313
|
-
let coll:
|
|
341
|
+
let coll: Array<any> = probe1.asArray;
|
|
314
342
|
expect(coll.length == 4).to.be.true;
|
|
343
|
+
});
|
|
315
344
|
|
|
316
|
-
|
|
345
|
+
it('it must stream to a domquery', function () {
|
|
346
|
+
let probe1 = new DomQuery(document).querySelectorAll("div");
|
|
347
|
+
let coll: DomQuery = Stream.ofDataSource(probe1).collect(new DomQueryCollector());
|
|
348
|
+
expect(coll.length == 4).to.be.true;
|
|
349
|
+
probe1.reset();
|
|
350
|
+
coll = LazyStream.ofStreamDataSource(probe1).collect(new DomQueryCollector());
|
|
317
351
|
expect(coll.length == 4).to.be.true;
|
|
318
352
|
});
|
|
319
353
|
|
|
320
354
|
it('it must have parents', function () {
|
|
321
355
|
let probe1 = new DomQuery(document).querySelectorAll("div");
|
|
322
|
-
let coll: Array<any> = probe1.
|
|
356
|
+
let coll: Array<any> = Stream.ofDataSource(probe1.parentsWhileMatch("body")).collect(new ArrayCollector());
|
|
323
357
|
expect(coll.length == 1).to.be.true;
|
|
324
358
|
|
|
325
359
|
});
|
|
@@ -342,6 +376,74 @@ describe('DOMQuery tests', function () {
|
|
|
342
376
|
expect(innerHtml.indexOf("id_x_1_1") > innerHtml.indexOf("id_x_0_1")).to.be.true;
|
|
343
377
|
})
|
|
344
378
|
|
|
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
|
+
|
|
345
447
|
it("must have a working input handling", function () {
|
|
346
448
|
DomQuery.querySelectorAll("body").innerHTML = `<form id="blarg">
|
|
347
449
|
<div id="embed1">
|
|
@@ -375,22 +477,22 @@ describe('DOMQuery tests', function () {
|
|
|
375
477
|
let length2 = DomQuery.byId("embed1").elements.length;
|
|
376
478
|
expect(length2 == 8).to.be.true;
|
|
377
479
|
|
|
378
|
-
let count = DomQuery.byId("embed1").elements
|
|
379
|
-
.
|
|
480
|
+
let count = Stream.ofDataSource(DomQuery.byId("embed1").elements)
|
|
481
|
+
.map<number>(item => item.disabled ? 1 : 0)
|
|
380
482
|
.reduce((val1, val2) => val1 + val2, 0);
|
|
381
483
|
expect(count.value).to.eq(1);
|
|
382
484
|
|
|
383
|
-
DomQuery.byId("embed1").elements
|
|
384
|
-
.
|
|
485
|
+
Stream.ofDataSource(DomQuery.byId("embed1").elements)
|
|
486
|
+
.filter(item => item.disabled)
|
|
385
487
|
.each(item => item.disabled = false);
|
|
386
488
|
|
|
387
|
-
count = DomQuery.byId("embed1").elements
|
|
388
|
-
.
|
|
489
|
+
count = Stream.ofDataSource(DomQuery.byId("embed1").elements)
|
|
490
|
+
.map<number>(item => item.disabled ? 1 : 0)
|
|
389
491
|
.reduce((val1, val2) => val1 + val2, 0);
|
|
390
492
|
expect(count.value).to.eq(0);
|
|
391
493
|
|
|
392
|
-
count = DomQuery.byId("embed1").elements
|
|
393
|
-
.
|
|
494
|
+
count = Stream.ofDataSource(DomQuery.byId("embed1").elements)
|
|
495
|
+
.map<number>(item => item.attr("checked").isPresent() ? 1 : 0)
|
|
394
496
|
.reduce((val1, val2) => val1 + val2, 0);
|
|
395
497
|
expect(count.value).to.eq(1);
|
|
396
498
|
|
|
@@ -403,7 +505,7 @@ describe('DOMQuery tests', function () {
|
|
|
403
505
|
DomQuery.byId("id_3").inputValue.value = "hello world";
|
|
404
506
|
expect(DomQuery.byId("id_3").inputValue.value).to.eq("hello world");
|
|
405
507
|
|
|
406
|
-
let cfg = DomQuery.querySelectorAll("form").elements.encodeFormElement();
|
|
508
|
+
let cfg = new Config(DomQuery.querySelectorAll("form").elements.encodeFormElement());
|
|
407
509
|
expect(cfg.getIf("id_1").value[0]).to.eq("booga");
|
|
408
510
|
expect(cfg.getIf("id_2").value[0]).to.eq("id_2_val");
|
|
409
511
|
expect(cfg.getIf("id_3").value[0]).to.eq("hello world");
|
|
@@ -456,12 +558,17 @@ describe('DOMQuery tests', function () {
|
|
|
456
558
|
border: 1px solid black;
|
|
457
559
|
}
|
|
458
560
|
</style>
|
|
561
|
+
|
|
562
|
+
<link rel="stylesheet" href="./fixtures/blank.css"></link>
|
|
459
563
|
`;
|
|
460
564
|
let content = DomQuery.byTagName("body").runScripts().runCss();
|
|
461
565
|
expect(content.byId("first").innerHTML).to.eq("hello world");
|
|
462
566
|
expect(content.byId("second").innerHTML).to.eq("hello world");
|
|
463
567
|
expect(content.byId("third").innerHTML).to.eq("hello world");
|
|
464
568
|
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);
|
|
465
572
|
done();
|
|
466
573
|
|
|
467
574
|
});
|
|
@@ -498,7 +605,7 @@ describe('DOMQuery tests', function () {
|
|
|
498
605
|
|
|
499
606
|
});
|
|
500
607
|
|
|
501
|
-
it("it must handle innerText properly", function () {
|
|
608
|
+
it("it must handle innerText properly", function (done) {
|
|
502
609
|
|
|
503
610
|
//jsdom bug
|
|
504
611
|
Object.defineProperty(Object.prototype, 'innerText', {
|
|
@@ -510,6 +617,7 @@ describe('DOMQuery tests', function () {
|
|
|
510
617
|
let probe = DomQuery.byId("id_1");
|
|
511
618
|
probe.innerHTML = "<div>hello</div><div>world</div>";
|
|
512
619
|
expect(probe.innerText()).to.eq("helloworld");
|
|
620
|
+
done();
|
|
513
621
|
});
|
|
514
622
|
it("it must handle textContent properly", function () {
|
|
515
623
|
let probe = DomQuery.byId("id_1");
|
|
@@ -519,7 +627,7 @@ describe('DOMQuery tests', function () {
|
|
|
519
627
|
|
|
520
628
|
it("it must handle iterations properly", function () {
|
|
521
629
|
let probe = DomQuery.byTagName("div");
|
|
522
|
-
let resArr = probe.
|
|
630
|
+
let resArr = LazyStream.ofStreamDataSource(probe).collect(new ArrayCollector());
|
|
523
631
|
expect(resArr.length).to.eq(4);
|
|
524
632
|
|
|
525
633
|
probe.reset();
|
|
@@ -558,6 +666,21 @@ describe('DOMQuery tests', function () {
|
|
|
558
666
|
})
|
|
559
667
|
|
|
560
668
|
|
|
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
|
+
|
|
561
684
|
it('it must have a working wait for dom with mut observer and must detect condition after change', async function () {
|
|
562
685
|
let probe = DomQuery.byId('id_1');
|
|
563
686
|
probe.innerHTML = 'true';
|
|
@@ -655,8 +778,21 @@ describe('DOMQuery tests', function () {
|
|
|
655
778
|
let probeCnt = 0;
|
|
656
779
|
let probe2Cnt = 0;
|
|
657
780
|
from(probe).subscribe(el => probeCnt++);
|
|
658
|
-
from(probe2
|
|
781
|
+
from(Stream.ofDataSource(probe2)).subscribe(el => probe2Cnt++);
|
|
659
782
|
expect(probeCnt).to.be.above(0);
|
|
660
783
|
expect(probeCnt).to.eq(probe2Cnt);
|
|
661
|
-
})
|
|
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
|
+
});
|
|
662
798
|
});
|
|
@@ -125,7 +125,7 @@ describe('Config tests', () => {
|
|
|
125
125
|
});
|
|
126
126
|
|
|
127
127
|
it('array config2', () => {
|
|
128
|
-
let config =
|
|
128
|
+
let config = new Config([]);
|
|
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 = new Config([]);
|
|
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 = new Config([]);
|
|
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 = new Config([]);
|
|
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");
|
|
File without changes
|