definition-generator-framework 1.12.5 → 1.12.7
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/framework/definition-component.d.ts +11 -9
- package/dist/framework/definition-component.js +18 -18
- package/dist/framework/definition-generator.d.ts +6 -5
- package/dist/framework/definition-generator.js +16 -18
- package/dist/framework/file-content-generator/file-content-generator.js +1 -1
- package/dist/framework/file-content-generator/file-content-generator.test.js +49 -49
- package/dist/framework/framework.d.ts +14 -13
- package/dist/framework/framework.data.d.ts +3 -3
- package/dist/framework/framework.data.js +13 -7
- package/dist/framework/framework.js +36 -33
- package/dist/framework/framework.model.d.ts +15 -15
- package/dist/framework/framework.model.js +3 -3
- package/dist/framework/index-file-generator/index-file-generator.js +2 -4
- package/dist/helpers/common-functions/common-functions.js +1 -1
- package/dist/helpers/common-functions/common-functions.spec.js +48 -48
- package/dist/helpers/duplicate-helper/duplicate-helper.spec.js +52 -52
- package/dist/helpers/output-helper/output-helper.d.ts +26 -26
- package/dist/helpers/output-helper/output-helper.js +127 -107
- package/dist/helpers/output-helper/output-helper.spec.d.ts +22 -22
- package/dist/helpers/output-helper/output-helper.spec.js +223 -211
- package/dist/helpers/output-helper/output-helper.test.d.ts +22 -22
- package/dist/helpers/output-helper/output-helper.test.js +224 -212
- package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js +133 -125
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.d.ts +1 -1
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js +174 -156
- package/dist/helpers/validator/custom-validators/image.custom-validator.d.ts +6 -6
- package/dist/helpers/validator/custom-validators/image.custom-validator.js +40 -39
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.d.ts +4 -4
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js +29 -29
- package/dist/helpers/validator/joi-custom-validators.spec.js +284 -240
- package/dist/helpers/validator/validator.spec.js +313 -303
- package/dist/pipeline/1-select-definitions-helper.d.ts +13 -13
- package/dist/pipeline/1-select-definitions-helper.js +68 -72
- package/dist/pipeline/1-select-definitions.helper.test.js +40 -40
- package/dist/pipeline/1-select-definitions.spec.js +131 -131
- package/dist/pipeline/2-structure-parser.helper.spec.js +266 -266
- package/dist/pipeline/parsers/array-parser.spec.js +116 -113
- package/dist/pipeline/parsers/object-parser.spec.js +159 -153
- package/dist/pipeline/parsers/primitive-parser.spec.js +67 -67
- package/dist/pre-made-components/assets/3-font.js +4 -4
- package/dist/pre-made-components/events/1-event.d.ts +1 -1
- package/dist/pre-made-components/events/1-event.js +157 -125
- package/dist/pre-made-components/events/2-event-test.d.ts +8 -8
- package/dist/pre-made-components/events/2-event-test.js +156 -119
- package/dist/pre-made-components/events/2-script-test.js +0 -1
- package/dist/pre-made-components/events/event-setup.d.ts +10 -5
- package/dist/pre-made-components/events/event-setup.js +15 -15
- package/dist/pre-made-components/events/script-setup.d.ts +5 -3
- package/dist/pre-made-components/events/script-setup.js +11 -11
- package/package.json +5 -10
|
@@ -1,280 +1,280 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
const _2_structure_parser_helper_1 = require(
|
|
4
|
-
const mocks_1 = require(
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
const _2_structure_parser_helper_1 = require('./2-structure-parser.helper');
|
|
4
|
+
const mocks_1 = require('../_mocks/mocks');
|
|
5
5
|
function getMockDefinitionPlaneText(content) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
return {
|
|
7
|
+
type: 'ASSET',
|
|
8
|
+
content,
|
|
9
|
+
location: mocks_1.SampleLocation1
|
|
10
|
+
};
|
|
11
11
|
}
|
|
12
12
|
function getBaseRawDefinition(definitionPlaneText, parsedStructure) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
return {
|
|
14
|
+
componentName: definitionPlaneText.type,
|
|
15
|
+
location: definitionPlaneText.location,
|
|
16
|
+
parsedStructure: parsedStructure
|
|
17
|
+
};
|
|
18
18
|
}
|
|
19
19
|
function getExpectedRawDefinition(expected, offset, definitionPlaneText) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
let rawDefinition = getBaseRawDefinition(definitionPlaneText, {
|
|
21
|
+
rawData: expected,
|
|
22
|
+
line: definitionPlaneText.location.line + offset
|
|
23
|
+
});
|
|
24
|
+
return rawDefinition;
|
|
25
25
|
}
|
|
26
26
|
describe('STRUCTURE PARSER HELPER', () => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
let structureParserHelper;
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
structureParserHelper = new _2_structure_parser_helper_1.StructureParserHelper();
|
|
30
|
+
});
|
|
31
|
+
describe('Primitive', () => {
|
|
32
|
+
test('empty content', () => {
|
|
33
|
+
let definitionPlaneText = getMockDefinitionPlaneText([]);
|
|
34
|
+
let result = structureParserHelper.process([definitionPlaneText]);
|
|
35
|
+
expect(result.rawDefinitions).toStrictEqual([]);
|
|
36
|
+
expect(result.errorLogs).toStrictEqual([]);
|
|
30
37
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
37
|
-
});
|
|
38
|
-
test('primitive string', () => {
|
|
39
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['text']);
|
|
40
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
41
|
-
expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('text', 1, definitionPlaneText)]);
|
|
42
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
43
|
-
});
|
|
44
|
-
test('primitive quoted string', () => {
|
|
45
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['"text with spaces"']);
|
|
46
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
47
|
-
expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('text with spaces', 1, definitionPlaneText)]);
|
|
48
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
49
|
-
});
|
|
50
|
-
it('primitive multiline string', () => {
|
|
51
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['`', 'text text', 'text', '`']);
|
|
52
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
53
|
-
expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('text text\ntext', 1, definitionPlaneText)]);
|
|
54
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
55
|
-
});
|
|
56
|
-
test('primitive number', () => {
|
|
57
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['123.123']);
|
|
58
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
59
|
-
expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('123.123', 1, definitionPlaneText)]);
|
|
60
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
61
|
-
});
|
|
62
|
-
test('primitive negative number', () => {
|
|
63
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['-123.123']);
|
|
64
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
65
|
-
expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('-123.123', 1, definitionPlaneText)]);
|
|
66
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
67
|
-
});
|
|
68
|
-
test('primitive undefined', () => {
|
|
69
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['undefined']);
|
|
70
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
71
|
-
expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition(undefined, 1, definitionPlaneText)]);
|
|
72
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
73
|
-
});
|
|
38
|
+
test('primitive string', () => {
|
|
39
|
+
let definitionPlaneText = getMockDefinitionPlaneText(['text']);
|
|
40
|
+
let result = structureParserHelper.process([definitionPlaneText]);
|
|
41
|
+
expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('text', 1, definitionPlaneText)]);
|
|
42
|
+
expect(result.errorLogs).toStrictEqual([]);
|
|
74
43
|
});
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
line: definitionPlaneText.location.line + 1,
|
|
81
|
-
rawData: [
|
|
82
|
-
{
|
|
83
|
-
line: definitionPlaneText.location.line + 1,
|
|
84
|
-
rawData: 'orange'
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
line: definitionPlaneText.location.line + 2,
|
|
88
|
-
rawData: 'banana'
|
|
89
|
-
}
|
|
90
|
-
]
|
|
91
|
-
});
|
|
92
|
-
expect(result.rawDefinitions).toStrictEqual([expectedStructure]);
|
|
93
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
94
|
-
});
|
|
95
|
-
it('array contains array', () => {
|
|
96
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['- - orange', ' - banana', '- - 1', ' - 2']);
|
|
97
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
98
|
-
let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
|
|
99
|
-
line: definitionPlaneText.location.line + 1,
|
|
100
|
-
rawData: [
|
|
101
|
-
{
|
|
102
|
-
line: definitionPlaneText.location.line + 1,
|
|
103
|
-
rawData: [
|
|
104
|
-
{
|
|
105
|
-
line: definitionPlaneText.location.line + 1,
|
|
106
|
-
rawData: 'orange'
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
line: definitionPlaneText.location.line + 2,
|
|
110
|
-
rawData: 'banana'
|
|
111
|
-
}
|
|
112
|
-
]
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
line: definitionPlaneText.location.line + 3,
|
|
116
|
-
rawData: [
|
|
117
|
-
{
|
|
118
|
-
line: definitionPlaneText.location.line + 3,
|
|
119
|
-
rawData: '1'
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
line: definitionPlaneText.location.line + 4,
|
|
123
|
-
rawData: '2'
|
|
124
|
-
}
|
|
125
|
-
]
|
|
126
|
-
}
|
|
127
|
-
]
|
|
128
|
-
});
|
|
129
|
-
expect(result.rawDefinitions).toStrictEqual([expectedStructure]);
|
|
130
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
131
|
-
});
|
|
132
|
-
it('array contains object', () => {
|
|
133
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['- Name: arrow', ' Quantity: 4', '- Name: axe', ' Quantity: 1']);
|
|
134
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
135
|
-
let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
|
|
136
|
-
line: definitionPlaneText.location.line + 1,
|
|
137
|
-
rawData: [
|
|
138
|
-
{
|
|
139
|
-
line: definitionPlaneText.location.line + 1,
|
|
140
|
-
rawData: {
|
|
141
|
-
name: {
|
|
142
|
-
line: definitionPlaneText.location.line + 1,
|
|
143
|
-
rawData: 'arrow'
|
|
144
|
-
},
|
|
145
|
-
quantity: {
|
|
146
|
-
line: definitionPlaneText.location.line + 2,
|
|
147
|
-
rawData: '4'
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
line: definitionPlaneText.location.line + 3,
|
|
153
|
-
rawData: {
|
|
154
|
-
name: {
|
|
155
|
-
line: definitionPlaneText.location.line + 3,
|
|
156
|
-
rawData: 'axe'
|
|
157
|
-
},
|
|
158
|
-
quantity: {
|
|
159
|
-
line: definitionPlaneText.location.line + 4,
|
|
160
|
-
rawData: '1'
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
]
|
|
165
|
-
});
|
|
166
|
-
expect(result.rawDefinitions).toStrictEqual([expectedStructure]);
|
|
167
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
168
|
-
});
|
|
44
|
+
test('primitive quoted string', () => {
|
|
45
|
+
let definitionPlaneText = getMockDefinitionPlaneText(['"text with spaces"']);
|
|
46
|
+
let result = structureParserHelper.process([definitionPlaneText]);
|
|
47
|
+
expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('text with spaces', 1, definitionPlaneText)]);
|
|
48
|
+
expect(result.errorLogs).toStrictEqual([]);
|
|
169
49
|
});
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
50
|
+
it('primitive multiline string', () => {
|
|
51
|
+
let definitionPlaneText = getMockDefinitionPlaneText(['`', 'text text', 'text', '`']);
|
|
52
|
+
let result = structureParserHelper.process([definitionPlaneText]);
|
|
53
|
+
expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('text text\ntext', 1, definitionPlaneText)]);
|
|
54
|
+
expect(result.errorLogs).toStrictEqual([]);
|
|
55
|
+
});
|
|
56
|
+
test('primitive number', () => {
|
|
57
|
+
let definitionPlaneText = getMockDefinitionPlaneText(['123.123']);
|
|
58
|
+
let result = structureParserHelper.process([definitionPlaneText]);
|
|
59
|
+
expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('123.123', 1, definitionPlaneText)]);
|
|
60
|
+
expect(result.errorLogs).toStrictEqual([]);
|
|
61
|
+
});
|
|
62
|
+
test('primitive negative number', () => {
|
|
63
|
+
let definitionPlaneText = getMockDefinitionPlaneText(['-123.123']);
|
|
64
|
+
let result = structureParserHelper.process([definitionPlaneText]);
|
|
65
|
+
expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('-123.123', 1, definitionPlaneText)]);
|
|
66
|
+
expect(result.errorLogs).toStrictEqual([]);
|
|
67
|
+
});
|
|
68
|
+
test('primitive undefined', () => {
|
|
69
|
+
let definitionPlaneText = getMockDefinitionPlaneText(['undefined']);
|
|
70
|
+
let result = structureParserHelper.process([definitionPlaneText]);
|
|
71
|
+
expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition(undefined, 1, definitionPlaneText)]);
|
|
72
|
+
expect(result.errorLogs).toStrictEqual([]);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
describe('Array', () => {
|
|
76
|
+
it('basic', () => {
|
|
77
|
+
let definitionPlaneText = getMockDefinitionPlaneText(['- orange', '- banana']);
|
|
78
|
+
let result = structureParserHelper.process([definitionPlaneText]);
|
|
79
|
+
let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
|
|
80
|
+
line: definitionPlaneText.location.line + 1,
|
|
81
|
+
rawData: [
|
|
82
|
+
{
|
|
83
|
+
line: definitionPlaneText.location.line + 1,
|
|
84
|
+
rawData: 'orange'
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
line: definitionPlaneText.location.line + 2,
|
|
88
|
+
rawData: 'banana'
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
});
|
|
92
|
+
expect(result.rawDefinitions).toStrictEqual([expectedStructure]);
|
|
93
|
+
expect(result.errorLogs).toStrictEqual([]);
|
|
94
|
+
});
|
|
95
|
+
it('array contains array', () => {
|
|
96
|
+
let definitionPlaneText = getMockDefinitionPlaneText(['- - orange', ' - banana', '- - 1', ' - 2']);
|
|
97
|
+
let result = structureParserHelper.process([definitionPlaneText]);
|
|
98
|
+
let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
|
|
99
|
+
line: definitionPlaneText.location.line + 1,
|
|
100
|
+
rawData: [
|
|
101
|
+
{
|
|
102
|
+
line: definitionPlaneText.location.line + 1,
|
|
103
|
+
rawData: [
|
|
104
|
+
{
|
|
201
105
|
line: definitionPlaneText.location.line + 1,
|
|
202
|
-
rawData:
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
'- orange',
|
|
239
|
-
'Array2:',
|
|
240
|
-
'- xWing',
|
|
241
|
-
'- tieFighter'
|
|
242
|
-
]);
|
|
243
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
244
|
-
let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
|
|
106
|
+
rawData: 'orange'
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
line: definitionPlaneText.location.line + 2,
|
|
110
|
+
rawData: 'banana'
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
line: definitionPlaneText.location.line + 3,
|
|
116
|
+
rawData: [
|
|
117
|
+
{
|
|
118
|
+
line: definitionPlaneText.location.line + 3,
|
|
119
|
+
rawData: '1'
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
line: definitionPlaneText.location.line + 4,
|
|
123
|
+
rawData: '2'
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
});
|
|
129
|
+
expect(result.rawDefinitions).toStrictEqual([expectedStructure]);
|
|
130
|
+
expect(result.errorLogs).toStrictEqual([]);
|
|
131
|
+
});
|
|
132
|
+
it('array contains object', () => {
|
|
133
|
+
let definitionPlaneText = getMockDefinitionPlaneText(['- Name: arrow', ' Quantity: 4', '- Name: axe', ' Quantity: 1']);
|
|
134
|
+
let result = structureParserHelper.process([definitionPlaneText]);
|
|
135
|
+
let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
|
|
136
|
+
line: definitionPlaneText.location.line + 1,
|
|
137
|
+
rawData: [
|
|
138
|
+
{
|
|
139
|
+
line: definitionPlaneText.location.line + 1,
|
|
140
|
+
rawData: {
|
|
141
|
+
name: {
|
|
245
142
|
line: definitionPlaneText.location.line + 1,
|
|
246
|
-
rawData:
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
143
|
+
rawData: 'arrow'
|
|
144
|
+
},
|
|
145
|
+
quantity: {
|
|
146
|
+
line: definitionPlaneText.location.line + 2,
|
|
147
|
+
rawData: '4'
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
line: definitionPlaneText.location.line + 3,
|
|
153
|
+
rawData: {
|
|
154
|
+
name: {
|
|
155
|
+
line: definitionPlaneText.location.line + 3,
|
|
156
|
+
rawData: 'axe'
|
|
157
|
+
},
|
|
158
|
+
quantity: {
|
|
159
|
+
line: definitionPlaneText.location.line + 4,
|
|
160
|
+
rawData: '1'
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
]
|
|
165
|
+
});
|
|
166
|
+
expect(result.rawDefinitions).toStrictEqual([expectedStructure]);
|
|
167
|
+
expect(result.errorLogs).toStrictEqual([]);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
describe('Object', () => {
|
|
171
|
+
it('basic', () => {
|
|
172
|
+
let definitionPlaneText = getMockDefinitionPlaneText(['Name: axe', 'Quantity: 1']);
|
|
173
|
+
let result = structureParserHelper.process([definitionPlaneText]);
|
|
174
|
+
let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
|
|
175
|
+
line: definitionPlaneText.location.line + 1,
|
|
176
|
+
rawData: {
|
|
177
|
+
name: {
|
|
178
|
+
line: definitionPlaneText.location.line + 1,
|
|
179
|
+
rawData: 'axe'
|
|
180
|
+
},
|
|
181
|
+
quantity: {
|
|
182
|
+
line: definitionPlaneText.location.line + 2,
|
|
183
|
+
rawData: '1'
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
expect(result.rawDefinitions).toStrictEqual([expectedStructure]);
|
|
188
|
+
expect(result.errorLogs).toStrictEqual([]);
|
|
189
|
+
});
|
|
190
|
+
it('object contains object', () => {
|
|
191
|
+
let definitionPlaneText = getMockDefinitionPlaneText([
|
|
192
|
+
'Attacker:',
|
|
193
|
+
' Name: firstObjectName',
|
|
194
|
+
' Age: 25',
|
|
195
|
+
'Defender:',
|
|
196
|
+
' Name: secondObjectName',
|
|
197
|
+
' Age: 35'
|
|
198
|
+
]);
|
|
199
|
+
let result = structureParserHelper.process([definitionPlaneText]);
|
|
200
|
+
let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
|
|
201
|
+
line: definitionPlaneText.location.line + 1,
|
|
202
|
+
rawData: {
|
|
203
|
+
attacker: {
|
|
204
|
+
line: definitionPlaneText.location.line + 1,
|
|
205
|
+
rawData: {
|
|
206
|
+
name: {
|
|
207
|
+
line: definitionPlaneText.location.line + 2,
|
|
208
|
+
rawData: 'firstObjectName'
|
|
209
|
+
},
|
|
210
|
+
age: {
|
|
211
|
+
line: definitionPlaneText.location.line + 3,
|
|
212
|
+
rawData: '25'
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
defender: {
|
|
217
|
+
line: definitionPlaneText.location.line + 4,
|
|
218
|
+
rawData: {
|
|
219
|
+
name: {
|
|
220
|
+
line: definitionPlaneText.location.line + 5,
|
|
221
|
+
rawData: 'secondObjectName'
|
|
222
|
+
},
|
|
223
|
+
age: {
|
|
224
|
+
line: definitionPlaneText.location.line + 6,
|
|
225
|
+
rawData: '35'
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
expect(result.rawDefinitions).toStrictEqual([expectedStructure]);
|
|
232
|
+
expect(result.errorLogs).toStrictEqual([]);
|
|
233
|
+
});
|
|
234
|
+
it('object contains array', () => {
|
|
235
|
+
let definitionPlaneText = getMockDefinitionPlaneText([
|
|
236
|
+
'Array1:',
|
|
237
|
+
'- apple',
|
|
238
|
+
'- orange',
|
|
239
|
+
'Array2:',
|
|
240
|
+
'- xWing',
|
|
241
|
+
'- tieFighter'
|
|
242
|
+
]);
|
|
243
|
+
let result = structureParserHelper.process([definitionPlaneText]);
|
|
244
|
+
let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
|
|
245
|
+
line: definitionPlaneText.location.line + 1,
|
|
246
|
+
rawData: {
|
|
247
|
+
array1: {
|
|
248
|
+
line: definitionPlaneText.location.line + 1,
|
|
249
|
+
rawData: [
|
|
250
|
+
{
|
|
251
|
+
line: definitionPlaneText.location.line + 2,
|
|
252
|
+
rawData: 'apple'
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
line: definitionPlaneText.location.line + 3,
|
|
256
|
+
rawData: 'orange'
|
|
257
|
+
}
|
|
258
|
+
]
|
|
259
|
+
},
|
|
260
|
+
array2: {
|
|
261
|
+
line: definitionPlaneText.location.line + 4,
|
|
262
|
+
rawData: [
|
|
263
|
+
{
|
|
264
|
+
line: definitionPlaneText.location.line + 5,
|
|
265
|
+
rawData: 'xWing'
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
line: definitionPlaneText.location.line + 6,
|
|
269
|
+
rawData: 'tieFighter'
|
|
270
|
+
}
|
|
271
|
+
]
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
expect(result.rawDefinitions).toStrictEqual([expectedStructure]);
|
|
276
|
+
expect(result.errorLogs).toStrictEqual([]);
|
|
278
277
|
});
|
|
278
|
+
});
|
|
279
279
|
});
|
|
280
|
-
//# sourceMappingURL=2-structure-parser.helper.spec.js.map
|
|
280
|
+
//# sourceMappingURL=2-structure-parser.helper.spec.js.map
|