definition-generator-framework 1.12.3 → 1.12.5

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.
Files changed (151) hide show
  1. package/dist/helpers/common-functions/common-functions.spec.d.ts +1 -0
  2. package/dist/helpers/common-functions/common-functions.spec.js +50 -0
  3. package/dist/helpers/duplicate-helper/duplicate-helper.spec.d.ts +1 -0
  4. package/dist/helpers/duplicate-helper/duplicate-helper.spec.js +54 -0
  5. package/dist/helpers/output-helper/output-helper.spec.d.ts +24 -0
  6. package/dist/helpers/output-helper/output-helper.spec.js +249 -0
  7. package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.d.ts +1 -0
  8. package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js +135 -0
  9. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.d.ts +1 -0
  10. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js +173 -0
  11. package/dist/helpers/validator/joi-custom-validators.spec.d.ts +1 -0
  12. package/dist/helpers/validator/joi-custom-validators.spec.js +260 -0
  13. package/dist/helpers/validator/validator.spec.d.ts +1 -0
  14. package/dist/helpers/validator/validator.spec.js +322 -0
  15. package/dist/pipeline/1-select-definitions.spec.d.ts +1 -0
  16. package/dist/pipeline/1-select-definitions.spec.js +140 -0
  17. package/dist/pipeline/2-structure-parser.helper.spec.d.ts +1 -0
  18. package/dist/pipeline/2-structure-parser.helper.spec.js +280 -0
  19. package/dist/pipeline/parsers/array-parser.spec.d.ts +1 -0
  20. package/dist/pipeline/parsers/array-parser.spec.js +125 -0
  21. package/dist/pipeline/parsers/object-parser.spec.d.ts +1 -0
  22. package/dist/pipeline/parsers/object-parser.spec.js +173 -0
  23. package/dist/pipeline/parsers/primitive-parser.spec.d.ts +1 -0
  24. package/dist/pipeline/parsers/primitive-parser.spec.js +79 -0
  25. package/package.json +8 -3
  26. package/.eslintrc.js +0 -212
  27. package/.vscode/launch.json +0 -15
  28. package/.vscode/settings.json +0 -25
  29. package/coverage/clover.xml +0 -503
  30. package/coverage/coverage-final.json +0 -16
  31. package/coverage/lcov-report/_mocks/index.html +0 -116
  32. package/coverage/lcov-report/_mocks/mocks.ts.html +0 -223
  33. package/coverage/lcov-report/base.css +0 -224
  34. package/coverage/lcov-report/block-navigation.js +0 -87
  35. package/coverage/lcov-report/favicon.png +0 -0
  36. package/coverage/lcov-report/framework/framework.data.ts.html +0 -109
  37. package/coverage/lcov-report/framework/index.html +0 -116
  38. package/coverage/lcov-report/helpers/common-functions/common-functions.ts.html +0 -178
  39. package/coverage/lcov-report/helpers/common-functions/index.html +0 -116
  40. package/coverage/lcov-report/helpers/duplicate-helper/duplicate-helper.ts.html +0 -196
  41. package/coverage/lcov-report/helpers/duplicate-helper/index.html +0 -116
  42. package/coverage/lcov-report/helpers/output-helper/index.html +0 -116
  43. package/coverage/lcov-report/helpers/output-helper/output-helper.ts.html +0 -277
  44. package/coverage/lcov-report/helpers/raw-definition-helper/index.html +0 -116
  45. package/coverage/lcov-report/helpers/raw-definition-helper/raw-definition.helper.ts.html +0 -256
  46. package/coverage/lcov-report/helpers/validator/index.html +0 -131
  47. package/coverage/lcov-report/helpers/validator/joi-custom-validators.ts.html +0 -643
  48. package/coverage/lcov-report/helpers/validator/validator.ts.html +0 -310
  49. package/coverage/lcov-report/index.html +0 -251
  50. package/coverage/lcov-report/pipeline/1-select-definitions-helper.ts.html +0 -358
  51. package/coverage/lcov-report/pipeline/2-structure-parser.helper.ts.html +0 -301
  52. package/coverage/lcov-report/pipeline/3-config.ts.html +0 -178
  53. package/coverage/lcov-report/pipeline/_mocks/index.html +0 -116
  54. package/coverage/lcov-report/pipeline/_mocks/index.ts.html +0 -229
  55. package/coverage/lcov-report/pipeline/index.html +0 -146
  56. package/coverage/lcov-report/pipeline/parsers/array-parser.ts.html +0 -271
  57. package/coverage/lcov-report/pipeline/parsers/index.html +0 -146
  58. package/coverage/lcov-report/pipeline/parsers/object-parser.ts.html +0 -439
  59. package/coverage/lcov-report/pipeline/parsers/primitive-parser.ts.html +0 -370
  60. package/coverage/lcov-report/prettify.css +0 -1
  61. package/coverage/lcov-report/prettify.js +0 -2
  62. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  63. package/coverage/lcov-report/sorter.js +0 -196
  64. package/coverage/lcov.info +0 -911
  65. package/dist/_mocks/mocks.js.map +0 -1
  66. package/dist/decorators/definition-component.js.map +0 -1
  67. package/dist/decorators/definition-generator.js.map +0 -1
  68. package/dist/framework/context.js.map +0 -1
  69. package/dist/framework/definition-component.js.map +0 -1
  70. package/dist/framework/definition-generator.js.map +0 -1
  71. package/dist/framework/definition-store.js.map +0 -1
  72. package/dist/framework/file-content-generator/file-content-generator.js.map +0 -1
  73. package/dist/framework/file-content-generator/file-content-generator.test.js.map +0 -1
  74. package/dist/framework/framework.data.js.map +0 -1
  75. package/dist/framework/framework.js.map +0 -1
  76. package/dist/framework/framework.model.js.map +0 -1
  77. package/dist/framework/index-file-generator/index-file-generator.js.map +0 -1
  78. package/dist/framework/interfaces.js.map +0 -1
  79. package/dist/framework/kernel.js.map +0 -1
  80. package/dist/helpers/common-functions/common-functions.js.map +0 -1
  81. package/dist/helpers/common-functions/common-functions.spec.js.map +0 -1
  82. package/dist/helpers/common-functions/common-functions.test.js.map +0 -1
  83. package/dist/helpers/duplicate-helper/duplicate-helper.js.map +0 -1
  84. package/dist/helpers/duplicate-helper/duplicate-helper.spec.js.map +0 -1
  85. package/dist/helpers/duplicate-helper/duplicate-helper.test.js.map +0 -1
  86. package/dist/helpers/output-helper/output-helper.js.map +0 -1
  87. package/dist/helpers/output-helper/output-helper.spec.js.map +0 -1
  88. package/dist/helpers/output-helper/output-helper.test.js.map +0 -1
  89. package/dist/helpers/raw-definition-helper/raw-definition.helper.js.map +0 -1
  90. package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js.map +0 -1
  91. package/dist/helpers/raw-definition-helper/raw-definition.helper.test.js.map +0 -1
  92. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.js.map +0 -1
  93. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js.map +0 -1
  94. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.test.js.map +0 -1
  95. package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.js.map +0 -1
  96. package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.test.js.map +0 -1
  97. package/dist/helpers/validator/custom-validators/image.custom-validator.js.map +0 -1
  98. package/dist/helpers/validator/custom-validators/path.custom-validator.js.map +0 -1
  99. package/dist/helpers/validator/custom-validators/position-on-sprite.js.map +0 -1
  100. package/dist/helpers/validator/custom-validators/reference.custom-validator.js.map +0 -1
  101. package/dist/helpers/validator/custom-validators/sprite.custom-validator.js.map +0 -1
  102. package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js.map +0 -1
  103. package/dist/helpers/validator/custom-validators/unique.custom-validator.js.map +0 -1
  104. package/dist/helpers/validator/joi-custom-validators.js.map +0 -1
  105. package/dist/helpers/validator/joi-custom-validators.spec.js.map +0 -1
  106. package/dist/helpers/validator/validator.js.map +0 -1
  107. package/dist/helpers/validator/validator.spec.js.map +0 -1
  108. package/dist/helpers/validator/validator.test.js.map +0 -1
  109. package/dist/index.js.map +0 -1
  110. package/dist/pipeline/1-select-definitions-helper.js.map +0 -1
  111. package/dist/pipeline/1-select-definitions.helper.js.map +0 -1
  112. package/dist/pipeline/1-select-definitions.helper.test.js.map +0 -1
  113. package/dist/pipeline/1-select-definitions.spec.js.map +0 -1
  114. package/dist/pipeline/2-structure-parser.helper.js.map +0 -1
  115. package/dist/pipeline/2-structure-parser.helper.spec.js.map +0 -1
  116. package/dist/pipeline/2-structure-parser.helper.test.js.map +0 -1
  117. package/dist/pipeline/3-config.js.map +0 -1
  118. package/dist/pipeline/_mocks/index.js.map +0 -1
  119. package/dist/pipeline/parsers/array-parser.js.map +0 -1
  120. package/dist/pipeline/parsers/array-parser.spec.js.map +0 -1
  121. package/dist/pipeline/parsers/array-parser.test.js.map +0 -1
  122. package/dist/pipeline/parsers/object-parser.js.map +0 -1
  123. package/dist/pipeline/parsers/object-parser.spec.js.map +0 -1
  124. package/dist/pipeline/parsers/object-parser.test.js.map +0 -1
  125. package/dist/pipeline/parsers/primitive-parser.js.map +0 -1
  126. package/dist/pipeline/parsers/primitive-parser.spec.js.map +0 -1
  127. package/dist/pipeline/parsers/primitive-parser.test.js.map +0 -1
  128. package/dist/pipeline/raw-data-parser.js.map +0 -1
  129. package/dist/pre-made-components/_validators/shape-validators.js.map +0 -1
  130. package/dist/pre-made-components/_validators/sprite-validators.js.map +0 -1
  131. package/dist/pre-made-components/assets/1-sprite.js.map +0 -1
  132. package/dist/pre-made-components/assets/2-sprite-group.js.map +0 -1
  133. package/dist/pre-made-components/assets/3-font.js.map +0 -1
  134. package/dist/pre-made-components/events/1-event.js.map +0 -1
  135. package/dist/pre-made-components/events/1-script.js.map +0 -1
  136. package/dist/pre-made-components/events/2-event-test.js.map +0 -1
  137. package/dist/pre-made-components/events/2-script-test.js.map +0 -1
  138. package/dist/pre-made-components/events/3-event.js.map +0 -1
  139. package/dist/pre-made-components/events/4-event-test.js.map +0 -1
  140. package/dist/pre-made-components/events/event-setup.js.map +0 -1
  141. package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.js.map +0 -1
  142. package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.test.js.map +0 -1
  143. package/dist/pre-made-components/events/helpers/script-testing.helper.js.map +0 -1
  144. package/dist/pre-made-components/events/script-setup.js.map +0 -1
  145. package/dist/pre-made-components/events/scripting-setup.js.map +0 -1
  146. package/dist/pre-made-components/events/validators.js.map +0 -1
  147. package/dist/setup.js.map +0 -1
  148. package/package.json.bak +0 -60
  149. package/scripts/prepare-package-json.ts +0 -23
  150. package/tsconfig.json +0 -24
  151. package/vitest.config.ts +0 -1
