@schukai/monster 1.22.0 → 1.26.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG +56 -0
- package/README.md +4 -4
- package/dist/modules/constants.js +2 -2
- package/dist/modules/constraints/abstract.js +1 -1
- package/dist/modules/constraints/abstractoperator.js +1 -1
- package/dist/modules/constraints/andoperator.js +1 -1
- package/dist/modules/constraints/invalid.js +1 -1
- package/dist/modules/constraints/isarray.js +1 -1
- package/dist/modules/constraints/isobject.js +1 -1
- package/dist/modules/constraints/namespace.js +1 -1
- package/dist/modules/constraints/oroperator.js +1 -1
- package/dist/modules/constraints/valid.js +1 -1
- package/dist/modules/data/buildmap.js +2 -2
- package/dist/modules/data/buildtree.js +2 -0
- package/dist/modules/data/datasource/namespace.js +1 -1
- package/dist/modules/data/datasource/restapi/writeerror.js +2 -0
- package/dist/modules/data/datasource/restapi.js +2 -2
- package/dist/modules/data/datasource/storage/localstorage.js +2 -2
- package/dist/modules/data/datasource/storage/namespace.js +1 -1
- package/dist/modules/data/datasource/storage/sessionstorage.js +2 -2
- package/dist/modules/data/datasource/storage.js +2 -2
- package/dist/modules/data/datasource.js +2 -2
- package/dist/modules/data/diff.js +2 -2
- package/dist/modules/data/extend.js +1 -1
- package/dist/modules/data/namespace.js +1 -1
- package/dist/modules/data/pathfinder.js +2 -2
- package/dist/modules/data/pipe.js +1 -1
- package/dist/modules/data/transformer.js +2 -2
- package/dist/modules/dom/assembler.js +1 -1
- package/dist/modules/dom/attributes.js +1 -1
- package/dist/modules/dom/constants.js +2 -2
- package/dist/modules/dom/customcontrol.js +2 -2
- package/dist/modules/dom/customelement.js +2 -2
- package/dist/modules/dom/events.js +1 -1
- package/dist/modules/dom/focusmanager.js +2 -0
- package/dist/modules/dom/locale.js +1 -1
- package/dist/modules/dom/namespace.js +1 -1
- package/dist/modules/dom/resource/data.js +2 -0
- package/dist/modules/dom/resource/link/stylesheet.js +2 -0
- package/dist/modules/dom/resource/link.js +2 -0
- package/dist/modules/dom/resource/script.js +2 -0
- package/dist/modules/dom/resource.js +2 -0
- package/dist/modules/dom/resourcemanager.js +2 -0
- package/dist/modules/dom/template.js +1 -1
- package/dist/modules/dom/theme.js +1 -1
- package/dist/modules/dom/updater.js +2 -2
- package/dist/modules/dom/util.js +1 -1
- package/dist/modules/dom/worker/factory.js +2 -0
- package/dist/modules/i18n/formatter.js +2 -0
- package/dist/modules/i18n/locale.js +1 -1
- package/dist/modules/i18n/namespace.js +1 -1
- package/dist/modules/i18n/provider.js +1 -1
- package/dist/modules/i18n/providers/fetch.js +2 -2
- package/dist/modules/i18n/providers/namespace.js +1 -1
- package/dist/modules/i18n/translations.js +1 -1
- package/dist/modules/logging/handler/console.js +1 -1
- package/dist/modules/logging/handler/namespace.js +1 -1
- package/dist/modules/logging/handler.js +1 -1
- package/dist/modules/logging/logentry.js +1 -1
- package/dist/modules/logging/logger.js +1 -1
- package/dist/modules/logging/namespace.js +1 -1
- package/dist/modules/math/namespace.js +1 -1
- package/dist/modules/math/random.js +2 -2
- package/dist/modules/monster.js +1 -1
- package/dist/modules/namespace.js +1 -1
- package/dist/modules/text/formatter.js +2 -2
- package/dist/modules/text/namespace.js +1 -1
- package/dist/modules/types/base.js +1 -1
- package/dist/modules/types/basewithoptions.js +2 -2
- package/dist/modules/types/binary.js +1 -1
- package/dist/modules/types/dataurl.js +1 -1
- package/dist/modules/types/global.js +1 -1
- package/dist/modules/types/id.js +1 -1
- package/dist/modules/types/is.js +2 -2
- package/dist/modules/types/mediatype.js +1 -1
- package/dist/modules/types/namespace.js +1 -1
- package/dist/modules/types/node.js +2 -0
- package/dist/modules/types/nodelist.js +2 -0
- package/dist/modules/types/noderecursiveiterator.js +2 -0
- package/dist/modules/types/observer.js +1 -1
- package/dist/modules/types/observerlist.js +2 -2
- package/dist/modules/types/proxyobserver.js +2 -2
- package/dist/modules/types/queue.js +1 -1
- package/dist/modules/types/randomid.js +1 -1
- package/dist/modules/types/regex.js +2 -0
- package/dist/modules/types/stack.js +1 -1
- package/dist/modules/types/tokenlist.js +2 -2
- package/dist/modules/types/typeof.js +1 -1
- package/dist/modules/types/uniquequeue.js +1 -1
- package/dist/modules/types/uuid.js +2 -0
- package/dist/modules/types/validate.js +1 -1
- package/dist/modules/types/version.js +2 -2
- package/dist/modules/util/clone.js +2 -2
- package/dist/modules/util/comparator.js +2 -2
- package/dist/modules/util/freeze.js +1 -1
- package/dist/modules/util/namespace.js +1 -1
- package/dist/modules/util/processing.js +2 -2
- package/dist/modules/util/trimspaces.js +2 -0
- package/dist/monster.dev.js +1838 -792
- package/dist/monster.dev.js.map +1 -1
- package/dist/monster.js +2 -2
- package/package.json +13 -2
- package/source/constants.js +16 -7
- package/source/constraints/abstract.js +5 -0
- package/source/constraints/abstractoperator.js +5 -0
- package/source/constraints/andoperator.js +10 -5
- package/source/constraints/invalid.js +8 -3
- package/source/constraints/isarray.js +9 -4
- package/source/constraints/isobject.js +8 -3
- package/source/constraints/oroperator.js +10 -5
- package/source/constraints/valid.js +8 -3
- package/source/data/buildmap.js +27 -11
- package/source/data/buildtree.js +95 -0
- package/source/data/datasource/restapi/writeerror.js +49 -0
- package/source/data/datasource/restapi.js +95 -11
- package/source/data/datasource/storage/localstorage.js +15 -8
- package/source/data/datasource/storage/sessionstorage.js +16 -12
- package/source/data/datasource/storage.js +16 -7
- package/source/data/datasource.js +60 -16
- package/source/data/diff.js +8 -8
- package/source/data/extend.js +5 -5
- package/source/data/pathfinder.js +12 -6
- package/source/data/pipe.js +6 -5
- package/source/data/transformer.js +131 -24
- package/source/dom/assembler.js +2 -2
- package/source/dom/attributes.js +24 -24
- package/source/dom/constants.js +305 -12
- package/source/dom/customcontrol.js +40 -19
- package/source/dom/customelement.js +182 -102
- package/source/dom/events.js +6 -6
- package/source/dom/focusmanager.js +250 -0
- package/source/dom/locale.js +10 -5
- package/source/dom/resource/data.js +170 -0
- package/source/dom/resource/link/stylesheet.js +54 -0
- package/source/dom/resource/link.js +125 -0
- package/source/dom/resource/script.js +112 -0
- package/source/dom/resource.js +268 -0
- package/source/dom/resourcemanager.js +214 -0
- package/source/dom/template.js +40 -10
- package/source/dom/theme.js +3 -3
- package/source/dom/updater.js +115 -39
- package/source/dom/util.js +6 -6
- package/source/dom/worker/factory.js +134 -0
- package/source/i18n/formatter.js +140 -0
- package/source/i18n/locale.js +10 -8
- package/source/i18n/provider.js +4 -4
- package/source/i18n/providers/fetch.js +24 -14
- package/source/i18n/translations.js +20 -10
- package/source/logging/handler/console.js +2 -2
- package/source/logging/handler.js +2 -2
- package/source/logging/logentry.js +2 -2
- package/source/logging/logger.js +4 -4
- package/source/math/random.js +11 -5
- package/source/namespace.js +1 -1
- package/source/text/formatter.js +244 -27
- package/source/types/base.js +4 -4
- package/source/types/basewithoptions.js +10 -15
- package/source/types/binary.js +8 -8
- package/source/types/dataurl.js +6 -6
- package/source/types/global.js +9 -7
- package/source/types/id.js +6 -3
- package/source/types/is.js +103 -85
- package/source/types/mediatype.js +4 -4
- package/source/types/node.js +179 -0
- package/source/types/nodelist.js +125 -0
- package/source/types/noderecursiveiterator.js +126 -0
- package/source/types/observer.js +3 -3
- package/source/types/observerlist.js +3 -3
- package/source/types/proxyobserver.js +24 -7
- package/source/types/queue.js +6 -6
- package/source/types/randomid.js +2 -2
- package/source/types/regex.js +49 -0
- package/source/types/stack.js +2 -2
- package/source/types/tokenlist.js +8 -9
- package/source/types/typeof.js +3 -3
- package/source/types/uniquequeue.js +4 -4
- package/source/types/uuid.js +102 -0
- package/source/types/validate.js +20 -20
- package/source/types/version.js +6 -6
- package/source/util/clone.js +5 -6
- package/source/util/comparator.js +5 -5
- package/source/util/freeze.js +5 -5
- package/source/util/processing.js +33 -36
- package/source/util/trimspaces.js +85 -0
- package/test/cases/data/buildtree.js +149 -0
- package/test/cases/data/datasource/restapi.js +1 -1
- package/test/cases/data/datasource.js +4 -4
- package/test/cases/data/diff.js +4 -4
- package/test/cases/data/pathfinder.js +18 -9
- package/test/cases/data/pipe.js +26 -2
- package/test/cases/data/transformer.js +41 -10
- package/test/cases/dom/attributes.js +18 -14
- package/test/cases/dom/customcontrol.js +6 -5
- package/test/cases/dom/customelement.js +25 -26
- package/test/cases/dom/focusmanager.js +111 -0
- package/test/cases/dom/locale.js +1 -4
- package/test/cases/dom/resource/data.js +129 -0
- package/test/cases/dom/resource/link/stylesheet.js +101 -0
- package/test/cases/dom/resource/link.js +101 -0
- package/test/cases/dom/resource/script.js +115 -0
- package/test/cases/dom/resourcemanager.js +118 -0
- package/test/cases/dom/updater.js +42 -19
- package/test/cases/dom/worker/factory.js +63 -0
- package/test/cases/i18n/formatter.js +66 -0
- package/test/cases/monster.js +1 -1
- package/test/cases/text/formatter.js +71 -8
- package/test/cases/types/node.js +196 -0
- package/test/cases/types/nodelist.js +64 -0
- package/test/cases/types/noderecursiveiterator.js +54 -0
- package/test/cases/types/proxyobserver.js +55 -11
- package/test/cases/types/regex.js +32 -0
- package/test/cases/types/uuid.js +42 -0
- package/test/cases/util/freeze.js +30 -4
- package/test/cases/util/trimspaces.js +24 -0
- package/test/util/cleanupdom.js +48 -0
- package/test/util/jsdom.js +22 -9
- package/test/web/import.js +15 -0
- package/test/web/monster-dev.html +3 -3
- package/test/web/monster.html +2 -2
- package/test/web/test.html +3 -3
- package/test/web/tests.js +7 -7
@@ -0,0 +1,64 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
import {expect} from "chai"
|
4
|
+
import {Node} from "../../../source/types/node.js";
|
5
|
+
import {NodeList} from "../../../source/types/nodelist.js";
|
6
|
+
|
7
|
+
describe('NodeList', function () {
|
8
|
+
describe('#constructor', function () {
|
9
|
+
it('should create an empty NodeList', function () {
|
10
|
+
let nodeList = new NodeList();
|
11
|
+
|
12
|
+
expect(nodeList.size).to.equal(0);
|
13
|
+
});
|
14
|
+
|
15
|
+
it('should create a NodeList from an array', function () {
|
16
|
+
let nodeList = new NodeList([
|
17
|
+
new Node('div'),
|
18
|
+
new Node('div'),
|
19
|
+
new Node('div')
|
20
|
+
]);
|
21
|
+
|
22
|
+
expect(nodeList.size).to.equal(3);
|
23
|
+
});
|
24
|
+
|
25
|
+
it('should create a NodeList from a NodeList', function () {
|
26
|
+
let nodeList = new NodeList([
|
27
|
+
new Node('div'),
|
28
|
+
new Node('div'),
|
29
|
+
new Node('div')
|
30
|
+
]);
|
31
|
+
|
32
|
+
let nodeList2 = new NodeList(nodeList);
|
33
|
+
|
34
|
+
expect(nodeList2.size).to.equal(3);
|
35
|
+
});
|
36
|
+
});
|
37
|
+
|
38
|
+
it('create NodeList', function () {
|
39
|
+
expect(new NodeList()).is.instanceof(NodeList);
|
40
|
+
})
|
41
|
+
|
42
|
+
it('add Node', function () {
|
43
|
+
expect(new NodeList().add(new Node())).to.be.instanceof(NodeList);
|
44
|
+
})
|
45
|
+
|
46
|
+
it('remove Node', function () {
|
47
|
+
expect(new NodeList().remove(new Node())).to.be.instanceof(NodeList);
|
48
|
+
})
|
49
|
+
|
50
|
+
it('has unknown Node', function () {
|
51
|
+
expect(new NodeList().has(new Node)).to.be.false;
|
52
|
+
})
|
53
|
+
|
54
|
+
it('has added Node', function () {
|
55
|
+
const n = new Node;
|
56
|
+
expect(new NodeList().add(n).has(n)).to.be.true;
|
57
|
+
})
|
58
|
+
|
59
|
+
it('throw exception', function () {
|
60
|
+
expect(() => new NodeList().add(1)).to.throw(Error);
|
61
|
+
})
|
62
|
+
|
63
|
+
|
64
|
+
});
|
@@ -0,0 +1,54 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
import {expect} from "chai"
|
4
|
+
import {Node} from "../../../source/types/node.js";
|
5
|
+
import {NodeRecursiveIterator} from "../../../source/types/noderecursiveiterator.js";
|
6
|
+
|
7
|
+
describe('NodeRecursiveIterator', function () {
|
8
|
+
|
9
|
+
it('should throw exeption', function () {
|
10
|
+
expect(() => new NodeRecursiveIterator()).to.throw(Error)
|
11
|
+
});
|
12
|
+
it('should be a function', function () {
|
13
|
+
expect(NodeRecursiveIterator).to.be.a('function');
|
14
|
+
});
|
15
|
+
|
16
|
+
it('should be a constructor', function () {
|
17
|
+
expect(new NodeRecursiveIterator(new Node)).to.be.an.instanceof(NodeRecursiveIterator);
|
18
|
+
});
|
19
|
+
|
20
|
+
/**
|
21
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield
|
22
|
+
*/
|
23
|
+
it('undefined should not result in undefined node', function () {
|
24
|
+
const iterator = new NodeRecursiveIterator(new Node);
|
25
|
+
|
26
|
+
const result = [];
|
27
|
+
for (const n of iterator) {
|
28
|
+
expect(n).to.be.an.instanceof(Node);
|
29
|
+
result.push(n.value);
|
30
|
+
}
|
31
|
+
|
32
|
+
expect(result).to.deep.equal([undefined]);
|
33
|
+
|
34
|
+
});
|
35
|
+
|
36
|
+
it('should iterate', function () {
|
37
|
+
const node =
|
38
|
+
new Node('1')
|
39
|
+
node.appendChild(
|
40
|
+
(new Node('2')).appendChild(new Node('2.1')).appendChild(new Node('2.2')).appendChild(new Node('2.3'))).appendChild(new Node('3')).appendChild(new Node('4').appendChild(new Node('4.1')).appendChild(new Node('4.2')));
|
41
|
+
|
42
|
+
const iterator = new NodeRecursiveIterator(node);
|
43
|
+
|
44
|
+
const result = [];
|
45
|
+
for (const n of iterator) {
|
46
|
+
expect(n).to.be.an.instanceof(Node);
|
47
|
+
result.push(n.value);
|
48
|
+
}
|
49
|
+
|
50
|
+
expect(result).to.deep.equal(['1', '2', '2.1', '2.2', '2.3', '3', '4', '4.1', '4.2']);
|
51
|
+
|
52
|
+
});
|
53
|
+
|
54
|
+
});
|
@@ -1,23 +1,65 @@
|
|
1
1
|
import {expect} from "chai"
|
2
|
+
import {extend} from "../../../source/data/extend.js";
|
3
|
+
import {isObject} from "../../../source/types/is.js";
|
4
|
+
import {Observer} from "../../../source/types/observer.js";
|
2
5
|
|
3
6
|
import {ProxyObserver} from "../../../source/types/proxyobserver.js";
|
4
|
-
import {Observer} from "../../../source/types/observer.js";
|
5
|
-
import {isObject} from "../../../source/types/is.js";
|
6
7
|
|
7
8
|
describe('ProxyObserver', function () {
|
8
9
|
|
10
|
+
describe('create', function () {
|
11
|
+
it('should return instanceof ProxyObserver', function () {
|
12
|
+
let o = new ProxyObserver({});
|
13
|
+
extend(o.getSubject(), {a: 4});
|
14
|
+
expect(o.getRealSubject()).is.eql({a: 4});
|
15
|
+
});
|
16
|
+
});
|
17
|
+
|
18
|
+
describe('setSubject', function () {
|
19
|
+
it('should run observer', function (done) {
|
20
|
+
let o = new ProxyObserver({a: 1});
|
21
|
+
expect(o.getRealSubject()).is.eql({a: 1});
|
22
|
+
let counter = 0;
|
23
|
+
o.attachObserver(new Observer(function () {
|
24
|
+
if (isObject(this) && this instanceof ProxyObserver) {
|
25
|
+
counter++;
|
26
|
+
// only one change as notify runs later
|
27
|
+
if (counter === 1) {
|
28
|
+
done();
|
29
|
+
return;
|
30
|
+
}
|
31
|
+
done("called for error");
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
|
35
|
+
done(new Error("this is not ProxyObserver"))
|
36
|
+
}))
|
37
|
+
|
38
|
+
o.getSubject().c = 4;
|
39
|
+
expect(o.getRealSubject()).is.eql({a: 1, c: 4});
|
40
|
+
|
41
|
+
o.setSubject({b: 2});
|
42
|
+
expect(o.getRealSubject()).is.eql({b: 2});
|
43
|
+
|
44
|
+
o.getSubject().d = 5;
|
45
|
+
expect(o.getRealSubject()).is.eql({b: 2, d: 5});
|
46
|
+
|
47
|
+
|
48
|
+
});
|
49
|
+
});
|
50
|
+
|
9
51
|
describe('create', function () {
|
10
52
|
it('should return instanceof ProxyObserver', function () {
|
11
53
|
let o = new ProxyObserver({});
|
12
54
|
expect(o).is.instanceOf(ProxyObserver);
|
13
55
|
});
|
14
56
|
});
|
15
|
-
|
57
|
+
|
16
58
|
describe('proxy objects', function () {
|
17
59
|
it('Proxy objects should not be recommitted', function () {
|
18
|
-
let o = new ProxyObserver({a:{b:true}});
|
19
|
-
o.getSubject().a.b=o.getSubject();
|
20
|
-
o.getSubject().a.b.a.b=false;
|
60
|
+
let o = new ProxyObserver({a: {b: true}});
|
61
|
+
o.getSubject().a.b = o.getSubject();
|
62
|
+
o.getSubject().a.b.a.b = false;
|
21
63
|
//expect(o.getSubject()===p.getSubject()).to.be.true;
|
22
64
|
});
|
23
65
|
});
|
@@ -67,7 +109,7 @@ describe('ProxyObserver', function () {
|
|
67
109
|
|
68
110
|
it('check Reflect.set() with Subject', function () {
|
69
111
|
let r;
|
70
|
-
|
112
|
+
|
71
113
|
const obj = (new ProxyObserver({})).getSubject();
|
72
114
|
|
73
115
|
[
|
@@ -75,14 +117,16 @@ describe('ProxyObserver', function () {
|
|
75
117
|
undefined,
|
76
118
|
"no"
|
77
119
|
].forEach(function (value) {
|
78
|
-
expect(()=>{
|
120
|
+
expect(() => {
|
121
|
+
obj['data'] = value
|
122
|
+
}).to.not.throw();
|
79
123
|
//r = Reflect.set(obj, 'data', value)
|
80
124
|
//expect(r).to.be.true;
|
81
125
|
})
|
82
|
-
|
83
|
-
|
126
|
+
|
127
|
+
|
84
128
|
});
|
85
|
-
|
129
|
+
|
86
130
|
|
87
131
|
[
|
88
132
|
['that', {that: 'checked1'}],
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import * as Crypto from "@peculiar/webcrypto";
|
2
|
+
|
3
|
+
import {expect} from "chai"
|
4
|
+
import {escapeString} from "../../../source/types/regex.js"
|
5
|
+
|
6
|
+
if (!global['crypto']) {
|
7
|
+
global['crypto'] = new Crypto.Crypto();
|
8
|
+
}
|
9
|
+
|
10
|
+
describe('escapeString', function () {
|
11
|
+
|
12
|
+
|
13
|
+
[
|
14
|
+
['test1', 'test1'],
|
15
|
+
['${', '\\$\\{'],
|
16
|
+
['i18n{', 'i18n\\{'],
|
17
|
+
['//', '//'],
|
18
|
+
['\\', '\\\\'],
|
19
|
+
|
20
|
+
].forEach(function (data) {
|
21
|
+
|
22
|
+
let a = data.shift()
|
23
|
+
let b = data.shift()
|
24
|
+
|
25
|
+
it('escapeString(' + a + ') should return ' + b, function () {
|
26
|
+
expect(escapeString(a)).is.equal(b)
|
27
|
+
});
|
28
|
+
});
|
29
|
+
|
30
|
+
|
31
|
+
});
|
32
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import * as Crypto from "@peculiar/webcrypto";
|
2
|
+
import {expect} from "chai"
|
3
|
+
import {UUID} from "../../../source/types/uuid.js";
|
4
|
+
|
5
|
+
if (!global['crypto']) {
|
6
|
+
global['crypto'] = new Crypto.Crypto();
|
7
|
+
}
|
8
|
+
|
9
|
+
|
10
|
+
describe('UUID', function () {
|
11
|
+
|
12
|
+
describe('.toString()', function () {
|
13
|
+
let uuid = new UUID()
|
14
|
+
let result = uuid.toString();
|
15
|
+
|
16
|
+
it('should return a string', function () {
|
17
|
+
expect(result).is.a('string')
|
18
|
+
expect(result.length).is.equal(36)
|
19
|
+
});
|
20
|
+
|
21
|
+
it('test format', function (done) {
|
22
|
+
|
23
|
+
const regexExp = /^[A-F\d]{8}-[A-F\d]{4}-4[A-F\d]{3}-[89AB][A-F\d]{3}-[A-F\d]{12}$/i;
|
24
|
+
|
25
|
+
for (let i = 0; i < 2000; i++) {
|
26
|
+
const u = new UUID().toString();
|
27
|
+
const r = regexExp.test(u);
|
28
|
+
|
29
|
+
if (r !== true) {
|
30
|
+
done('no uuid ' + u + ' => ' + r);
|
31
|
+
return;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
done();
|
36
|
+
|
37
|
+
});
|
38
|
+
|
39
|
+
});
|
40
|
+
|
41
|
+
});
|
42
|
+
|
@@ -10,13 +10,39 @@ describe('deepFreeze', function () {
|
|
10
10
|
|
11
11
|
let obj1 = {
|
12
12
|
a: {
|
13
|
-
b: {
|
13
|
+
b: {
|
14
|
+
c:1
|
15
|
+
}
|
14
16
|
}
|
15
17
|
};
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
19
|
+
let obj2 = {
|
20
|
+
a: {
|
21
|
+
b: {
|
22
|
+
c:2
|
23
|
+
}
|
24
|
+
}
|
25
|
+
};
|
26
|
+
|
27
|
+
expect(obj2).to.not.eql(obj1)
|
28
|
+
obj1.a.b.c = 2;
|
29
|
+
expect(obj2).to.eql(obj1);
|
30
|
+
|
31
|
+
const obj1Freezed = deepFreeze(obj1);
|
32
|
+
|
33
|
+
expect(obj2).to.eql(obj1Freezed);
|
34
|
+
|
35
|
+
try {
|
36
|
+
// https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
|
37
|
+
// no change to the object, exception depends on mode (strict ES 2015, etc)
|
38
|
+
obj1Freezed.a.b.c = 3
|
39
|
+
} catch (_) {
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
expect(obj2).to.eql(obj1Freezed);
|
44
|
+
|
45
|
+
|
20
46
|
});
|
21
47
|
|
22
48
|
});
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import {expect} from "chai"
|
2
|
+
import {trimSpaces} from "../../../source/util/trimspaces.js";
|
3
|
+
|
4
|
+
|
5
|
+
describe('trimSpaces', function () {
|
6
|
+
[
|
7
|
+
// one stroke is escped by the javascript interpreter, the second stroke escapes the stroke
|
8
|
+
[' value ', 'value'],
|
9
|
+
[' value\\ ', 'value\\ '],
|
10
|
+
['\\ value\\ ', '\\ value\\ '],
|
11
|
+
['\ value\ ', 'value'],
|
12
|
+
[" value \ ", 'value'],
|
13
|
+
|
14
|
+
].forEach(function (data) {
|
15
|
+
|
16
|
+
let a = data.shift()
|
17
|
+
let b = data.shift()
|
18
|
+
|
19
|
+
it('trimSpaces(' + JSON.stringify(a) + ') should return ' + JSON.stringify(b), function () {
|
20
|
+
expect(trimSpaces(a)).to.be.equal(b);
|
21
|
+
});
|
22
|
+
});
|
23
|
+
});
|
24
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
|
4
|
+
let addedNodes, mutationobserver;
|
5
|
+
|
6
|
+
function init() {
|
7
|
+
|
8
|
+
addedNodes = [];
|
9
|
+
mutationobserver = new MutationObserver(function (mutations) {
|
10
|
+
mutations.forEach(function (mutation) {
|
11
|
+
if (mutation.type === 'childList' && mutation.removedNodes) {
|
12
|
+
|
13
|
+
mutation.addedNodes.forEach((n) => {
|
14
|
+
if (n instanceof HTMLElement) {
|
15
|
+
addedNodes.push(n);
|
16
|
+
}
|
17
|
+
})
|
18
|
+
}
|
19
|
+
|
20
|
+
});
|
21
|
+
});
|
22
|
+
|
23
|
+
|
24
|
+
}
|
25
|
+
|
26
|
+
|
27
|
+
/**
|
28
|
+
*
|
29
|
+
*/
|
30
|
+
export function initMutationObserverForTesting() {
|
31
|
+
|
32
|
+
if (mutationobserver === undefined) {
|
33
|
+
init()
|
34
|
+
}
|
35
|
+
|
36
|
+
mutationobserver.observe(document.querySelector('head'), {childList: true});
|
37
|
+
}
|
38
|
+
|
39
|
+
/**
|
40
|
+
*
|
41
|
+
*/
|
42
|
+
export function cleanupDOMFromTesting() {
|
43
|
+
mutationobserver.disconnect();
|
44
|
+
|
45
|
+
for (const n of addedNodes) {
|
46
|
+
n.remove();
|
47
|
+
}
|
48
|
+
}
|
package/test/util/jsdom.js
CHANGED
@@ -1,29 +1,39 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
+
import {extend} from "../../source/data/extend.js";
|
3
4
|
import {getGlobal} from "../../source/types/global.js";
|
4
5
|
|
6
|
+
export const isBrowser = new Function("try {return this===window;}catch(e){ return false;}");
|
7
|
+
|
8
|
+
export const isNode = new Function("try {return this===global;}catch(e){return false;}");
|
9
|
+
|
10
|
+
|
5
11
|
/**
|
6
12
|
* this helper function creates the dom stack in the node environment
|
7
13
|
*
|
8
14
|
* @return {Promise<unknown>|Promise<void>}
|
9
15
|
*/
|
10
|
-
function initJSDOM() {
|
16
|
+
function initJSDOM(options) {
|
11
17
|
if (typeof window === "object" && window['DOMParser']) return Promise.resolve();
|
12
18
|
|
13
19
|
const g = getGlobal();
|
14
20
|
|
21
|
+
options = extend({}, {
|
22
|
+
pretendToBeVisual: true,
|
23
|
+
contentType: "text/html",
|
24
|
+
includeNodeLocations: true,
|
25
|
+
storageQuota: 10000000,
|
26
|
+
runScripts: "dangerously",
|
27
|
+
resources: "usable"
|
28
|
+
}, options||{})
|
29
|
+
|
15
30
|
return import("jsdom").then(({JSDOM}) => {
|
16
31
|
const {window} = new JSDOM(`<html>
|
17
32
|
<head>
|
18
33
|
</head>
|
19
34
|
<body>
|
20
35
|
<div id="mocks"></div>
|
21
|
-
</body>`,
|
22
|
-
pretendToBeVisual: true,
|
23
|
-
contentType: "text/html",
|
24
|
-
includeNodeLocations: true,
|
25
|
-
storageQuota: 10000000
|
26
|
-
});
|
36
|
+
</body>`, options);
|
27
37
|
|
28
38
|
g['window'] = window;
|
29
39
|
|
@@ -35,6 +45,7 @@ function initJSDOM() {
|
|
35
45
|
'HTMLCollection',
|
36
46
|
'NodeList',
|
37
47
|
'ElementInternals',
|
48
|
+
'HTMLDocument',
|
38
49
|
'HTMLFormElement',
|
39
50
|
'HTMLInputElement',
|
40
51
|
'HTMLSelectElement',
|
@@ -44,7 +55,6 @@ function initJSDOM() {
|
|
44
55
|
'Node',
|
45
56
|
'ShadowRoot',
|
46
57
|
'Event',
|
47
|
-
'fetch',
|
48
58
|
'CustomEvent',
|
49
59
|
'Element',
|
50
60
|
'HTMLElement',
|
@@ -59,8 +69,11 @@ function initJSDOM() {
|
|
59
69
|
'NodeFilter',
|
60
70
|
'navigator',
|
61
71
|
'InputEvent',
|
72
|
+
'Blob',
|
62
73
|
'CustomEvent'
|
63
|
-
].forEach(key =>
|
74
|
+
].forEach(key => {
|
75
|
+
g[key] = window[key]
|
76
|
+
});
|
64
77
|
|
65
78
|
resolve();
|
66
79
|
})
|
package/test/web/import.js
CHANGED
@@ -5,22 +5,31 @@ import "../cases/logging/handler.js";
|
|
5
5
|
import "../cases/logging/logentry.js";
|
6
6
|
import "../cases/logging/handler/console.js";
|
7
7
|
import "../cases/text/formatter.js";
|
8
|
+
import "../cases/dom/resource/script.js";
|
9
|
+
import "../cases/dom/resource/data.js";
|
10
|
+
import "../cases/dom/resource/link/stylesheet.js";
|
11
|
+
import "../cases/dom/resource/link.js";
|
8
12
|
import "../cases/dom/updater.js";
|
9
13
|
import "../cases/dom/attributes.js";
|
10
14
|
import "../cases/dom/template.js";
|
11
15
|
import "../cases/dom/util.js";
|
16
|
+
import "../cases/dom/resourcemanager.js";
|
12
17
|
import "../cases/dom/locale.js";
|
13
18
|
import "../cases/dom/customcontrol.js";
|
14
19
|
import "../cases/dom/assembler.js";
|
15
20
|
import "../cases/dom/theme.js";
|
21
|
+
import "../cases/dom/worker/factory.js";
|
22
|
+
import "../cases/dom/focusmanager.js";
|
16
23
|
import "../cases/dom/events.js";
|
17
24
|
import "../cases/dom/customelement.js";
|
25
|
+
import "../cases/i18n/formatter.js";
|
18
26
|
import "../cases/i18n/providers/fetch.js";
|
19
27
|
import "../cases/i18n/translations.js";
|
20
28
|
import "../cases/i18n/locale.js";
|
21
29
|
import "../cases/i18n/provider.js";
|
22
30
|
import "../cases/types/queue.js";
|
23
31
|
import "../cases/types/binary.js";
|
32
|
+
import "../cases/types/regex.js";
|
24
33
|
import "../cases/types/observer.js";
|
25
34
|
import "../cases/types/global.js";
|
26
35
|
import "../cases/types/observerlist.js";
|
@@ -28,14 +37,18 @@ import "../cases/types/basewithoptions.js";
|
|
28
37
|
import "../cases/types/is.js";
|
29
38
|
import "../cases/types/proxyobserver.js";
|
30
39
|
import "../cases/types/uniquequeue.js";
|
40
|
+
import "../cases/types/node.js";
|
31
41
|
import "../cases/types/tokenlist.js";
|
32
42
|
import "../cases/types/typeof.js";
|
43
|
+
import "../cases/types/uuid.js";
|
33
44
|
import "../cases/types/mediatype.js";
|
34
45
|
import "../cases/types/dataurl.js";
|
35
46
|
import "../cases/types/base.js";
|
36
47
|
import "../cases/types/version.js";
|
48
|
+
import "../cases/types/nodelist.js";
|
37
49
|
import "../cases/types/id.js";
|
38
50
|
import "../cases/types/randomid.js";
|
51
|
+
import "../cases/types/noderecursiveiterator.js";
|
39
52
|
import "../cases/types/validate.js";
|
40
53
|
import "../cases/types/stack.js";
|
41
54
|
import "../cases/constraint/isobject.js";
|
@@ -45,6 +58,7 @@ import "../cases/constraint/oroperator.js";
|
|
45
58
|
import "../cases/constraint/andoperator.js";
|
46
59
|
import "../cases/constraint/isarray.js";
|
47
60
|
import "../cases/util/comparator.js";
|
61
|
+
import "../cases/util/trimspaces.js";
|
48
62
|
import "../cases/util/clone.js";
|
49
63
|
import "../cases/util/freeze.js";
|
50
64
|
import "../cases/util/processing.js";
|
@@ -54,6 +68,7 @@ import "../cases/data/extend.js";
|
|
54
68
|
import "../cases/data/diff.js";
|
55
69
|
import "../cases/data/buildmap.js";
|
56
70
|
import "../cases/data/datasource.js";
|
71
|
+
import "../cases/data/buildtree.js";
|
57
72
|
import "../cases/data/transformer.js";
|
58
73
|
import "../cases/data/datasource/restapi.js";
|
59
74
|
import "../cases/data/datasource/storage/sessionstorage.js";
|
@@ -10,13 +10,13 @@
|
|
10
10
|
crossorigin="anonymous"
|
11
11
|
referrerpolicy="no-referrer"></script>
|
12
12
|
|
13
|
-
<script src="https://monsterjs.org/dist/1.
|
13
|
+
<script src="https://monsterjs.org/dist/1.26.0/dist/monster.dev.js"></script>
|
14
14
|
|
15
15
|
</head>
|
16
16
|
<body>
|
17
17
|
<div id="headline" style="display: flex;align-items: center;justify-content: center;flex-direction: column;">
|
18
|
-
<h1 style='margin-bottom: 0.1em;'>Monster 1.
|
19
|
-
<div id="lastupdate" style='font-size:0.7em'>last update
|
18
|
+
<h1 style='margin-bottom: 0.1em;'>Monster 1.26.0</h1>
|
19
|
+
<div id="lastupdate" style='font-size:0.7em'>last update Do 2. Dez 10:00:50 CET 2021</div>
|
20
20
|
</div>
|
21
21
|
</body>
|
22
22
|
</html>
|
package/test/web/monster.html
CHANGED
@@ -14,8 +14,8 @@
|
|
14
14
|
</head>
|
15
15
|
<body>
|
16
16
|
<div id="headline" style="display: flex;align-items: center;justify-content: center;flex-direction: column;">
|
17
|
-
<h1 style='margin-bottom: 0.1em;'>Monster 1.
|
18
|
-
<div id="lastupdate" style='font-size:0.7em'>last update
|
17
|
+
<h1 style='margin-bottom: 0.1em;'>Monster 1.26.0</h1>
|
18
|
+
<div id="lastupdate" style='font-size:0.7em'>last update Do 2. Dez 10:00:50 CET 2021</div>
|
19
19
|
</div>
|
20
20
|
</body>
|
21
21
|
</html>
|
package/test/web/test.html
CHANGED
@@ -5,15 +5,15 @@
|
|
5
5
|
<title>Mocha Monster</title>
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
7
7
|
<link rel="stylesheet" href="mocha.css"/>
|
8
|
-
<script id="polyfill" src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Array.isArray,Array.prototype.entries,Array.prototype.fill,Array.prototype.forEach,Array.prototype.indexOf,Array.prototype.keys,Array.prototype.lastIndexOf,Array.prototype.map,Array.prototype.reduce,ArrayBuffer,atob,DataView,document,Document,DocumentFragment,Element,Event,fetch,globalThis,HTMLDocument,HTMLTemplateElement,Intl,JSON,Map,Math.log2,
|
8
|
+
<script id="polyfill" src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Array.isArray,Array.prototype.entries,Array.prototype.fill,Array.prototype.filter,Array.prototype.forEach,Array.prototype.indexOf,Array.prototype.keys,Array.prototype.lastIndexOf,Array.prototype.map,Array.prototype.reduce,Array.prototype.sort,ArrayBuffer,atob,DataView,document,Document,DocumentFragment,Element,Event,fetch,globalThis,HTMLDocument,HTMLTemplateElement,Intl,JSON,Map,Math.log2,Number.isInteger,Object.assign,Object.defineProperty,Object.entries,Object.freeze,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.keys,Promise,Reflect,Reflect.defineProperty,Reflect.get,Reflect.getOwnPropertyDescriptor,Reflect.setPrototypeOf,Set,String.prototype.endsWith,String.prototype.startsWith,String.prototype.trim,Symbol,Symbol.iterator,Uint16Array,Uint8Array,URL,WeakMap,WeakSet"
|
9
9
|
crossorigin="anonymous"
|
10
10
|
referrerpolicy="no-referrer"></script>
|
11
11
|
|
12
12
|
</head>
|
13
13
|
<body>
|
14
14
|
<div id="headline" style="display: flex;align-items: center;justify-content: center;flex-direction: column;">
|
15
|
-
<h1 style='margin-bottom: 0.1em;'>Monster 1.
|
16
|
-
<div id="lastupdate" style='font-size:0.7em'>last update
|
15
|
+
<h1 style='margin-bottom: 0.1em;'>Monster 1.26.0</h1>
|
16
|
+
<div id="lastupdate" style='font-size:0.7em'>last update Do 2. Dez 10:00:50 CET 2021</div>
|
17
17
|
</div>
|
18
18
|
<div id="mocks"></div>
|
19
19
|
<div id="mocha"></div>
|