@legalplace/lplogic 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +52 -0
- package/.gitlab-ci.yml +28 -0
- package/.vscode/settings.json +23 -0
- package/.vscode/tasks.json +24 -0
- package/README.md +149 -0
- package/dist/LpLogic.d.ts +3 -0
- package/dist/LpLogic.js +102 -0
- package/dist/Parser.d.ts +12 -0
- package/dist/Parser.js +90 -0
- package/dist/definitions/model-v1-schema.d.ts +152 -0
- package/dist/definitions/model-v1-schema.js +2 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +9 -0
- package/dist/schemas/condition-v1-schema.d.ts +45 -0
- package/dist/schemas/condition-v1-schema.js +67 -0
- package/dist/schemas/model-v1-schema.d.ts +510 -0
- package/dist/schemas/model-v1-schema.js +543 -0
- package/jest.config.js +13 -0
- package/package.json +37 -0
- package/tests/LpLogic.test.ts +90 -0
- package/tests/Parser.test.ts +40 -0
- package/tests/References.test.ts +26 -0
- package/tests/misc/expected-model-v3.json +19891 -0
- package/tests/misc/refs-model-v3.json +642 -0
- package/tests/misc/unparsed-model-v3.json +1 -0
- package/tsconfig.json +26 -0
- package/yarn.lock +5050 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Parser, References } from "../lib/index"
|
|
2
|
+
import fs from "fs"
|
|
3
|
+
|
|
4
|
+
// Getting & Parsing models
|
|
5
|
+
let ExpectedModelV3 = JSON.parse(fs.readFileSync("./tests/misc/expected-model-v3.json", "UTF-8"))
|
|
6
|
+
let UnparsedModelV3 = JSON.parse(fs.readFileSync("./tests/misc/unparsed-model-v3.json", "UTF-8"))
|
|
7
|
+
|
|
8
|
+
// Getting Conditions v1 & v3 by option ID
|
|
9
|
+
let ConditionsV1:Record<string, any> = {}
|
|
10
|
+
let ConditionsV3:Record<string, any> = {}
|
|
11
|
+
|
|
12
|
+
// Unparsed Conditions
|
|
13
|
+
Object.keys(UnparsedModelV3.options).forEach((id) => {
|
|
14
|
+
|
|
15
|
+
let meta = UnparsedModelV3.options[ id ].meta
|
|
16
|
+
if(Array.isArray(meta.compiledConditions) && meta.compiledConditions.length > 0)
|
|
17
|
+
ConditionsV1[ id ] = meta.compiledConditions
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
// Expected Conditions
|
|
21
|
+
Object.keys(ExpectedModelV3.options).forEach((id) => {
|
|
22
|
+
let meta = ExpectedModelV3.options[ id ].meta
|
|
23
|
+
if(typeof meta.compiledConditions === 'object' && Object.keys(meta.compiledConditions).length > 0)
|
|
24
|
+
ConditionsV3[ id ] = meta.compiledConditions
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
// Setting Refs
|
|
28
|
+
beforeAll(() => {
|
|
29
|
+
References.setRefs(UnparsedModelV3.documents.main.sections, UnparsedModelV3.options, UnparsedModelV3.variables);
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
// Starting tests
|
|
33
|
+
describe(`Parser: Testing Conditions Parsing from V1 to V3 (LpLogic)`, () => {
|
|
34
|
+
for(let id in ConditionsV1){
|
|
35
|
+
it(`Parsing conditions for option id ${id}`, async () => {
|
|
36
|
+
let parsedCondition = new Parser(ConditionsV1[id]).getLogic();
|
|
37
|
+
expect(parsedCondition).toStrictEqual( ConditionsV3[id] )
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { References } from "../lib/index"
|
|
2
|
+
import fs from "fs"
|
|
3
|
+
|
|
4
|
+
// Getting & Parsing model & expected refs
|
|
5
|
+
let ExpectedModelV3 = JSON.parse(fs.readFileSync("./tests/misc/expected-model-v3.json", "UTF-8"))
|
|
6
|
+
let RefsModelV3 = JSON.parse(fs.readFileSync("./tests/misc/refs-model-v3.json", "UTF-8"))
|
|
7
|
+
|
|
8
|
+
// Initiating refs
|
|
9
|
+
beforeAll(() => {
|
|
10
|
+
References.setRefs(ExpectedModelV3.documents.main.sections, ExpectedModelV3.options, ExpectedModelV3.variables);
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
// Running tests on parentsTree
|
|
14
|
+
test('Testing parentsTree', async () => {
|
|
15
|
+
expect(References.getParentsTree()).toStrictEqual(RefsModelV3.parentsTree)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
// Running tests on conditionnedOptions
|
|
19
|
+
test('Testing conditionnedOptions', async () => {
|
|
20
|
+
expect(References.getConditionnedOptions()).toStrictEqual(RefsModelV3.conditionnedOptions)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
// Running tests on multiplesDependencies
|
|
24
|
+
test('Testing multiplesDependencies', async () => {
|
|
25
|
+
expect(References.getMultiplesDependencies()).toStrictEqual(RefsModelV3.multiplesDependencies)
|
|
26
|
+
})
|