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,20 +1,20 @@
|
|
|
1
1
|
import { FileInfo, LocationInFile, ErrorLog } from '../framework/interfaces';
|
|
2
2
|
export interface DefinitionPlaneText {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
readonly type: string;
|
|
4
|
+
readonly content: string[];
|
|
5
|
+
readonly location: LocationInFile;
|
|
6
6
|
}
|
|
7
7
|
export interface SelectDefinitionsResult {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
definitionPlaneTexts: DefinitionPlaneText[];
|
|
9
|
+
errorLogs: ErrorLog[];
|
|
10
10
|
}
|
|
11
11
|
export declare class SelectDefinitionsHelper {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
private definitionsStarted;
|
|
13
|
+
private currentItem;
|
|
14
|
+
private definitionPlaneTexts;
|
|
15
|
+
private errorLogs;
|
|
16
|
+
private currentFilePath;
|
|
17
|
+
process(file: FileInfo): SelectDefinitionsResult;
|
|
18
|
+
private flushCurrentItem;
|
|
19
|
+
private onDeclarationEncountered;
|
|
20
20
|
}
|
|
@@ -1,80 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
3
|
exports.SelectDefinitionsHelper = void 0;
|
|
4
|
-
const common_functions_1 = require(
|
|
5
|
-
const definition_store_1 = require(
|
|
4
|
+
const common_functions_1 = require('../helpers/common-functions/common-functions');
|
|
5
|
+
const definition_store_1 = require('../framework/definition-store');
|
|
6
6
|
class SelectDefinitionsHelper {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.currentItem.content.push(common_functions_1.CommonFunctions.removeComments(row));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
else if (trimmedRow === '# DEFINITIONS') {
|
|
31
|
-
this.definitionsStarted = true;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
this.flushCurrentItem();
|
|
35
|
-
return {
|
|
36
|
-
definitionPlaneTexts: this.definitionPlaneTexts,
|
|
37
|
-
errorLogs: this.errorLogs
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
flushCurrentItem() {
|
|
41
|
-
if (this.currentItem) {
|
|
42
|
-
if (this.currentItem.content.length > 0) {
|
|
43
|
-
this.definitionPlaneTexts.push(this.currentItem);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
let errorLog = {
|
|
47
|
-
description: 'Definitions cannot be empty!',
|
|
48
|
-
location: this.currentItem.location
|
|
49
|
-
};
|
|
50
|
-
this.errorLogs.push(errorLog);
|
|
51
|
-
}
|
|
7
|
+
constructor() {
|
|
8
|
+
this.definitionsStarted = false;
|
|
9
|
+
this.definitionPlaneTexts = [];
|
|
10
|
+
this.errorLogs = [];
|
|
11
|
+
this.currentFilePath = '';
|
|
12
|
+
}
|
|
13
|
+
process(file) {
|
|
14
|
+
this.definitionsStarted = false;
|
|
15
|
+
this.currentItem = undefined;
|
|
16
|
+
this.definitionPlaneTexts = [];
|
|
17
|
+
this.errorLogs = [];
|
|
18
|
+
this.currentFilePath = file.path;
|
|
19
|
+
file.content.split('\n').forEach((row, index) => {
|
|
20
|
+
let trimmedRow = common_functions_1.CommonFunctions.removeWhiteSpace(row);
|
|
21
|
+
if (this.definitionsStarted) {
|
|
22
|
+
if (trimmedRow.startsWith('###')) {
|
|
23
|
+
this.flushCurrentItem();
|
|
24
|
+
this.onDeclarationEncountered(row, index, trimmedRow.substring(4));
|
|
25
|
+
} else if (this.currentItem && trimmedRow.length > 0) {
|
|
26
|
+
this.currentItem.content.push(common_functions_1.CommonFunctions.removeComments(row));
|
|
52
27
|
}
|
|
53
|
-
|
|
28
|
+
} else if (trimmedRow === '# DEFINITIONS') {
|
|
29
|
+
this.definitionsStarted = true;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
this.flushCurrentItem();
|
|
33
|
+
return {
|
|
34
|
+
definitionPlaneTexts: this.definitionPlaneTexts,
|
|
35
|
+
errorLogs: this.errorLogs
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
flushCurrentItem() {
|
|
39
|
+
if (this.currentItem) {
|
|
40
|
+
if (this.currentItem.content.length > 0) {
|
|
41
|
+
this.definitionPlaneTexts.push(this.currentItem);
|
|
42
|
+
} else {
|
|
43
|
+
let errorLog = {
|
|
44
|
+
description: 'Definitions cannot be empty!',
|
|
45
|
+
location: this.currentItem.location
|
|
46
|
+
};
|
|
47
|
+
this.errorLogs.push(errorLog);
|
|
48
|
+
}
|
|
54
49
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
};
|
|
74
|
-
this.errorLogs.push(errorLog);
|
|
75
|
-
this.currentItem = undefined;
|
|
50
|
+
this.currentItem = undefined;
|
|
51
|
+
}
|
|
52
|
+
onDeclarationEncountered(row, index, componentName) {
|
|
53
|
+
if (definition_store_1.DefinitionStore['isValidComponentName'](componentName)) {
|
|
54
|
+
this.currentItem = {
|
|
55
|
+
type: componentName,
|
|
56
|
+
location: {
|
|
57
|
+
line: index + 1,
|
|
58
|
+
path: this.currentFilePath
|
|
59
|
+
},
|
|
60
|
+
content: []
|
|
61
|
+
};
|
|
62
|
+
} else {
|
|
63
|
+
let errorLog = {
|
|
64
|
+
description: `Invalid definition header: "${row.trim()}"`,
|
|
65
|
+
location: {
|
|
66
|
+
line: index + 1,
|
|
67
|
+
path: this.currentFilePath
|
|
76
68
|
}
|
|
69
|
+
};
|
|
70
|
+
this.errorLogs.push(errorLog);
|
|
71
|
+
this.currentItem = undefined;
|
|
77
72
|
}
|
|
73
|
+
}
|
|
78
74
|
}
|
|
79
75
|
exports.SelectDefinitionsHelper = SelectDefinitionsHelper;
|
|
80
|
-
//# sourceMappingURL=1-select-definitions-helper.js.map
|
|
76
|
+
//# sourceMappingURL=1-select-definitions-helper.js.map
|
|
@@ -19,12 +19,12 @@ definition_store_1.DefinitionStore['definitionsMap'].set(custom_validator_helper
|
|
|
19
19
|
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
20
20
|
});
|
|
21
21
|
(0, vitest_1.test)('should handle files without definitions', () => {
|
|
22
|
-
let content = `
|
|
23
|
-
Explanation
|
|
24
|
-
|
|
25
|
-
### ASSET
|
|
26
|
-
Name: singular name
|
|
27
|
-
Path: path to file
|
|
22
|
+
let content = `
|
|
23
|
+
Explanation
|
|
24
|
+
|
|
25
|
+
### ASSET
|
|
26
|
+
Name: singular name
|
|
27
|
+
Path: path to file
|
|
28
28
|
`;
|
|
29
29
|
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
30
30
|
let result = selectDefinitionsHelper.process(fileInfo);
|
|
@@ -32,11 +32,11 @@ definition_store_1.DefinitionStore['definitionsMap'].set(custom_validator_helper
|
|
|
32
32
|
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
33
33
|
});
|
|
34
34
|
(0, vitest_1.test)('should select definitions', () => {
|
|
35
|
-
let content = `
|
|
36
|
-
# DEFINITIONS
|
|
37
|
-
### ASSET
|
|
38
|
-
Name: test
|
|
39
|
-
Path: test.png
|
|
35
|
+
let content = `
|
|
36
|
+
# DEFINITIONS
|
|
37
|
+
### ASSET
|
|
38
|
+
Name: test
|
|
39
|
+
Path: test.png
|
|
40
40
|
`;
|
|
41
41
|
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
42
42
|
let result = selectDefinitionsHelper.process(fileInfo);
|
|
@@ -50,12 +50,12 @@ definition_store_1.DefinitionStore['definitionsMap'].set(custom_validator_helper
|
|
|
50
50
|
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
51
51
|
});
|
|
52
52
|
(0, vitest_1.test)('should ignore comments', () => {
|
|
53
|
-
let content = `
|
|
54
|
-
# DEFINITIONS
|
|
55
|
-
### ASSET
|
|
56
|
-
Name: test // comment
|
|
57
|
-
Path: test.png // comment
|
|
58
|
-
// ----comment----\r
|
|
53
|
+
let content = `
|
|
54
|
+
# DEFINITIONS
|
|
55
|
+
### ASSET
|
|
56
|
+
Name: test // comment
|
|
57
|
+
Path: test.png // comment
|
|
58
|
+
// ----comment----\r
|
|
59
59
|
`;
|
|
60
60
|
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
61
61
|
let result = selectDefinitionsHelper.process(fileInfo);
|
|
@@ -69,9 +69,9 @@ definition_store_1.DefinitionStore['definitionsMap'].set(custom_validator_helper
|
|
|
69
69
|
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
70
70
|
});
|
|
71
71
|
(0, vitest_1.test)('should not allow empty definitions', () => {
|
|
72
|
-
let content = `
|
|
73
|
-
# DEFINITIONS
|
|
74
|
-
### ASSET
|
|
72
|
+
let content = `
|
|
73
|
+
# DEFINITIONS
|
|
74
|
+
### ASSET
|
|
75
75
|
`;
|
|
76
76
|
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
77
77
|
let result = selectDefinitionsHelper.process(fileInfo);
|
|
@@ -84,14 +84,14 @@ definition_store_1.DefinitionStore['definitionsMap'].set(custom_validator_helper
|
|
|
84
84
|
]);
|
|
85
85
|
});
|
|
86
86
|
(0, vitest_1.test)('should not allow unknown definition header after the first valid definition', () => {
|
|
87
|
-
let content = `
|
|
88
|
-
# DEFINITIONS
|
|
89
|
-
### ASSET
|
|
90
|
-
Name: test
|
|
91
|
-
Path: test.png
|
|
92
|
-
|
|
93
|
-
### Some text
|
|
94
|
-
some text
|
|
87
|
+
let content = `
|
|
88
|
+
# DEFINITIONS
|
|
89
|
+
### ASSET
|
|
90
|
+
Name: test
|
|
91
|
+
Path: test.png
|
|
92
|
+
|
|
93
|
+
### Some text
|
|
94
|
+
some text
|
|
95
95
|
`;
|
|
96
96
|
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
97
97
|
let result = selectDefinitionsHelper.process(fileInfo);
|
|
@@ -103,18 +103,18 @@ definition_store_1.DefinitionStore['definitionsMap'].set(custom_validator_helper
|
|
|
103
103
|
]);
|
|
104
104
|
});
|
|
105
105
|
(0, vitest_1.test)('invalid definitions should not corrupt other definitions', () => {
|
|
106
|
-
let content = `
|
|
107
|
-
# DEFINITIONS
|
|
108
|
-
### ASSET
|
|
109
|
-
Name: test
|
|
110
|
-
Path: test.png
|
|
111
|
-
|
|
112
|
-
### Some text
|
|
113
|
-
some text
|
|
114
|
-
|
|
115
|
-
### ASSET
|
|
116
|
-
Name: test2
|
|
117
|
-
Path: test2.png
|
|
106
|
+
let content = `
|
|
107
|
+
# DEFINITIONS
|
|
108
|
+
### ASSET
|
|
109
|
+
Name: test
|
|
110
|
+
Path: test.png
|
|
111
|
+
|
|
112
|
+
### Some text
|
|
113
|
+
some text
|
|
114
|
+
|
|
115
|
+
### ASSET
|
|
116
|
+
Name: test2
|
|
117
|
+
Path: test2.png
|
|
118
118
|
`;
|
|
119
119
|
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
120
120
|
let result = selectDefinitionsHelper.process(fileInfo);
|
|
@@ -1,140 +1,140 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
const _1_select_definitions_helper_1 = require(
|
|
4
|
-
const mocks_1 = require(
|
|
5
|
-
const custom_validator_helper_spec_1 = require(
|
|
6
|
-
const definition_store_1 = require(
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
const _1_select_definitions_helper_1 = require('./1-select-definitions-helper');
|
|
4
|
+
const mocks_1 = require('../_mocks/mocks');
|
|
5
|
+
const custom_validator_helper_spec_1 = require('../helpers/validator/custom-validator-helper/custom-validator.helper.spec');
|
|
6
|
+
const definition_store_1 = require('../framework/definition-store');
|
|
7
7
|
definition_store_1.DefinitionStore['definitionsMap'].set(custom_validator_helper_spec_1.AssetComponentName, new Map());
|
|
8
8
|
describe('SELECT DEFINITIONS HELPER', () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Explanation
|
|
23
|
-
|
|
24
|
-
### ASSET
|
|
25
|
-
Name: singular name
|
|
26
|
-
Path: path to file
|
|
9
|
+
let selectDefinitionsHelper;
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
selectDefinitionsHelper = new _1_select_definitions_helper_1.SelectDefinitionsHelper();
|
|
12
|
+
});
|
|
13
|
+
test('should handle empty files', () => {
|
|
14
|
+
let content = ``;
|
|
15
|
+
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
16
|
+
let result = selectDefinitionsHelper.process(fileInfo);
|
|
17
|
+
expect(result.definitionPlaneTexts).toStrictEqual([]);
|
|
18
|
+
expect(result.errorLogs).toStrictEqual([]);
|
|
19
|
+
});
|
|
20
|
+
test('should handle files without definitions', () => {
|
|
21
|
+
let content = `
|
|
22
|
+
Explanation
|
|
23
|
+
|
|
24
|
+
### ASSET
|
|
25
|
+
Name: singular name
|
|
26
|
+
Path: path to file
|
|
27
27
|
`;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
# DEFINITIONS
|
|
36
|
-
### ASSET
|
|
37
|
-
Name: test
|
|
38
|
-
Path: test.png
|
|
28
|
+
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
29
|
+
let result = selectDefinitionsHelper.process(fileInfo);
|
|
30
|
+
expect(result.definitionPlaneTexts).toStrictEqual([]);
|
|
31
|
+
expect(result.errorLogs).toStrictEqual([]);
|
|
32
|
+
});
|
|
33
|
+
test('should select definitions', () => {
|
|
34
|
+
let content = `
|
|
35
|
+
# DEFINITIONS
|
|
36
|
+
### ASSET
|
|
37
|
+
Name: test
|
|
38
|
+
Path: test.png
|
|
39
39
|
`;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
# DEFINITIONS
|
|
54
|
-
### ASSET
|
|
55
|
-
Name: test // comment
|
|
56
|
-
Path: test.png // comment
|
|
57
|
-
// ----comment----\r
|
|
40
|
+
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
41
|
+
let result = selectDefinitionsHelper.process(fileInfo);
|
|
42
|
+
expect(result.definitionPlaneTexts).toStrictEqual([
|
|
43
|
+
{
|
|
44
|
+
type: 'ASSET',
|
|
45
|
+
content: [' Name: test', ' Path: test.png'],
|
|
46
|
+
location: { line: 3, path: fileInfo.path }
|
|
47
|
+
}
|
|
48
|
+
]);
|
|
49
|
+
expect(result.errorLogs).toStrictEqual([]);
|
|
50
|
+
});
|
|
51
|
+
test('should ignore comments', () => {
|
|
52
|
+
let content = `
|
|
53
|
+
# DEFINITIONS
|
|
54
|
+
### ASSET
|
|
55
|
+
Name: test // comment
|
|
56
|
+
Path: test.png // comment
|
|
57
|
+
// ----comment----\r
|
|
58
58
|
`;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
# DEFINITIONS
|
|
73
|
-
### ASSET
|
|
59
|
+
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
60
|
+
let result = selectDefinitionsHelper.process(fileInfo);
|
|
61
|
+
expect(result.definitionPlaneTexts).toStrictEqual([
|
|
62
|
+
{
|
|
63
|
+
type: 'ASSET',
|
|
64
|
+
content: [' Name: test', ' Path: test.png'],
|
|
65
|
+
location: { line: 3, path: fileInfo.path }
|
|
66
|
+
}
|
|
67
|
+
]);
|
|
68
|
+
expect(result.errorLogs).toStrictEqual([]);
|
|
69
|
+
});
|
|
70
|
+
test('should not allow empty definitions', () => {
|
|
71
|
+
let content = `
|
|
72
|
+
# DEFINITIONS
|
|
73
|
+
### ASSET
|
|
74
74
|
`;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
# DEFINITIONS
|
|
88
|
-
### ASSET
|
|
89
|
-
Name: test
|
|
90
|
-
Path: test.png
|
|
91
|
-
|
|
92
|
-
### Some text
|
|
93
|
-
some text
|
|
75
|
+
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
76
|
+
let result = selectDefinitionsHelper.process(fileInfo);
|
|
77
|
+
expect(result.definitionPlaneTexts).toStrictEqual([]);
|
|
78
|
+
expect(result.errorLogs).toStrictEqual([
|
|
79
|
+
{
|
|
80
|
+
description: 'Definitions cannot be empty!',
|
|
81
|
+
location: { line: 3, path: fileInfo.path }
|
|
82
|
+
}
|
|
83
|
+
]);
|
|
84
|
+
});
|
|
85
|
+
test('should not allow unknown definition header after the first valid definition', () => {
|
|
86
|
+
let content = `
|
|
87
|
+
# DEFINITIONS
|
|
88
|
+
### ASSET
|
|
89
|
+
Name: test
|
|
90
|
+
Path: test.png
|
|
91
|
+
|
|
92
|
+
### Some text
|
|
93
|
+
some text
|
|
94
94
|
`;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
# DEFINITIONS
|
|
107
|
-
### ASSET
|
|
108
|
-
Name: test
|
|
109
|
-
Path: test.png
|
|
110
|
-
|
|
111
|
-
### Some text
|
|
112
|
-
some text
|
|
113
|
-
|
|
114
|
-
### ASSET
|
|
115
|
-
Name: test2
|
|
116
|
-
Path: test2.png
|
|
95
|
+
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
96
|
+
let result = selectDefinitionsHelper.process(fileInfo);
|
|
97
|
+
expect(result.errorLogs).toStrictEqual([
|
|
98
|
+
{
|
|
99
|
+
description: 'Invalid definition header: "### Some text"',
|
|
100
|
+
location: { line: 7, path: fileInfo.path }
|
|
101
|
+
}
|
|
102
|
+
]);
|
|
103
|
+
});
|
|
104
|
+
test('invalid definitions should not corrupt other definitions', () => {
|
|
105
|
+
let content = `
|
|
106
|
+
# DEFINITIONS
|
|
107
|
+
### ASSET
|
|
108
|
+
Name: test
|
|
109
|
+
Path: test.png
|
|
110
|
+
|
|
111
|
+
### Some text
|
|
112
|
+
some text
|
|
113
|
+
|
|
114
|
+
### ASSET
|
|
115
|
+
Name: test2
|
|
116
|
+
Path: test2.png
|
|
117
117
|
`;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
118
|
+
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
119
|
+
let result = selectDefinitionsHelper.process(fileInfo);
|
|
120
|
+
expect(result.definitionPlaneTexts).toStrictEqual([
|
|
121
|
+
{
|
|
122
|
+
type: 'ASSET',
|
|
123
|
+
content: [' Name: test', ' Path: test.png'],
|
|
124
|
+
location: { line: 3, path: fileInfo.path }
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
type: 'ASSET',
|
|
128
|
+
content: [' Name: test2', ' Path: test2.png'],
|
|
129
|
+
location: { line: 10, path: fileInfo.path }
|
|
130
|
+
}
|
|
131
|
+
]);
|
|
132
|
+
expect(result.errorLogs).toStrictEqual([
|
|
133
|
+
{
|
|
134
|
+
description: 'Invalid definition header: "### Some text"',
|
|
135
|
+
location: { line: 7, path: fileInfo.path }
|
|
136
|
+
}
|
|
137
|
+
]);
|
|
138
|
+
});
|
|
139
139
|
});
|
|
140
|
-
//# sourceMappingURL=1-select-definitions.spec.js.map
|
|
140
|
+
//# sourceMappingURL=1-select-definitions.spec.js.map
|