yini-parser 1.0.0-alpha.1 → 1.0.0-alpha.2
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/README.md +21 -10
- package/dist/YINI.d.ts +21 -0
- package/dist/{src/YINI.js → YINI.js} +7 -7
- package/dist/config/env.d.ts +20 -0
- package/dist/core/ErrorDataHandler.d.ts +60 -0
- package/dist/core/YINIVisitor.d.ts +149 -0
- package/dist/core/objectBuilder.d.ts +6 -0
- package/dist/core/types.d.ts +49 -0
- package/dist/grammar/YiniLexer.d.ts +68 -0
- package/dist/grammar/YiniParser.d.ts +284 -0
- package/dist/grammar/YiniParserVisitor.d.ts +143 -0
- package/dist/index.d.ts +1 -0
- package/dist/parseEntry.d.ts +2 -0
- package/dist/parsers/extractHeaderParts.d.ts +31 -0
- package/dist/parsers/extractSignificantYiniLine.d.ts +9 -0
- package/dist/parsers/parseBoolean.d.ts +5 -0
- package/dist/parsers/parseNull.d.ts +2 -0
- package/dist/parsers/parseNumber.d.ts +6 -0
- package/dist/parsers/parseSectionHeader.d.ts +13 -0
- package/dist/parsers/parseString.d.ts +2 -0
- package/dist/utils/pathAndFileName.d.ts +5 -0
- package/dist/utils/string.d.ts +42 -0
- package/dist/utils/system.d.ts +7 -0
- package/dist/yiniHelpers.d.ts +44 -0
- package/package.json +17 -18
- package/dist/tests/integration/1-core-parsing/parse-bigger-section-nesting-as-object.test.js +0 -83
- package/dist/tests/integration/1-core-parsing/parse-section-nesting-w-classic-markers.test.js +0 -170
- package/dist/tests/integration/1-core-parsing/parse-section-nesting-w-nsh-markers.test.js +0 -27
- package/dist/tests/integration/1-core-parsing/read some values from level 1 and 2.test.js +0 -77
- package/dist/tests/integration/1-core-parsing/throw on bad section heads.test.js +0 -162
- package/dist/tests/integration/10-special-validation-modes/validation-modes.test.js +0 -38
- package/dist/tests/integration/2-file-structure-and-error/able to parse mixed case filenames.test.js +0 -72
- package/dist/tests/integration/2-file-structure-and-error/throw error on bad file extensions.test.js +0 -36
- package/dist/tests/integration/2-file-structure-and-error/throw error parsing bad content.test.js +0 -80
- package/dist/tests/smoke/A-general-smoke.test.js +0 -259
- package/dist/tests/smoke/B-parse-inline-smoke.test.js +0 -270
- package/dist/tests/smoke/C-traverse-file-smoke.test.js +0 -141
- package/dist/tests/smoke/D-parse-file-smoke.test.js +0 -134
- package/dist/tests/unit/parsers/extractHeaderParts.unit.test.js +0 -490
- package/dist/tests/unit/parsers/parseSectionHeader-classic.unit.test.js +0 -421
- package/dist/tests/unit/parsers/parseSectionHeader-nsh.unit.test.js +0 -436
- package/dist/tests/unit/parsers/parseSectionHeader-throw-on-invalid.unit.test.js +0 -168
- package/dist/tests/unit/utils/utils-pathAndFileName.unit.test.js +0 -80
- package/dist/tests/unit/utils/utils-string.unit.test.js +0 -185
- package/dist/tests/unit/yiniHelpers.unit.test.js +0 -306
- /package/dist/{src/config → config}/env.js +0 -0
- /package/dist/{src/core → core}/ErrorDataHandler.js +0 -0
- /package/dist/{src/core → core}/YINIVisitor.js +0 -0
- /package/dist/{src/core → core}/objectBuilder.js +0 -0
- /package/dist/{src/core → core}/types.js +0 -0
- /package/dist/{src/grammar → grammar}/YiniLexer.js +0 -0
- /package/dist/{src/grammar → grammar}/YiniParser.js +0 -0
- /package/dist/{src/grammar → grammar}/YiniParserVisitor.js +0 -0
- /package/dist/{src/index.js → index.js} +0 -0
- /package/dist/{src/parseEntry.js → parseEntry.js} +0 -0
- /package/dist/{src/parsers → parsers}/extractHeaderParts.js +0 -0
- /package/dist/{src/parsers → parsers}/extractSignificantYiniLine.js +0 -0
- /package/dist/{src/parsers → parsers}/parseBoolean.js +0 -0
- /package/dist/{src/parsers → parsers}/parseNull.js +0 -0
- /package/dist/{src/parsers → parsers}/parseNumber.js +0 -0
- /package/dist/{src/parsers → parsers}/parseSectionHeader.js +0 -0
- /package/dist/{src/parsers → parsers}/parseString.js +0 -0
- /package/dist/{src/utils → utils}/pathAndFileName.js +0 -0
- /package/dist/{src/utils → utils}/string.js +0 -0
- /package/dist/{src/utils → utils}/system.js +0 -0
- /package/dist/{src/yiniHelpers.js → yiniHelpers.js} +0 -0
|
@@ -1,436 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const ErrorDataHandler_1 = require("../../../src/core/ErrorDataHandler");
|
|
7
|
-
const parseSectionHeader_1 = __importDefault(require("../../../src/parsers/parseSectionHeader"));
|
|
8
|
-
const system_1 = require("../../../src/utils/system");
|
|
9
|
-
/**
|
|
10
|
-
* Parse numeric shorthand section header unit tests.
|
|
11
|
-
*/
|
|
12
|
-
describe('Parse numeric shorthand section header unit tests:', () => {
|
|
13
|
-
let eh;
|
|
14
|
-
beforeAll(() => {
|
|
15
|
-
eh = new ErrorDataHandler_1.ErrorDataHandler('1-Abort-on-Errors');
|
|
16
|
-
});
|
|
17
|
-
test('1.a. Identify numeric shorthand header with level 1.', () => {
|
|
18
|
-
// Arrange.
|
|
19
|
-
const fixture = '^1 SectionName';
|
|
20
|
-
// Act.
|
|
21
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
22
|
-
(0, system_1.debugPrint)(' markerType: ' + markerType);
|
|
23
|
-
(0, system_1.debugPrint)(' sectionName: ' + sectionName);
|
|
24
|
-
(0, system_1.debugPrint)('sectionLevel: ' + sectionLevel);
|
|
25
|
-
// Assert.
|
|
26
|
-
expect(sectionName).not.toEqual('thisNameIsNotCorrect');
|
|
27
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
28
|
-
expect(sectionName).toEqual('SectionName');
|
|
29
|
-
expect(sectionLevel).toEqual(1);
|
|
30
|
-
});
|
|
31
|
-
test('1.b. Identify numeric shorthand header with level 1 with tabbed delimeter.', () => {
|
|
32
|
-
// Arrange.
|
|
33
|
-
const fixture = '^1\tSectionName';
|
|
34
|
-
// Act.
|
|
35
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
36
|
-
// Assert.
|
|
37
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
38
|
-
expect(sectionName).toEqual('SectionName');
|
|
39
|
-
expect(sectionLevel).toEqual(1);
|
|
40
|
-
});
|
|
41
|
-
test('1.c. Identify numeric shorthand header with level 1 with multiple spaces.', () => {
|
|
42
|
-
// Arrange.
|
|
43
|
-
const fixture = '^1 SectionName';
|
|
44
|
-
// Act.
|
|
45
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
46
|
-
// Assert.
|
|
47
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
48
|
-
expect(sectionName).toEqual('SectionName');
|
|
49
|
-
expect(sectionLevel).toEqual(1);
|
|
50
|
-
});
|
|
51
|
-
test('1.d. Identify numeric shorthand header with level 1 with any WS delimeters.', () => {
|
|
52
|
-
// Arrange.
|
|
53
|
-
const fixture = '^1\t \t SectionName';
|
|
54
|
-
// Act.
|
|
55
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
56
|
-
// Assert.
|
|
57
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
58
|
-
expect(sectionName).toEqual('SectionName');
|
|
59
|
-
expect(sectionLevel).toEqual(1);
|
|
60
|
-
});
|
|
61
|
-
test('1.e. Identify numeric shorthand header with level 1 with a comment and any WS delimeters.', () => {
|
|
62
|
-
// Arrange.
|
|
63
|
-
const fixture = '^1\t \t SectionName // This part is a comment.';
|
|
64
|
-
// Act.
|
|
65
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
66
|
-
// Assert.
|
|
67
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
68
|
-
expect(sectionName).toEqual('SectionName');
|
|
69
|
-
expect(sectionLevel).toEqual(1);
|
|
70
|
-
});
|
|
71
|
-
test('2.a. Identify numeric shorthand header with level 1 and backticked name.', () => {
|
|
72
|
-
// Arrange.
|
|
73
|
-
const fixture = '^1 `Section Name`';
|
|
74
|
-
// Act.
|
|
75
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
76
|
-
// Assert.
|
|
77
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
78
|
-
expect(sectionName).toEqual('`Section Name`');
|
|
79
|
-
expect(sectionLevel).toEqual(1);
|
|
80
|
-
});
|
|
81
|
-
test('2.b. Identify numeric shorthand header with level 1 with tabbed delimeter and backticked name.', () => {
|
|
82
|
-
// Arrange.
|
|
83
|
-
const fixture = '^1\t`Section Name`';
|
|
84
|
-
// Act.
|
|
85
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
86
|
-
// Assert.
|
|
87
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
88
|
-
expect(sectionName).toEqual('`Section Name`');
|
|
89
|
-
expect(sectionLevel).toEqual(1);
|
|
90
|
-
});
|
|
91
|
-
test('2.c. Identify numeric shorthand header with level 1 with multiple spaces and backticked name.', () => {
|
|
92
|
-
// Arrange.
|
|
93
|
-
const fixture = '^1 `Section Name`';
|
|
94
|
-
// Act.
|
|
95
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
96
|
-
// Assert.
|
|
97
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
98
|
-
expect(sectionName).toEqual('`Section Name`');
|
|
99
|
-
expect(sectionLevel).toEqual(1);
|
|
100
|
-
});
|
|
101
|
-
test('2.d. Identify numeric shorthand header with level 1 with any WS delimeters and backticked name.', () => {
|
|
102
|
-
// Arrange.
|
|
103
|
-
const fixture = '^1\t \t `Section Name`';
|
|
104
|
-
// Act.
|
|
105
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
106
|
-
// Assert.
|
|
107
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
108
|
-
expect(sectionName).toEqual('`Section Name`');
|
|
109
|
-
expect(sectionLevel).toEqual(1);
|
|
110
|
-
});
|
|
111
|
-
test('2.e. Identify numeric shorthand header with level 1 with a comment and any WS delimeters and backticked name.', () => {
|
|
112
|
-
// Arrange.
|
|
113
|
-
const fixture = '^1\t \t `Section Name` # This part is a comment.';
|
|
114
|
-
// Act.
|
|
115
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
116
|
-
// Assert.
|
|
117
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
118
|
-
expect(sectionName).toEqual('`Section Name`');
|
|
119
|
-
expect(sectionLevel).toEqual(1);
|
|
120
|
-
});
|
|
121
|
-
test('3.a. Identify numeric shorthand header with level 1, compact (no WS).', () => {
|
|
122
|
-
// Arrange.
|
|
123
|
-
const fixture = '^1SectionName';
|
|
124
|
-
// Act.
|
|
125
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
126
|
-
// Assert.
|
|
127
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
128
|
-
expect(sectionName).toEqual('SectionName');
|
|
129
|
-
expect(sectionLevel).toEqual(1);
|
|
130
|
-
});
|
|
131
|
-
test('3.b. Identify numeric shorthand header with level 1 with comment, compact (no WS).', () => {
|
|
132
|
-
// Arrange.
|
|
133
|
-
const fixture = '^1SectionName // This is a section header.';
|
|
134
|
-
// Act.
|
|
135
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
136
|
-
// Assert.
|
|
137
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
138
|
-
expect(sectionName).toEqual('SectionName');
|
|
139
|
-
expect(sectionLevel).toEqual(1);
|
|
140
|
-
});
|
|
141
|
-
test('3.c. Identify numeric shorthand header with level 1 with comment, compact (no WS).', () => {
|
|
142
|
-
// Arrange.
|
|
143
|
-
const fixture = '^1SectionName # This part is a comment.';
|
|
144
|
-
// Act.
|
|
145
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
146
|
-
// Assert.
|
|
147
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
148
|
-
expect(sectionName).toEqual('SectionName');
|
|
149
|
-
expect(sectionLevel).toEqual(1);
|
|
150
|
-
});
|
|
151
|
-
test('3.d. Identify numeric shorthand header with level 1 with comment, compact (no WS).', () => {
|
|
152
|
-
// Arrange.
|
|
153
|
-
const fixture = '^1SectionName// This is a section header.';
|
|
154
|
-
// Act.
|
|
155
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
156
|
-
// Assert.
|
|
157
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
158
|
-
expect(sectionName).toEqual('SectionName');
|
|
159
|
-
expect(sectionLevel).toEqual(1);
|
|
160
|
-
});
|
|
161
|
-
test('3.e. Identify numeric shorthand header with level 1 with comment, compact (no WS).', () => {
|
|
162
|
-
// Arrange.
|
|
163
|
-
const fixture = '^1SectionName# This part is a comment.';
|
|
164
|
-
// Act.
|
|
165
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
166
|
-
// Assert.
|
|
167
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
168
|
-
expect(sectionName).toEqual('SectionName');
|
|
169
|
-
expect(sectionLevel).toEqual(1);
|
|
170
|
-
});
|
|
171
|
-
test('3.f. Identify numeric shorthand header with level 1 enclosed in comments, compact (no WS).', () => {
|
|
172
|
-
// Arrange.
|
|
173
|
-
const fixture = `// This whole line is a comment.
|
|
174
|
-
^1SectionName# This part is a comment.
|
|
175
|
-
// This whole line is a comment.
|
|
176
|
-
`;
|
|
177
|
-
// Act.
|
|
178
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
179
|
-
// Assert.
|
|
180
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
181
|
-
expect(sectionName).toEqual('SectionName');
|
|
182
|
-
expect(sectionLevel).toEqual(1);
|
|
183
|
-
});
|
|
184
|
-
test('4.a. Identify numeric shorthand header with level 1, backticked name, compact (no WS).', () => {
|
|
185
|
-
// Arrange.
|
|
186
|
-
const fixture = '^1`Section Name`';
|
|
187
|
-
// Act.
|
|
188
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
189
|
-
// Assert.
|
|
190
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
191
|
-
expect(sectionName).toEqual('`Section Name`');
|
|
192
|
-
expect(sectionLevel).toEqual(1);
|
|
193
|
-
});
|
|
194
|
-
test('4.b. Identify numeric shorthand header with level 1 with backticked name and comment, compact (no WS).', () => {
|
|
195
|
-
// Arrange.
|
|
196
|
-
const fixture = '^1`Section Name` // Comment.';
|
|
197
|
-
// Act.
|
|
198
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
199
|
-
// Assert.
|
|
200
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
201
|
-
expect(sectionName).toEqual('`Section Name`');
|
|
202
|
-
expect(sectionLevel).toEqual(1);
|
|
203
|
-
});
|
|
204
|
-
test('4.c. Identify numeric shorthand header with level 1 with backticked name and comment, compact (no WS).', () => {
|
|
205
|
-
// Arrange.
|
|
206
|
-
const fixture = '^1`Section Name` # Comment.';
|
|
207
|
-
// Act.
|
|
208
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
209
|
-
// Assert.
|
|
210
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
211
|
-
expect(sectionName).toEqual('`Section Name`');
|
|
212
|
-
expect(sectionLevel).toEqual(1);
|
|
213
|
-
});
|
|
214
|
-
test('4.d. Identify numeric shorthand header with level 1 with backticked name and comment, compact (no WS).', () => {
|
|
215
|
-
// Arrange.
|
|
216
|
-
const fixture = '^1`Section Name`// This part is a comment.';
|
|
217
|
-
// Act.
|
|
218
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
219
|
-
// Assert.
|
|
220
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
221
|
-
expect(sectionName).toEqual('`Section Name`');
|
|
222
|
-
expect(sectionLevel).toEqual(1);
|
|
223
|
-
});
|
|
224
|
-
test('5.a. Identify numeric shorthand header with level 2.', () => {
|
|
225
|
-
// Arrange.
|
|
226
|
-
const fixture = '^2 SectionName';
|
|
227
|
-
// Act.
|
|
228
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
229
|
-
// Assert.
|
|
230
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
231
|
-
expect(sectionName).toEqual('SectionName');
|
|
232
|
-
expect(sectionLevel).toEqual(2);
|
|
233
|
-
});
|
|
234
|
-
test('5.b. Identify numeric shorthand header with level 2 and comment.', () => {
|
|
235
|
-
// Arrange.
|
|
236
|
-
const fixture = '^2 SectionName // This part is a comment.';
|
|
237
|
-
// Act.
|
|
238
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
239
|
-
// Assert.
|
|
240
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
241
|
-
expect(sectionName).toEqual('SectionName');
|
|
242
|
-
expect(sectionLevel).toEqual(2);
|
|
243
|
-
});
|
|
244
|
-
test('6.a. Identify numeric shorthand header with level 3.', () => {
|
|
245
|
-
// Arrange.
|
|
246
|
-
const fixture = '^3 SectionName';
|
|
247
|
-
// Act.
|
|
248
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
249
|
-
// Assert.
|
|
250
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
251
|
-
expect(sectionName).toEqual('SectionName');
|
|
252
|
-
expect(sectionLevel).toEqual(3);
|
|
253
|
-
});
|
|
254
|
-
test('6.b. Identify numeric shorthand header with level 3, compact (no WS).', () => {
|
|
255
|
-
// Arrange.
|
|
256
|
-
const fixture = '^3SectionName';
|
|
257
|
-
// Act.
|
|
258
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
259
|
-
// Assert.
|
|
260
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
261
|
-
expect(sectionName).toEqual('SectionName');
|
|
262
|
-
expect(sectionLevel).toEqual(3);
|
|
263
|
-
});
|
|
264
|
-
test('7.a. Identify numeric shorthand header with level 4.', () => {
|
|
265
|
-
// Arrange.
|
|
266
|
-
const fixture = '^4 SectionName';
|
|
267
|
-
// Act.
|
|
268
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
269
|
-
// Assert.
|
|
270
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
271
|
-
expect(sectionName).toEqual('SectionName');
|
|
272
|
-
expect(sectionLevel).toEqual(4);
|
|
273
|
-
});
|
|
274
|
-
test('7.b. Identify numeric shorthand header with level 4 with backticked name.', () => {
|
|
275
|
-
// Arrange.
|
|
276
|
-
const fixture = '^4 `Section Name`';
|
|
277
|
-
// Act.
|
|
278
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
279
|
-
// Assert.
|
|
280
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
281
|
-
expect(sectionName).toEqual('`Section Name`');
|
|
282
|
-
expect(sectionLevel).toEqual(4);
|
|
283
|
-
});
|
|
284
|
-
test('8.a. Identify numeric shorthand header with level 5.', () => {
|
|
285
|
-
// Arrange.
|
|
286
|
-
const fixture = '^5 SectionName';
|
|
287
|
-
// Act.
|
|
288
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
289
|
-
// Assert.
|
|
290
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
291
|
-
expect(sectionName).toEqual('SectionName');
|
|
292
|
-
expect(sectionLevel).toEqual(5);
|
|
293
|
-
});
|
|
294
|
-
test('8.b. Identify numeric shorthand header with level 5, with many WS.', () => {
|
|
295
|
-
// Arrange.
|
|
296
|
-
const fixture = '^5 \tSectionName';
|
|
297
|
-
// Act.
|
|
298
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
299
|
-
// Assert.
|
|
300
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
301
|
-
expect(sectionName).toEqual('SectionName');
|
|
302
|
-
expect(sectionLevel).toEqual(5);
|
|
303
|
-
});
|
|
304
|
-
test('9.a. Identify numeric shorthand header with level 6.', () => {
|
|
305
|
-
// Arrange.
|
|
306
|
-
const fixture = '^6 SectionName';
|
|
307
|
-
// Act.
|
|
308
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
309
|
-
// Assert.
|
|
310
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
311
|
-
expect(sectionName).toEqual('SectionName');
|
|
312
|
-
expect(sectionLevel).toEqual(6);
|
|
313
|
-
});
|
|
314
|
-
test('9.b. Identify numeric shorthand header with level 6, compact with backticed name and comment.', () => {
|
|
315
|
-
// Arrange.
|
|
316
|
-
const fixture = `;This line is comment.
|
|
317
|
-
^6\`Section Name\`//Comment here.
|
|
318
|
-
;This line is comment.
|
|
319
|
-
`;
|
|
320
|
-
// Act.
|
|
321
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
322
|
-
// Assert.
|
|
323
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
324
|
-
expect(sectionName).toEqual('`Section Name`');
|
|
325
|
-
expect(sectionLevel).toEqual(6);
|
|
326
|
-
});
|
|
327
|
-
test('10.a. Identify numeric shorthand header with level 1 and alternative character marker (~).', () => {
|
|
328
|
-
// Arrange.
|
|
329
|
-
const fixture = '~1 SectionName';
|
|
330
|
-
// Act.
|
|
331
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
332
|
-
// Assert.
|
|
333
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
334
|
-
expect(sectionName).toEqual('SectionName');
|
|
335
|
-
expect(sectionLevel).toEqual(1);
|
|
336
|
-
});
|
|
337
|
-
test('10.b. Identify numeric shorthand header with level 2 with tabbed delimeter and alternative character marker (§).', () => {
|
|
338
|
-
// Arrange.
|
|
339
|
-
const fixture = '§2\tSectionName';
|
|
340
|
-
// Act.
|
|
341
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
342
|
-
// Assert.
|
|
343
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
344
|
-
expect(sectionName).toEqual('SectionName');
|
|
345
|
-
expect(sectionLevel).toEqual(2);
|
|
346
|
-
});
|
|
347
|
-
test('10.c. Identify numeric shorthand header with level 2 with tabbed delimeter and alternative character marker (€).', () => {
|
|
348
|
-
// Arrange.
|
|
349
|
-
const fixture = '€2\tSectionName';
|
|
350
|
-
// Act.
|
|
351
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
352
|
-
// Assert.
|
|
353
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
354
|
-
expect(sectionName).toEqual('SectionName');
|
|
355
|
-
expect(sectionLevel).toEqual(2);
|
|
356
|
-
});
|
|
357
|
-
test('11.a. Identify numeric shorthand header with level 4 and alternative character marker (~).', () => {
|
|
358
|
-
// Arrange.
|
|
359
|
-
const fixture = '~4 SectionName // This part is a comment.';
|
|
360
|
-
// Act.
|
|
361
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
362
|
-
// Assert.
|
|
363
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
364
|
-
expect(sectionName).toEqual('SectionName');
|
|
365
|
-
expect(sectionLevel).toEqual(4);
|
|
366
|
-
});
|
|
367
|
-
test('11.b. Identify numeric shorthand header with level 5 with tabbed delimeter and alternative character marker (§).', () => {
|
|
368
|
-
// Arrange.
|
|
369
|
-
const fixture = '§5SectionName # This part is a comment.';
|
|
370
|
-
// Act.
|
|
371
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
372
|
-
// Assert.
|
|
373
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
374
|
-
expect(sectionName).toEqual('SectionName');
|
|
375
|
-
expect(sectionLevel).toEqual(5);
|
|
376
|
-
});
|
|
377
|
-
test('11.c. Identify numeric shorthand header with level 6 with tabbed delimeter and alternative character marker (€).', () => {
|
|
378
|
-
// Arrange.
|
|
379
|
-
const fixture = `// This line is a comment.
|
|
380
|
-
€6 SectionName# This part is a comment.
|
|
381
|
-
; This line is a comment.
|
|
382
|
-
`;
|
|
383
|
-
// Act.
|
|
384
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
385
|
-
// Assert.
|
|
386
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
387
|
-
expect(sectionName).toEqual('SectionName');
|
|
388
|
-
expect(sectionLevel).toEqual(6);
|
|
389
|
-
});
|
|
390
|
-
test('12.a. Identify numeric shorthand header with level higher than what classic support.', () => {
|
|
391
|
-
// Arrange.
|
|
392
|
-
const fixture = '^7 Section7';
|
|
393
|
-
// Act.
|
|
394
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
395
|
-
// Assert.
|
|
396
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
397
|
-
expect(sectionName).toEqual('Section7');
|
|
398
|
-
expect(sectionLevel).toEqual(7);
|
|
399
|
-
});
|
|
400
|
-
test('12.b. Identify numeric shorthand header with level higher than what classic support.', () => {
|
|
401
|
-
// Arrange.
|
|
402
|
-
const fixture = `
|
|
403
|
-
^16SectionName # Comment here.
|
|
404
|
-
//This line is comment.
|
|
405
|
-
`;
|
|
406
|
-
// Act.
|
|
407
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
408
|
-
// Assert.
|
|
409
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
410
|
-
expect(sectionName).toEqual('SectionName');
|
|
411
|
-
expect(sectionLevel).toEqual(16);
|
|
412
|
-
});
|
|
413
|
-
test('12.c. Identify numeric shorthand header with level higher than what classic support.', () => {
|
|
414
|
-
// Arrange.
|
|
415
|
-
const fixture = '^77 SectionName';
|
|
416
|
-
// Act.
|
|
417
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
418
|
-
// Assert.
|
|
419
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
420
|
-
expect(sectionName).toEqual('SectionName');
|
|
421
|
-
expect(sectionLevel).toEqual(77);
|
|
422
|
-
});
|
|
423
|
-
test('12.d. Identify numeric shorthand header with level higher than what classic support.', () => {
|
|
424
|
-
// Arrange.
|
|
425
|
-
const fixture = `;This line is comment.
|
|
426
|
-
^199\`Section Name 199\`//Comment here.
|
|
427
|
-
;This line is comment.
|
|
428
|
-
`;
|
|
429
|
-
// Act.
|
|
430
|
-
const { markerType, sectionName, sectionLevel } = (0, parseSectionHeader_1.default)(fixture, eh, null);
|
|
431
|
-
// Assert.
|
|
432
|
-
expect(markerType).toEqual('Numeric-Header-Marker');
|
|
433
|
-
expect(sectionName).toEqual('`Section Name 199`');
|
|
434
|
-
expect(sectionLevel).toEqual(199);
|
|
435
|
-
});
|
|
436
|
-
});
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const ErrorDataHandler_1 = require("../../../src/core/ErrorDataHandler");
|
|
7
|
-
const parseSectionHeader_1 = __importDefault(require("../../../src/parsers/parseSectionHeader"));
|
|
8
|
-
/**
|
|
9
|
-
* Throw error when parsing bad classic header unit tests.
|
|
10
|
-
*/
|
|
11
|
-
describe('Throw error when parsing bad header marker (classic and numeric shorthand) unit tests:', () => {
|
|
12
|
-
let eh;
|
|
13
|
-
beforeAll(() => {
|
|
14
|
-
eh = new ErrorDataHandler_1.ErrorDataHandler('1-Abort-on-Errors');
|
|
15
|
-
});
|
|
16
|
-
test('1.a. Should throw error if parsing bad classic header (more than 6 marker (^) characters).', () => {
|
|
17
|
-
// Arrange.
|
|
18
|
-
const invalidYini = `
|
|
19
|
-
^^^^^^^ InvalidHeaderMarker // INVALID: More than 6 marker characters.
|
|
20
|
-
value = 3
|
|
21
|
-
`;
|
|
22
|
-
// Act & Assert.
|
|
23
|
-
expect(() => {
|
|
24
|
-
(0, parseSectionHeader_1.default)(invalidYini, eh, null);
|
|
25
|
-
}).toThrow();
|
|
26
|
-
});
|
|
27
|
-
test('1.b. Should throw error if parsing bad classic header (more than 6 marker (~) characters).', () => {
|
|
28
|
-
// Arrange.
|
|
29
|
-
const invalidYini = `
|
|
30
|
-
~~~~~~~ InvalidHeaderMarker // INVALID: More than 6 marker characters.
|
|
31
|
-
`;
|
|
32
|
-
// Act & Assert.
|
|
33
|
-
expect(() => {
|
|
34
|
-
(0, parseSectionHeader_1.default)(invalidYini, eh, null);
|
|
35
|
-
}).toThrow();
|
|
36
|
-
});
|
|
37
|
-
test('1.c. Should throw error if parsing bad classic header (more than 6 marker (§) characters).', () => {
|
|
38
|
-
// Arrange.
|
|
39
|
-
const invalidYini = `
|
|
40
|
-
§§§§§§§ InvalidHeaderMarker // INVALID: More than 6 marker characters.
|
|
41
|
-
value = 3
|
|
42
|
-
`;
|
|
43
|
-
// Act & Assert.
|
|
44
|
-
expect(() => {
|
|
45
|
-
(0, parseSectionHeader_1.default)(invalidYini, eh, null);
|
|
46
|
-
}).toThrow();
|
|
47
|
-
});
|
|
48
|
-
test('1.d. Should throw error if parsing bad classic header (more than 6 marker (€) characters).', () => {
|
|
49
|
-
// Arrange.
|
|
50
|
-
const invalidYini = `
|
|
51
|
-
€€€€€€€ InvalidHeaderMarker // INVALID: More than 6 marker characters.
|
|
52
|
-
`;
|
|
53
|
-
// Act & Assert.
|
|
54
|
-
expect(() => {
|
|
55
|
-
(0, parseSectionHeader_1.default)(invalidYini, eh, null);
|
|
56
|
-
}).toThrow();
|
|
57
|
-
});
|
|
58
|
-
test('2.a. Should throw error if parsing bad numeric shorthand marker header with (^).', () => {
|
|
59
|
-
// Arrange.
|
|
60
|
-
const invalidYini = `
|
|
61
|
-
^0 InvalidHeaderMarker // INVALID: Numeric shorthand marker.
|
|
62
|
-
value = 3
|
|
63
|
-
`;
|
|
64
|
-
// Act & Assert.
|
|
65
|
-
expect(() => {
|
|
66
|
-
(0, parseSectionHeader_1.default)(invalidYini, eh, null);
|
|
67
|
-
}).toThrow();
|
|
68
|
-
});
|
|
69
|
-
test('2.b. Should throw error if parsing bad numeric shorthand marker header with (~).', () => {
|
|
70
|
-
// Arrange.
|
|
71
|
-
const invalidYini = `
|
|
72
|
-
~0 InvalidHeaderMarker // INVALID: Numeric shorthand marker.
|
|
73
|
-
value = 3
|
|
74
|
-
`;
|
|
75
|
-
// Act & Assert.
|
|
76
|
-
expect(() => {
|
|
77
|
-
(0, parseSectionHeader_1.default)(invalidYini, eh, null);
|
|
78
|
-
}).toThrow();
|
|
79
|
-
});
|
|
80
|
-
test('2.c. Should throw error if parsing bad numeric shorthand marker header with (§).', () => {
|
|
81
|
-
// Arrange.
|
|
82
|
-
const invalidYini = `
|
|
83
|
-
§0 InvalidHeaderMarker // INVALID: Numeric shorthand marker.
|
|
84
|
-
value = 3
|
|
85
|
-
`;
|
|
86
|
-
// Act & Assert.
|
|
87
|
-
expect(() => {
|
|
88
|
-
(0, parseSectionHeader_1.default)(invalidYini, eh, null);
|
|
89
|
-
}).toThrow();
|
|
90
|
-
});
|
|
91
|
-
test('2.d. Should throw error if parsing bad numeric shorthand marker header with (€).', () => {
|
|
92
|
-
// Arrange.
|
|
93
|
-
const invalidYini = `
|
|
94
|
-
€0 InvalidHeaderMarker // INVALID: Numeric shorthand marker.
|
|
95
|
-
value = 3
|
|
96
|
-
`;
|
|
97
|
-
// Act & Assert.
|
|
98
|
-
expect(() => {
|
|
99
|
-
(0, parseSectionHeader_1.default)(invalidYini, eh, null);
|
|
100
|
-
}).toThrow();
|
|
101
|
-
});
|
|
102
|
-
test('3.a. Should throw error if parsing bad section header marker (^).', () => {
|
|
103
|
-
// Arrange.
|
|
104
|
-
const invalidYini = `
|
|
105
|
-
^^1 InvalidHeaderMarker // INVALID section header marker.
|
|
106
|
-
`;
|
|
107
|
-
// Act & Assert.
|
|
108
|
-
expect(() => {
|
|
109
|
-
(0, parseSectionHeader_1.default)(invalidYini, eh, null);
|
|
110
|
-
}).toThrow();
|
|
111
|
-
});
|
|
112
|
-
test('3.b. Should throw error if parsing bad section header marker (~).', () => {
|
|
113
|
-
// Arrange.
|
|
114
|
-
const invalidYini = `
|
|
115
|
-
~~10 InvalidHeaderMarker // INVALID section header marker.
|
|
116
|
-
`;
|
|
117
|
-
// Act & Assert.
|
|
118
|
-
expect(() => {
|
|
119
|
-
(0, parseSectionHeader_1.default)(invalidYini, eh, null);
|
|
120
|
-
}).toThrow();
|
|
121
|
-
});
|
|
122
|
-
test('3.c. Should throw error if parsing bad section header marker (§).', () => {
|
|
123
|
-
// Arrange.
|
|
124
|
-
const invalidYini = `
|
|
125
|
-
§§§1 InvalidHeaderMarker // INVALID section header marker.
|
|
126
|
-
`;
|
|
127
|
-
// Act & Assert.
|
|
128
|
-
expect(() => {
|
|
129
|
-
(0, parseSectionHeader_1.default)(invalidYini, eh, null);
|
|
130
|
-
}).toThrow();
|
|
131
|
-
});
|
|
132
|
-
test('3.d. Should throw error if parsing bad section header marker (€).', () => {
|
|
133
|
-
// Arrange.
|
|
134
|
-
const invalidYini = `
|
|
135
|
-
€€€ 3 InvalidHeaderMarker // INVALID section header marker.
|
|
136
|
-
`;
|
|
137
|
-
// Act & Assert.
|
|
138
|
-
expect(() => {
|
|
139
|
-
(0, parseSectionHeader_1.default)(invalidYini, eh, null);
|
|
140
|
-
}).toThrow();
|
|
141
|
-
});
|
|
142
|
-
test('4. Should throw error if mixing section header types.', () => {
|
|
143
|
-
// Arrange.
|
|
144
|
-
const invalidYini = `
|
|
145
|
-
^^^3 Section1 // NOT OK, bad section marker, cannot mix marker types.
|
|
146
|
-
`;
|
|
147
|
-
// Act & Assert.
|
|
148
|
-
expect(() => {
|
|
149
|
-
(0, parseSectionHeader_1.default)(invalidYini, eh, null);
|
|
150
|
-
}).toThrow();
|
|
151
|
-
});
|
|
152
|
-
test('5. Should throw error if mixing section header types.', () => {
|
|
153
|
-
// Arrange.
|
|
154
|
-
const invalidYini = `
|
|
155
|
-
~1 user3
|
|
156
|
-
username = 'tester three'
|
|
157
|
-
isSysOp = NO
|
|
158
|
-
|
|
159
|
-
~~2 prefs // NOT OK, bad section marker, cannot mix marker types.
|
|
160
|
-
theme = "special-dark"
|
|
161
|
-
notifications = ON
|
|
162
|
-
`;
|
|
163
|
-
// Act & Assert.
|
|
164
|
-
expect(() => {
|
|
165
|
-
(0, parseSectionHeader_1.default)(invalidYini, eh, null);
|
|
166
|
-
}).toThrow();
|
|
167
|
-
});
|
|
168
|
-
});
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const pathAndFileName_1 = require("../../../src/utils/pathAndFileName");
|
|
4
|
-
/**
|
|
5
|
-
* Utils-Path and File Name Unit Tests.
|
|
6
|
-
*/
|
|
7
|
-
describe('Utils-Path and File Name Unit Tests:', () => {
|
|
8
|
-
test('1. Get correct extension from file name.', () => {
|
|
9
|
-
// Arrange.
|
|
10
|
-
const fixture = 'config.yini';
|
|
11
|
-
// Act.
|
|
12
|
-
const result = (0, pathAndFileName_1.getFileNameExtension)(fixture);
|
|
13
|
-
// Assert.
|
|
14
|
-
expect(result).toEqual('.yini');
|
|
15
|
-
});
|
|
16
|
-
test('2. Get correct extension from file name.', () => {
|
|
17
|
-
// Arrange.
|
|
18
|
-
const fixture = 'config.YINI';
|
|
19
|
-
// Act.
|
|
20
|
-
const result = (0, pathAndFileName_1.getFileNameExtension)(fixture);
|
|
21
|
-
// Assert.
|
|
22
|
-
expect(result).toEqual('.YINI');
|
|
23
|
-
});
|
|
24
|
-
test('3. Get correct extension from file name.', () => {
|
|
25
|
-
// Arrange.
|
|
26
|
-
const fixture = 'My Config.yini';
|
|
27
|
-
// Act.
|
|
28
|
-
const result = (0, pathAndFileName_1.getFileNameExtension)(fixture);
|
|
29
|
-
// Assert.
|
|
30
|
-
expect(result).toEqual('.yini');
|
|
31
|
-
});
|
|
32
|
-
test('4. Get correct extension from file name.', () => {
|
|
33
|
-
// Arrange.
|
|
34
|
-
const fixture = 'My.Config.yini';
|
|
35
|
-
// Act.
|
|
36
|
-
const result = (0, pathAndFileName_1.getFileNameExtension)(fixture);
|
|
37
|
-
// Assert.
|
|
38
|
-
expect(result).toEqual('.yini');
|
|
39
|
-
});
|
|
40
|
-
test('5. Get correct extension from file name (edge-case).', () => {
|
|
41
|
-
// Arrange.
|
|
42
|
-
const fixture = ''; // (!) Blank!
|
|
43
|
-
// Act.
|
|
44
|
-
const result = (0, pathAndFileName_1.getFileNameExtension)(fixture);
|
|
45
|
-
// Assert.
|
|
46
|
-
expect(result).toEqual('');
|
|
47
|
-
});
|
|
48
|
-
test('6. Get correct extension from file name (edge-case).', () => {
|
|
49
|
-
// Arrange.
|
|
50
|
-
const fixture = 'Config'; // (!) Blank!
|
|
51
|
-
// Act.
|
|
52
|
-
const result = (0, pathAndFileName_1.getFileNameExtension)(fixture);
|
|
53
|
-
// Assert.
|
|
54
|
-
expect(result).toEqual('');
|
|
55
|
-
});
|
|
56
|
-
test('7. Get correct extension from file name (with "./" path).', () => {
|
|
57
|
-
// Arrange.
|
|
58
|
-
const fixture = './config/general.yini';
|
|
59
|
-
// Act.
|
|
60
|
-
const result = (0, pathAndFileName_1.getFileNameExtension)(fixture);
|
|
61
|
-
// Assert.
|
|
62
|
-
expect(result).toEqual('.yini');
|
|
63
|
-
});
|
|
64
|
-
test('8. Get correct extension from file name (with "../" path).', () => {
|
|
65
|
-
// Arrange.
|
|
66
|
-
const fixture = '../../../config/general.yini';
|
|
67
|
-
// Act.
|
|
68
|
-
const result = (0, pathAndFileName_1.getFileNameExtension)(fixture);
|
|
69
|
-
// Assert.
|
|
70
|
-
expect(result).toEqual('.yini');
|
|
71
|
-
});
|
|
72
|
-
test('9. Get correct extension from file name (with "\\" path).', () => {
|
|
73
|
-
// Arrange.
|
|
74
|
-
const fixture = '\config\general.yini';
|
|
75
|
-
// Act.
|
|
76
|
-
const result = (0, pathAndFileName_1.getFileNameExtension)(fixture);
|
|
77
|
-
// Assert.
|
|
78
|
-
expect(result).toEqual('.yini');
|
|
79
|
-
});
|
|
80
|
-
});
|