xdbc 1.0.217 → 1.0.218
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/.gitattributes +8 -0
- package/.vscode/settings.json +3 -3
- package/.vscode/tasks.json +23 -23
- package/ASSESSMENT.md +249 -0
- package/README.md +131 -1
- package/__tests__/DBC/AE.test.ts +62 -62
- package/__tests__/DBC/ARRAY.test.ts +91 -91
- package/__tests__/DBC/DEFINED.test.ts +53 -53
- package/__tests__/DBC/DOM.test.ts +481 -0
- package/__tests__/DBC/Decorators.test.ts +367 -367
- package/__tests__/DBC/EQ.test.ts +13 -13
- package/__tests__/DBC/GREATER.test.ts +31 -31
- package/__tests__/DBC/HasAttribute.test.ts +60 -60
- package/__tests__/DBC/IF.test.ts +62 -62
- package/__tests__/DBC/INSTANCE.test.ts +13 -13
- package/__tests__/DBC/JSON.OP.test.ts +47 -47
- package/__tests__/DBC/JSON.Parse.test.ts +17 -17
- package/__tests__/DBC/OR.test.ts +14 -14
- package/__tests__/DBC/PLAIN_OBJECT.test.ts +109 -109
- package/__tests__/DBC/REGEX.test.ts +17 -17
- package/__tests__/DBC/TYPE.test.ts +13 -13
- package/__tests__/DBC/UNDEFINED.test.ts +45 -45
- package/__tests__/DBC/ZOD.test.ts +54 -54
- package/__tests__/DBC/onInfringement.test.ts +262 -0
- package/biome.json +40 -40
- package/dist/DBC/AE.js +172 -0
- package/dist/DBC/ARR/PLAIN_OBJECT.d.ts +0 -3
- package/dist/DBC/ARR/PLAIN_OBJECT.js +95 -0
- package/dist/DBC/ARRAY.d.ts +0 -3
- package/dist/DBC/ARRAY.js +90 -0
- package/dist/DBC/COMPARISON/GREATER.js +21 -0
- package/dist/DBC/COMPARISON/GREATER_OR_EQUAL.js +21 -0
- package/dist/DBC/COMPARISON/LESS.js +21 -0
- package/dist/DBC/COMPARISON/LESS_OR_EQUAL.js +21 -0
- package/dist/DBC/COMPARISON.js +98 -0
- package/dist/DBC/DEFINED.js +87 -0
- package/dist/DBC/DOM.d.ts +87 -0
- package/dist/DBC/DOM.js +223 -0
- package/dist/DBC/EQ/DIFFERENT.js +34 -0
- package/dist/DBC/EQ.js +101 -0
- package/dist/DBC/HasAttribute.js +101 -0
- package/dist/DBC/IF.js +96 -0
- package/dist/DBC/INSTANCE.js +122 -0
- package/dist/DBC/JSON.OP.js +120 -0
- package/dist/DBC/JSON.Parse.js +104 -0
- package/dist/DBC/OR.js +125 -0
- package/dist/DBC/REGEX.js +136 -0
- package/dist/DBC/TYPE.js +112 -0
- package/dist/DBC/UNDEFINED.js +87 -0
- package/dist/DBC/ZOD.js +99 -0
- package/dist/DBC.d.ts +18 -4
- package/dist/DBC.js +645 -0
- package/dist/Demo.d.ts +10 -0
- package/dist/Demo.js +713 -0
- package/dist/bundle.js +6140 -405
- package/dist/index.d.ts +22 -0
- package/dist/index.js +22 -0
- package/jest.config.js +32 -32
- package/package.json +71 -55
- package/src/DBC/AE.ts +269 -288
- package/src/DBC/ARR/PLAIN_OBJECT.ts +122 -133
- package/src/DBC/ARRAY.ts +117 -127
- package/src/DBC/COMPARISON/GREATER.ts +41 -46
- package/src/DBC/COMPARISON/GREATER_OR_EQUAL.ts +41 -45
- package/src/DBC/COMPARISON/LESS.ts +41 -45
- package/src/DBC/COMPARISON/LESS_OR_EQUAL.ts +41 -45
- package/src/DBC/COMPARISON.ts +149 -159
- package/src/DBC/DEFINED.ts +117 -122
- package/src/DBC/DOM.ts +291 -0
- package/src/DBC/EQ/DIFFERENT.ts +51 -57
- package/src/DBC/EQ.ts +154 -163
- package/src/DBC/HasAttribute.ts +149 -154
- package/src/DBC/IF.ts +173 -179
- package/src/DBC/INSTANCE.ts +168 -171
- package/src/DBC/JSON.OP.ts +178 -186
- package/src/DBC/JSON.Parse.ts +150 -157
- package/src/DBC/OR.ts +183 -187
- package/src/DBC/REGEX.ts +195 -196
- package/src/DBC/TYPE.ts +142 -149
- package/src/DBC/UNDEFINED.ts +115 -117
- package/src/DBC/ZOD.ts +130 -135
- package/src/DBC.ts +902 -904
- package/src/Demo.ts +537 -404
- package/src/index.ts +22 -0
- package/tsconfig.json +18 -18
- package/tsconfig.test.json +7 -7
- package/typedoc.json +16 -16
- package/webpack.config.js +27 -27
- package/Assessment.md +0 -507
package/__tests__/DBC/EQ.test.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { EQ } from "../../src/DBC/EQ";
|
|
2
|
-
|
|
3
|
-
describe("EQ", () => {
|
|
4
|
-
const eq = new EQ("b");
|
|
5
|
-
|
|
6
|
-
test("Should not report infringement with 'b' to check", () => {
|
|
7
|
-
expect(eq.check("b")).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
test("Should report infringement with 'c' to check", () => {
|
|
11
|
-
expect(typeof eq.check("c")).toBe("string");
|
|
12
|
-
});
|
|
13
|
-
});
|
|
1
|
+
import { EQ } from "../../src/DBC/EQ";
|
|
2
|
+
|
|
3
|
+
describe("EQ", () => {
|
|
4
|
+
const eq = new EQ("b");
|
|
5
|
+
|
|
6
|
+
test("Should not report infringement with 'b' to check", () => {
|
|
7
|
+
expect(eq.check("b")).toBe(true);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test("Should report infringement with 'c' to check", () => {
|
|
11
|
+
expect(typeof eq.check("c")).toBe("string");
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { GREATER } from "../../src/DBC/COMPARISON/GREATER";
|
|
2
|
-
import { GREATER_OR_EQUAL } from "../../src/DBC/COMPARISON/GREATER_OR_EQUAL";
|
|
3
|
-
import { LESS_OR_EQUAL } from "../../src/DBC/COMPARISON/LESS_OR_EQUAL";
|
|
4
|
-
|
|
5
|
-
describe("GREATER", () => {
|
|
6
|
-
const greater = new GREATER(1);
|
|
7
|
-
|
|
8
|
-
test("Should not report infringement with '2' to check", () => {
|
|
9
|
-
expect(greater.check(2)).toBe(true);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test("Should report infringement with '0' to check", () => {
|
|
13
|
-
expect(typeof greater.check(0)).toBe("string");
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
test("Should report infringement with '1' to check (equality not permitted)", () => {
|
|
17
|
-
expect(typeof greater.check(1)).toBe("string");
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test("Should not report infringement with '1' and '1' to check since equality is now permitted", () => {
|
|
21
|
-
expect(new GREATER_OR_EQUAL(1).check(1)).toBe(true);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test("Should not report infringement with '1' and '1' to check since inverting the result is now on", () => {
|
|
25
|
-
expect(new LESS_OR_EQUAL(1).check(1)).toBe(true);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test("Should not report infringement with 'undefined' and 'undefined' to check", () => {
|
|
29
|
-
expect(new GREATER(undefined).check(undefined)).toBe(true);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
1
|
+
import { GREATER } from "../../src/DBC/COMPARISON/GREATER";
|
|
2
|
+
import { GREATER_OR_EQUAL } from "../../src/DBC/COMPARISON/GREATER_OR_EQUAL";
|
|
3
|
+
import { LESS_OR_EQUAL } from "../../src/DBC/COMPARISON/LESS_OR_EQUAL";
|
|
4
|
+
|
|
5
|
+
describe("GREATER", () => {
|
|
6
|
+
const greater = new GREATER(1);
|
|
7
|
+
|
|
8
|
+
test("Should not report infringement with '2' to check", () => {
|
|
9
|
+
expect(greater.check(2)).toBe(true);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test("Should report infringement with '0' to check", () => {
|
|
13
|
+
expect(typeof greater.check(0)).toBe("string");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test("Should report infringement with '1' to check (equality not permitted)", () => {
|
|
17
|
+
expect(typeof greater.check(1)).toBe("string");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test("Should not report infringement with '1' and '1' to check since equality is now permitted", () => {
|
|
21
|
+
expect(new GREATER_OR_EQUAL(1).check(1)).toBe(true);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test("Should not report infringement with '1' and '1' to check since inverting the result is now on", () => {
|
|
25
|
+
expect(new LESS_OR_EQUAL(1).check(1)).toBe(true);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test("Should not report infringement with 'undefined' and 'undefined' to check", () => {
|
|
29
|
+
expect(new GREATER(undefined).check(undefined)).toBe(true);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import { HasAttribute } from "../../src/DBC/HasAttribute";
|
|
2
|
-
|
|
3
|
-
describe("HasAttribute", () => {
|
|
4
|
-
const hasId = new HasAttribute("id");
|
|
5
|
-
|
|
6
|
-
test("Should not report infringement when attribute exists", () => {
|
|
7
|
-
const el = document.createElement("div");
|
|
8
|
-
el.setAttribute("id", "test");
|
|
9
|
-
expect(hasId.check(el)).toBe(true);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test("Should report infringement when attribute is missing", () => {
|
|
13
|
-
const el = document.createElement("div");
|
|
14
|
-
expect(typeof hasId.check(el)).toBe("string");
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test("Should report infringement when value is not an HTMLElement", () => {
|
|
18
|
-
expect(typeof hasId.check("not an element")).toBe("string");
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test("Should report infringement when value is a plain object", () => {
|
|
22
|
-
expect(typeof hasId.check({ id: "test" })).toBe("string");
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe("invert", () => {
|
|
26
|
-
const noId = new HasAttribute("id", true);
|
|
27
|
-
|
|
28
|
-
test("Should not report infringement when attribute is absent", () => {
|
|
29
|
-
const el = document.createElement("div");
|
|
30
|
-
expect(noId.check(el)).toBe(true);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test("Should report infringement when forbidden attribute exists", () => {
|
|
34
|
-
const el = document.createElement("div");
|
|
35
|
-
el.setAttribute("id", "test");
|
|
36
|
-
expect(typeof noId.check(el)).toBe("string");
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
describe("checkAlgorithm", () => {
|
|
41
|
-
test("Should return true when element has the attribute", () => {
|
|
42
|
-
const el = document.createElement("span");
|
|
43
|
-
el.setAttribute("class", "active");
|
|
44
|
-
expect(HasAttribute.checkAlgorithm(el, "class", false)).toBe(true);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test("Should return string when element lacks the attribute", () => {
|
|
48
|
-
const el = document.createElement("span");
|
|
49
|
-
expect(typeof HasAttribute.checkAlgorithm(el, "class", false)).toBe(
|
|
50
|
-
"string",
|
|
51
|
-
);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test("Should return string for non-HTMLElement", () => {
|
|
55
|
-
expect(typeof HasAttribute.checkAlgorithm(42, "id", false)).toBe(
|
|
56
|
-
"string",
|
|
57
|
-
);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
});
|
|
1
|
+
import { HasAttribute } from "../../src/DBC/HasAttribute";
|
|
2
|
+
|
|
3
|
+
describe("HasAttribute", () => {
|
|
4
|
+
const hasId = new HasAttribute("id");
|
|
5
|
+
|
|
6
|
+
test("Should not report infringement when attribute exists", () => {
|
|
7
|
+
const el = document.createElement("div");
|
|
8
|
+
el.setAttribute("id", "test");
|
|
9
|
+
expect(hasId.check(el)).toBe(true);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test("Should report infringement when attribute is missing", () => {
|
|
13
|
+
const el = document.createElement("div");
|
|
14
|
+
expect(typeof hasId.check(el)).toBe("string");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("Should report infringement when value is not an HTMLElement", () => {
|
|
18
|
+
expect(typeof hasId.check("not an element")).toBe("string");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("Should report infringement when value is a plain object", () => {
|
|
22
|
+
expect(typeof hasId.check({ id: "test" })).toBe("string");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe("invert", () => {
|
|
26
|
+
const noId = new HasAttribute("id", true);
|
|
27
|
+
|
|
28
|
+
test("Should not report infringement when attribute is absent", () => {
|
|
29
|
+
const el = document.createElement("div");
|
|
30
|
+
expect(noId.check(el)).toBe(true);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("Should report infringement when forbidden attribute exists", () => {
|
|
34
|
+
const el = document.createElement("div");
|
|
35
|
+
el.setAttribute("id", "test");
|
|
36
|
+
expect(typeof noId.check(el)).toBe("string");
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe("checkAlgorithm", () => {
|
|
41
|
+
test("Should return true when element has the attribute", () => {
|
|
42
|
+
const el = document.createElement("span");
|
|
43
|
+
el.setAttribute("class", "active");
|
|
44
|
+
expect(HasAttribute.checkAlgorithm(el, "class", false)).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("Should return string when element lacks the attribute", () => {
|
|
48
|
+
const el = document.createElement("span");
|
|
49
|
+
expect(typeof HasAttribute.checkAlgorithm(el, "class", false)).toBe(
|
|
50
|
+
"string",
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("Should return string for non-HTMLElement", () => {
|
|
55
|
+
expect(typeof HasAttribute.checkAlgorithm(42, "id", false)).toBe(
|
|
56
|
+
"string",
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
package/__tests__/DBC/IF.test.ts
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import { EQ } from "../../src/DBC/EQ";
|
|
2
|
-
import { IF } from "../../src/DBC/IF";
|
|
3
|
-
import { TYPE } from "../../src/DBC/TYPE";
|
|
4
|
-
|
|
5
|
-
describe("IF", () => {
|
|
6
|
-
const isString = new TYPE("string");
|
|
7
|
-
const eqHello = new EQ("hello");
|
|
8
|
-
|
|
9
|
-
const ifContract = new IF(isString, eqHello);
|
|
10
|
-
|
|
11
|
-
test("Should not report infringement when condition matches and inCase is fulfilled", () => {
|
|
12
|
-
expect(ifContract.check("hello")).toBe(true);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
test("Should report infringement when condition matches but inCase is not fulfilled", () => {
|
|
16
|
-
expect(typeof ifContract.check("world")).toBe("string");
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test("Should not report infringement when condition does not match", () => {
|
|
20
|
-
expect(ifContract.check(42)).toBe(true);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
describe("invert", () => {
|
|
24
|
-
const invertedContract = new IF(isString, eqHello, true);
|
|
25
|
-
|
|
26
|
-
test("Should not report infringement when condition does not match and inCase is fulfilled", () => {
|
|
27
|
-
expect(invertedContract.check("hello")).toBe(true);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test("Should report infringement when condition does not match and inCase is not fulfilled", () => {
|
|
31
|
-
expect(typeof invertedContract.check(42)).toBe("string");
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test("Should not report infringement when condition matches", () => {
|
|
35
|
-
expect(invertedContract.check("world")).toBe(true);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
describe("checkAlgorithm", () => {
|
|
40
|
-
test("Should return true when condition not met", () => {
|
|
41
|
-
expect(IF.checkAlgorithm(123, isString, eqHello)).toBe(true);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test("Should return string when condition met but inCase fails", () => {
|
|
45
|
-
expect(typeof IF.checkAlgorithm("notHello", isString, eqHello)).toBe(
|
|
46
|
-
"string",
|
|
47
|
-
);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test("Should return true when both condition and inCase pass", () => {
|
|
51
|
-
expect(IF.checkAlgorithm("hello", isString, eqHello)).toBe(true);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test("Should return true when toCheck is undefined", () => {
|
|
55
|
-
expect(IF.checkAlgorithm(undefined, isString, eqHello)).toBe(true);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test("Should return true when toCheck is null", () => {
|
|
59
|
-
expect(IF.checkAlgorithm(null, isString, eqHello)).toBe(true);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
});
|
|
1
|
+
import { EQ } from "../../src/DBC/EQ";
|
|
2
|
+
import { IF } from "../../src/DBC/IF";
|
|
3
|
+
import { TYPE } from "../../src/DBC/TYPE";
|
|
4
|
+
|
|
5
|
+
describe("IF", () => {
|
|
6
|
+
const isString = new TYPE("string");
|
|
7
|
+
const eqHello = new EQ("hello");
|
|
8
|
+
|
|
9
|
+
const ifContract = new IF(isString, eqHello);
|
|
10
|
+
|
|
11
|
+
test("Should not report infringement when condition matches and inCase is fulfilled", () => {
|
|
12
|
+
expect(ifContract.check("hello")).toBe(true);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("Should report infringement when condition matches but inCase is not fulfilled", () => {
|
|
16
|
+
expect(typeof ifContract.check("world")).toBe("string");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("Should not report infringement when condition does not match", () => {
|
|
20
|
+
expect(ifContract.check(42)).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe("invert", () => {
|
|
24
|
+
const invertedContract = new IF(isString, eqHello, true);
|
|
25
|
+
|
|
26
|
+
test("Should not report infringement when condition does not match and inCase is fulfilled", () => {
|
|
27
|
+
expect(invertedContract.check("hello")).toBe(true);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("Should report infringement when condition does not match and inCase is not fulfilled", () => {
|
|
31
|
+
expect(typeof invertedContract.check(42)).toBe("string");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("Should not report infringement when condition matches", () => {
|
|
35
|
+
expect(invertedContract.check("world")).toBe(true);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe("checkAlgorithm", () => {
|
|
40
|
+
test("Should return true when condition not met", () => {
|
|
41
|
+
expect(IF.checkAlgorithm(123, isString, eqHello)).toBe(true);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("Should return string when condition met but inCase fails", () => {
|
|
45
|
+
expect(typeof IF.checkAlgorithm("notHello", isString, eqHello)).toBe(
|
|
46
|
+
"string",
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("Should return true when both condition and inCase pass", () => {
|
|
51
|
+
expect(IF.checkAlgorithm("hello", isString, eqHello)).toBe(true);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("Should return true when toCheck is undefined", () => {
|
|
55
|
+
expect(IF.checkAlgorithm(undefined, isString, eqHello)).toBe(true);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("Should return true when toCheck is null", () => {
|
|
59
|
+
expect(IF.checkAlgorithm(null, isString, eqHello)).toBe(true);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { INSTANCE } from "../../src/DBC/INSTANCE";
|
|
2
|
-
|
|
3
|
-
describe("INSTANCE", () => {
|
|
4
|
-
const instance = new INSTANCE(RegExp);
|
|
5
|
-
|
|
6
|
-
test("Should not report infringement with '/a/g' to check", () => {
|
|
7
|
-
expect(instance.check(/a/g)).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
test("Should report infringement with 'd' to check", () => {
|
|
11
|
-
expect(typeof instance.check("d")).toBe("string");
|
|
12
|
-
});
|
|
13
|
-
});
|
|
1
|
+
import { INSTANCE } from "../../src/DBC/INSTANCE";
|
|
2
|
+
|
|
3
|
+
describe("INSTANCE", () => {
|
|
4
|
+
const instance = new INSTANCE(RegExp);
|
|
5
|
+
|
|
6
|
+
test("Should not report infringement with '/a/g' to check", () => {
|
|
7
|
+
expect(instance.check(/a/g)).toBe(true);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test("Should report infringement with 'd' to check", () => {
|
|
11
|
+
expect(typeof instance.check("d")).toBe("string");
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { JSON_OP } from "../../src/DBC/JSON.OP";
|
|
2
|
-
|
|
3
|
-
describe("JSON.OP", () => {
|
|
4
|
-
const jsonOP = new JSON_OP([
|
|
5
|
-
{ name: "x", type: "string" },
|
|
6
|
-
{ name: "y", type: "number" },
|
|
7
|
-
]);
|
|
8
|
-
|
|
9
|
-
test("Should not report infringement with { x: 'x', y: 1 } to check", () => {
|
|
10
|
-
expect(jsonOP.check({ x: "x", y: 1 })).toBe(true);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
test("Should report infringement with { x: 1 } to check", () => {
|
|
14
|
-
expect(typeof jsonOP.check({ x: 1 })).toBe("string");
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test("Should not report infringement with [{ x: 'x', y: 1 },{ x: 'xs', y: 2 }] to check in 'checkElements' mode", () => {
|
|
18
|
-
expect(
|
|
19
|
-
new JSON_OP(
|
|
20
|
-
[
|
|
21
|
-
{ name: "x", type: "string" },
|
|
22
|
-
{ name: "y", type: "number" },
|
|
23
|
-
],
|
|
24
|
-
true,
|
|
25
|
-
).check([
|
|
26
|
-
{ x: "x", y: 1 },
|
|
27
|
-
{ x: "xs", y: 2 },
|
|
28
|
-
]),
|
|
29
|
-
).toBe(true);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test("Should report infringement with [{ x: 'x', y: 1 },{ x: 'xs', y: 2 }] to check with no 'checkElements' mode", () => {
|
|
33
|
-
expect(
|
|
34
|
-
typeof new JSON_OP([
|
|
35
|
-
{ name: "x", type: "string" },
|
|
36
|
-
{ name: "y", type: "number" },
|
|
37
|
-
]).check([
|
|
38
|
-
{ x: "x", y: 1 },
|
|
39
|
-
{ x: "xs", y: 2 },
|
|
40
|
-
]),
|
|
41
|
-
).toBe("string");
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test("Should report infringement with [] to check", () => {
|
|
45
|
-
expect(typeof jsonOP.check([])).toBe("string");
|
|
46
|
-
});
|
|
47
|
-
});
|
|
1
|
+
import { JSON_OP } from "../../src/DBC/JSON.OP";
|
|
2
|
+
|
|
3
|
+
describe("JSON.OP", () => {
|
|
4
|
+
const jsonOP = new JSON_OP([
|
|
5
|
+
{ name: "x", type: "string" },
|
|
6
|
+
{ name: "y", type: "number" },
|
|
7
|
+
]);
|
|
8
|
+
|
|
9
|
+
test("Should not report infringement with { x: 'x', y: 1 } to check", () => {
|
|
10
|
+
expect(jsonOP.check({ x: "x", y: 1 })).toBe(true);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test("Should report infringement with { x: 1 } to check", () => {
|
|
14
|
+
expect(typeof jsonOP.check({ x: 1 })).toBe("string");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("Should not report infringement with [{ x: 'x', y: 1 },{ x: 'xs', y: 2 }] to check in 'checkElements' mode", () => {
|
|
18
|
+
expect(
|
|
19
|
+
new JSON_OP(
|
|
20
|
+
[
|
|
21
|
+
{ name: "x", type: "string" },
|
|
22
|
+
{ name: "y", type: "number" },
|
|
23
|
+
],
|
|
24
|
+
true,
|
|
25
|
+
).check([
|
|
26
|
+
{ x: "x", y: 1 },
|
|
27
|
+
{ x: "xs", y: 2 },
|
|
28
|
+
]),
|
|
29
|
+
).toBe(true);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("Should report infringement with [{ x: 'x', y: 1 },{ x: 'xs', y: 2 }] to check with no 'checkElements' mode", () => {
|
|
33
|
+
expect(
|
|
34
|
+
typeof new JSON_OP([
|
|
35
|
+
{ name: "x", type: "string" },
|
|
36
|
+
{ name: "y", type: "number" },
|
|
37
|
+
]).check([
|
|
38
|
+
{ x: "x", y: 1 },
|
|
39
|
+
{ x: "xs", y: 2 },
|
|
40
|
+
]),
|
|
41
|
+
).toBe("string");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("Should report infringement with [] to check", () => {
|
|
45
|
+
expect(typeof jsonOP.check([])).toBe("string");
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { JSON_Parse } from "../../src/DBC/JSON.Parse";
|
|
2
|
-
|
|
3
|
-
describe("JSON_Parse", () => {
|
|
4
|
-
const jsonParse = new JSON_Parse();
|
|
5
|
-
|
|
6
|
-
test(`Should not report infringement with '{"d":"o"}' to check`, () => {
|
|
7
|
-
expect(jsonParse.check('{"d":"o"}')).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
test(`Should report infringement with '{"d":o}' to check`, () => {
|
|
11
|
-
expect(typeof jsonParse.check('{"d":o}')).toBe("string");
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test(`Should not report infringement or throw "referenceException" with '{"d":"o"}' to check and "receptor" not defined`, () => {
|
|
15
|
-
expect(new JSON_Parse().check('{"d":"o"}')).toBe(true);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
1
|
+
import { JSON_Parse } from "../../src/DBC/JSON.Parse";
|
|
2
|
+
|
|
3
|
+
describe("JSON_Parse", () => {
|
|
4
|
+
const jsonParse = new JSON_Parse();
|
|
5
|
+
|
|
6
|
+
test(`Should not report infringement with '{"d":"o"}' to check`, () => {
|
|
7
|
+
expect(jsonParse.check('{"d":"o"}')).toBe(true);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test(`Should report infringement with '{"d":o}' to check`, () => {
|
|
11
|
+
expect(typeof jsonParse.check('{"d":o}')).toBe("string");
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test(`Should not report infringement or throw "referenceException" with '{"d":"o"}' to check and "receptor" not defined`, () => {
|
|
15
|
+
expect(new JSON_Parse().check('{"d":"o"}')).toBe(true);
|
|
16
|
+
});
|
|
17
|
+
});
|
package/__tests__/DBC/OR.test.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { EQ } from "../../src/DBC/EQ";
|
|
2
|
-
import { OR } from "../../src/DBC/OR";
|
|
3
|
-
|
|
4
|
-
describe("OR", () => {
|
|
5
|
-
const or = new OR([new EQ("a"), new EQ("b")]);
|
|
6
|
-
|
|
7
|
-
test("Should not report infringement with 'b' to check", () => {
|
|
8
|
-
expect(or.check("b")).toBe(true);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
test("Should report infringement with 'c' to check", () => {
|
|
12
|
-
expect(typeof or.check("c")).toBe("string");
|
|
13
|
-
});
|
|
14
|
-
});
|
|
1
|
+
import { EQ } from "../../src/DBC/EQ";
|
|
2
|
+
import { OR } from "../../src/DBC/OR";
|
|
3
|
+
|
|
4
|
+
describe("OR", () => {
|
|
5
|
+
const or = new OR([new EQ("a"), new EQ("b")]);
|
|
6
|
+
|
|
7
|
+
test("Should not report infringement with 'b' to check", () => {
|
|
8
|
+
expect(or.check("b")).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("Should report infringement with 'c' to check", () => {
|
|
12
|
+
expect(typeof or.check("c")).toBe("string");
|
|
13
|
+
});
|
|
14
|
+
});
|