@@ -0,0 +1,280 @@
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
+ function getMockDefinitionPlaneText(content) {
6
+ return {
7
+ type: 'ASSET',
8
+ content,
9
+ location: mocks_1.SampleLocation1
10
+ };
11
+ }
12
+ function getBaseRawDefinition(definitionPlaneText, parsedStructure) {
13
+ return {
14
+ componentName: definitionPlaneText.type,
15
+ location: definitionPlaneText.location,
16
+ parsedStructure: parsedStructure
17
+ };
18
+ }
19
+ function getExpectedRawDefinition(expected, offset, definitionPlaneText) {
20
+ let rawDefinition = getBaseRawDefinition(definitionPlaneText, {
21
+ rawData: expected,
22
+ line: definitionPlaneText.location.line + offset
23
+ });
24
+ return rawDefinition;
25
+ }
26
+ describe('STRUCTURE PARSER HELPER', () => {
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([]);
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
+ });
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
+ {
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
+ });
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([]);
277
+ });
278
+ });
279
+ });
280
+ //# sourceMappingURL=2-structure-parser.helper.spec.js.map
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const _mocks_1 = require("../_mocks");
4
+ const array_parser_1 = require("./array-parser");
5
+ const mocks_1 = require("../../_mocks/mocks");
6
+ describe('ARRAY PARSER', () => {
7
+ test('basic', () => {
8
+ let result = array_parser_1.ArrayParser.parse(['- orange', '- banana'], mocks_1.SampleLocation1);
9
+ expect(result).toStrictEqual({
10
+ line: mocks_1.SampleLocation1.line,
11
+ rawData: [
12
+ {
13
+ line: mocks_1.SampleLocation1.line,
14
+ rawData: 'orange'
15
+ },
16
+ {
17
+ line: mocks_1.SampleLocation1.line + 1,
18
+ rawData: 'banana'
19
+ }
20
+ ]
21
+ });
22
+ });
23
+ test('array contains array', () => {
24
+ let result = array_parser_1.ArrayParser.parse(['- - orange', ' - banana', '- - 1', ' - 2'], mocks_1.SampleLocation1);
25
+ expect(result).toStrictEqual({
26
+ line: mocks_1.SampleLocation1.line,
27
+ rawData: [
28
+ {
29
+ line: mocks_1.SampleLocation1.line,
30
+ rawData: [
31
+ {
32
+ line: mocks_1.SampleLocation1.line,
33
+ rawData: 'orange'
34
+ },
35
+ {
36
+ line: mocks_1.SampleLocation1.line + 1,
37
+ rawData: 'banana'
38
+ }
39
+ ]
40
+ },
41
+ {
42
+ line: mocks_1.SampleLocation1.line + 2,
43
+ rawData: [
44
+ {
45
+ line: mocks_1.SampleLocation1.line + 2,
46
+ rawData: '1'
47
+ },
48
+ {
49
+ line: mocks_1.SampleLocation1.line + 3,
50
+ rawData: '2'
51
+ }
52
+ ]
53
+ }
54
+ ]
55
+ });
56
+ });
57
+ test('array contains object', () => {
58
+ let result = array_parser_1.ArrayParser.parse(['- Name: arrow', ' Quantity: 4', '- Name: axe', ' Quantity: 1'], mocks_1.SampleLocation1);
59
+ expect(result).toStrictEqual({
60
+ line: mocks_1.SampleLocation1.line,
61
+ rawData: [
62
+ {
63
+ line: mocks_1.SampleLocation1.line,
64
+ rawData: {
65
+ name: {
66
+ line: mocks_1.SampleLocation1.line,
67
+ rawData: 'arrow'
68
+ },
69
+ quantity: {
70
+ line: mocks_1.SampleLocation1.line + 1,
71
+ rawData: '4'
72
+ }
73
+ }
74
+ },
75
+ {
76
+ line: mocks_1.SampleLocation1.line + 2,
77
+ rawData: {
78
+ name: {
79
+ line: mocks_1.SampleLocation1.line + 2,
80
+ rawData: 'axe'
81
+ },
82
+ quantity: {
83
+ line: mocks_1.SampleLocation1.line + 3,
84
+ rawData: '1'
85
+ }
86
+ }
87
+ }
88
+ ]
89
+ });
90
+ });
91
+ });
92
+ describe('ARRAY PARSER - Error Detection', () => {
93
+ let expectErrorHelper = new _mocks_1.ExpectErrorHelper(array_parser_1.ArrayParser);
94
+ test.each(['-text', '- text'])('one space after dash, first line "%s"', (item) => {
95
+ expectErrorHelper.expect([item], {
96
+ description: `There should be one space after dash operator! "${item}"`,
97
+ location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
98
+ });
99
+ });
100
+ test.each(['-text', '- text'])('one space after dash, second line "%s"', (item) => {
101
+ expectErrorHelper.expect(['- item', item], {
102
+ description: `There should be one space after dash operator! "${item}"`,
103
+ location: { line: mocks_1.SampleLocation1.line + 1, path: mocks_1.SampleLocation1.path }
104
+ });
105
+ });
106
+ test('unexpected array element', () => {
107
+ expectErrorHelper.expect(['- item', 'Name: axe'], {
108
+ description: `Unexpected array element! "Name: axe"`,
109
+ location: { line: mocks_1.SampleLocation1.line + 1, path: mocks_1.SampleLocation1.path }
110
+ });
111
+ });
112
+ test('invalid coding indent', () => {
113
+ expectErrorHelper.expect([' - item'], {
114
+ description: `Invalid coding indent!`,
115
+ location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
116
+ });
117
+ });
118
+ test('invalid coding indent', () => {
119
+ expectErrorHelper.expect([' - item'], {
120
+ description: `Invalid coding indent!`,
121
+ location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
122
+ });
123
+ });
124
+ });
125
+ //# sourceMappingURL=array-parser.spec.js.map
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const object_parser_1 = require("./object-parser");
4
+ const mocks_1 = require("../../_mocks/mocks");
5
+ const _mocks_1 = require("../_mocks");
6
+ describe('OBJECT PARSER', () => {
7
+ test('basic', () => {
8
+ let result = object_parser_1.ObjectParser.parse(['Name: axe', 'Quantity: 1'], mocks_1.SampleLocation1);
9
+ expect(result).toStrictEqual({
10
+ line: mocks_1.SampleLocation1.line,
11
+ rawData: {
12
+ name: {
13
+ line: mocks_1.SampleLocation1.line,
14
+ rawData: 'axe'
15
+ },
16
+ quantity: {
17
+ line: mocks_1.SampleLocation1.line + 1,
18
+ rawData: '1'
19
+ }
20
+ }
21
+ });
22
+ });
23
+ test('quote string value', () => {
24
+ let result = object_parser_1.ObjectParser.parse(['Path: "D:/test"'], mocks_1.SampleLocation1);
25
+ expect(result).toStrictEqual({
26
+ line: mocks_1.SampleLocation1.line,
27
+ rawData: {
28
+ path: {
29
+ line: mocks_1.SampleLocation1.line,
30
+ rawData: 'D:/test'
31
+ }
32
+ }
33
+ });
34
+ });
35
+ test('quote string value', () => {
36
+ let result = object_parser_1.ObjectParser.parse(['Str: `', 'text with space', 'text', '`'], mocks_1.SampleLocation1);
37
+ expect(result).toStrictEqual({
38
+ line: mocks_1.SampleLocation1.line,
39
+ rawData: {
40
+ str: {
41
+ line: mocks_1.SampleLocation1.line,
42
+ rawData: 'text with space\ntext'
43
+ }
44
+ }
45
+ });
46
+ });
47
+ test('object contains object', () => {
48
+ let result = object_parser_1.ObjectParser.parse(['Attacker:', ' Name: firstObjectName', ' Age: 25', 'Defender:', ' Name: secondObjectName', ' Age: 35'], mocks_1.SampleLocation1);
49
+ expect(result).toStrictEqual({
50
+ line: mocks_1.SampleLocation1.line,
51
+ rawData: {
52
+ attacker: {
53
+ line: mocks_1.SampleLocation1.line,
54
+ rawData: {
55
+ name: {
56
+ line: mocks_1.SampleLocation1.line + 1,
57
+ rawData: 'firstObjectName'
58
+ },
59
+ age: {
60
+ line: mocks_1.SampleLocation1.line + 2,
61
+ rawData: '25'
62
+ }
63
+ }
64
+ },
65
+ defender: {
66
+ line: mocks_1.SampleLocation1.line + 3,
67
+ rawData: {
68
+ name: {
69
+ line: mocks_1.SampleLocation1.line + 4,
70
+ rawData: 'secondObjectName'
71
+ },
72
+ age: {
73
+ line: mocks_1.SampleLocation1.line + 5,
74
+ rawData: '35'
75
+ }
76
+ }
77
+ }
78
+ }
79
+ });
80
+ });
81
+ test('object contains array', () => {
82
+ let result = object_parser_1.ObjectParser.parse(['Array1:', '- apple', '- orange', 'Array2:', '- xWing', '- tieFighter'], mocks_1.SampleLocation1);
83
+ expect(result).toStrictEqual({
84
+ line: mocks_1.SampleLocation1.line,
85
+ rawData: {
86
+ array1: {
87
+ line: mocks_1.SampleLocation1.line,
88
+ rawData: [
89
+ {
90
+ line: mocks_1.SampleLocation1.line + 1,
91
+ rawData: 'apple'
92
+ },
93
+ {
94
+ line: mocks_1.SampleLocation1.line + 2,
95
+ rawData: 'orange'
96
+ }
97
+ ]
98
+ },
99
+ array2: {
100
+ line: mocks_1.SampleLocation1.line + 3,
101
+ rawData: [
102
+ {
103
+ line: mocks_1.SampleLocation1.line + 4,
104
+ rawData: 'xWing'
105
+ },
106
+ {
107
+ line: mocks_1.SampleLocation1.line + 5,
108
+ rawData: 'tieFighter'
109
+ }
110
+ ]
111
+ }
112
+ }
113
+ });
114
+ });
115
+ });
116
+ describe('OBJECT PARSER - Error Detection', () => {
117
+ let expectErrorHelper = new _mocks_1.ExpectErrorHelper(object_parser_1.ObjectParser);
118
+ test.each(['Name:axe', 'Name: axe'])('one space after column, first line "%s"', (item) => {
119
+ expectErrorHelper.expect([item], {
120
+ description: `There should be one space after column operator! "${item}"`,
121
+ location: mocks_1.SampleLocation1
122
+ });
123
+ });
124
+ test('object cannot start with backtick', () => {
125
+ expectErrorHelper.expect(['`'], {
126
+ description: `Unexpected object element! "\`"`,
127
+ location: mocks_1.SampleLocation1
128
+ });
129
+ });
130
+ test('unexpected backtick', () => {
131
+ expectErrorHelper.expect(['Group:', '- item', '`'], {
132
+ description: `Unexpected object element! "\`"`,
133
+ location: { line: mocks_1.SampleLocation1.line + 2, path: mocks_1.SampleLocation1.path }
134
+ });
135
+ });
136
+ test.each(['Quantity:5', 'Quantity: 5'])('one space after column, second line "%s"', (item) => {
137
+ expectErrorHelper.expect(['Name: axe', item], {
138
+ description: `There should be one space after column operator! "${item}"`,
139
+ location: { line: mocks_1.SampleLocation1.line + 1, path: mocks_1.SampleLocation1.path }
140
+ });
141
+ });
142
+ test.each(['- apple', 'text'])('unexpected object element, "%s"', (item) => {
143
+ expectErrorHelper.expect([item], {
144
+ description: `Unexpected object element! "${item}"`,
145
+ location: mocks_1.SampleLocation1
146
+ });
147
+ });
148
+ test('multiple columns', () => {
149
+ expectErrorHelper.expect(['Name:something: axe'], {
150
+ description: `Invalid row, multiple columns! "Name:something: axe"`,
151
+ location: mocks_1.SampleLocation1
152
+ });
153
+ });
154
+ test('starting with column', () => {
155
+ expectErrorHelper.expect([':something: axe'], {
156
+ description: `Invalid row, row cannot start with columns! ":something: axe"`,
157
+ location: mocks_1.SampleLocation1
158
+ });
159
+ });
160
+ test.each([' Name: axe', ' Name: axe'])('invalid coding indent, "%s"', (item) => {
161
+ expectErrorHelper.expect([item], {
162
+ description: `Invalid coding indent! "${item}"`,
163
+ location: mocks_1.SampleLocation1
164
+ });
165
+ });
166
+ test('no value', () => {
167
+ expectErrorHelper.expect(['Name:'], {
168
+ description: `No value found after column! "Name:"`,
169
+ location: mocks_1.SampleLocation1
170
+ });
171
+ });
172
+ });
173
+ //# sourceMappingURL=object-parser.spec.js.map
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const primitive_parser_1 = require("./primitive-parser");
4
+ const _mocks_1 = require("../_mocks");
5
+ const mocks_1 = require("../../_mocks/mocks");
6
+ describe('PRIMITIVE PARSER', () => {
7
+ test('primitive string', () => {
8
+ let result = primitive_parser_1.PrimitiveParser.parse(['text'], mocks_1.SampleLocation1);
9
+ expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('text', mocks_1.SampleLocation1));
10
+ });
11
+ test('primitive quoted string', () => {
12
+ let result = primitive_parser_1.PrimitiveParser.parse(['"text with spaces"'], mocks_1.SampleLocation1);
13
+ expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('text with spaces', mocks_1.SampleLocation1));
14
+ });
15
+ test('primitive multiline string', () => {
16
+ let result = primitive_parser_1.PrimitiveParser.parse(['`', 'text text', 'text', '`'], mocks_1.SampleLocation1);
17
+ expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('text text\ntext', mocks_1.SampleLocation1));
18
+ });
19
+ test('primitive number', () => {
20
+ let result = primitive_parser_1.PrimitiveParser.parse(['123.123'], mocks_1.SampleLocation1);
21
+ expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('123.123', mocks_1.SampleLocation1));
22
+ });
23
+ test('primitive undefined', () => {
24
+ let result = primitive_parser_1.PrimitiveParser.parse(['undefined'], mocks_1.SampleLocation1);
25
+ expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)(undefined, mocks_1.SampleLocation1));
26
+ });
27
+ });
28
+ describe('PRIMITIVE PARSER - Error Detection', () => {
29
+ let expectErrorHelper = new _mocks_1.ExpectErrorHelper(primitive_parser_1.PrimitiveParser);
30
+ test.each([' text', 'some text'])('primitive with space "%s"', (item) => {
31
+ expectErrorHelper.expect([item], {
32
+ description: `Unexpected space! "${item}"`,
33
+ location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
34
+ });
35
+ });
36
+ test('not closed quote string', () => {
37
+ expectErrorHelper.expect(['"some text'], {
38
+ description: 'Quote is not get closed!',
39
+ location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
40
+ });
41
+ });
42
+ test('invalid quote text', () => {
43
+ expectErrorHelper.expect(['"some "text"'], {
44
+ description: 'There should be only one opening and one closeing quote!',
45
+ location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
46
+ });
47
+ });
48
+ test('multiline primitive', () => {
49
+ expectErrorHelper.expect(['text', 'secondRow'], {
50
+ description: 'Invalid row! "secondRow"',
51
+ location: { line: mocks_1.SampleLocation1.line + 2, path: mocks_1.SampleLocation1.path }
52
+ });
53
+ });
54
+ test('multiline string no character after backtick - openning', () => {
55
+ expectErrorHelper.expect(['`test', 'something'], {
56
+ description: 'There should be new line after backtick "`test"!',
57
+ location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
58
+ });
59
+ });
60
+ test('multiline string no character after backtick - closing', () => {
61
+ expectErrorHelper.expect(['`', 'test', '`,'], {
62
+ description: 'There should be new line after backtick "`,"!',
63
+ location: { line: mocks_1.SampleLocation1.line + 3, path: mocks_1.SampleLocation1.path }
64
+ });
65
+ });
66
+ test('multiline string should end with backtick', () => {
67
+ expectErrorHelper.expect(['`', 'test`'], {
68
+ description: 'Multiline string should end with backtick in new line "test`"!',
69
+ location: { line: mocks_1.SampleLocation1.line + 2, path: mocks_1.SampleLocation1.path }
70
+ });
71
+ });
72
+ test('multiline string should end with backtick in the same coding indent', () => {
73
+ expectErrorHelper.expect(['`', 'test', ' `'], {
74
+ description: 'Invalid coding indent!',
75
+ location: { line: mocks_1.SampleLocation1.line + 3, path: mocks_1.SampleLocation1.path }
76
+ });
77
+ });
78
+ });
79
+ //# sourceMappingURL=primitive-parser.spec.js.map