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