25import * as CONST from
'../constants';
34suite(
'Constants Validation Tests', () => {
40 test(
'Status codes are properly defined', () => {
41 assert.strictEqual(typeof CONST.statusError,
'number');
42 assert.strictEqual(typeof CONST.statusSuccess,
'number');
43 assert.notStrictEqual(CONST.statusError, CONST.statusSuccess);
44 assert.strictEqual(CONST.statusError, 1);
45 assert.strictEqual(CONST.statusSuccess, 0);
52 test(
'Extension identity strings are non-empty', () => {
53 assert.ok(CONST.extensionName.length > 0,
'Extension name should not be empty');
54 assert.ok(CONST.moduleName.length > 0,
'Module name should not be empty');
55 assert.ok(CONST.projectCopyright.length > 0,
'Project copyright should not be empty');
62 test(
'Extension name format validation', () => {
63 assert.strictEqual(CONST.extensionName,
'AsperHeader');
64 assert.strictEqual(CONST.moduleName,
'asperheader');
65 assert.match(CONST.projectCopyright, /\(c\)/,
'Copyright should contain (c) symbol');
72 test(
'Header decoration patterns are properly formatted', () => {
73 assert.ok(CONST.headerOpenerDecorationOpen.includes(
'+===='));
74 assert.ok(CONST.headerOpenerDecorationClose.includes(
'=================+'));
75 assert.strictEqual(typeof CONST.headerCommentSpacing,
'string');
82 test(
'Header decoration symmetry', () => {
83 const opener = CONST.headerOpenerDecorationOpen;
84 const closer = CONST.headerOpenerDecorationClose;
87 assert.ok(typeof opener ===
'string' && opener.length > 0,
'Opening decoration should be non-empty string');
88 assert.ok(typeof closer ===
'string' && closer.length > 0,
'Closing decoration should be non-empty string');
90 assert.ok(opener.length >= 1,
'Opening decoration should have meaningful content');
91 assert.ok(closer.length >= 1,
'Closing decoration should have meaningful content');
97 test(
'Telegraph protocol markers are defined', () => {
98 assert.strictEqual(CONST.telegraphBegin,
'BEGIN');
99 assert.strictEqual(CONST.telegraphEnd,
'END');
100 assert.strictEqual(CONST.telegraphBlockStop,
'/STOP');
101 assert.strictEqual(CONST.telegraphEndOfTransmission,
'// AR');
108 test(
'Telegraph markers follow proper format', () => {
109 assert.ok(CONST.telegraphBegin.length > 0);
110 assert.ok(CONST.telegraphEnd.length > 0);
111 assert.ok(CONST.telegraphBlockStop.startsWith(
'/'));
112 assert.ok(CONST.telegraphEndOfTransmission.includes(
'//'));
120 test(
'Header layout configuration types', () => {
121 assert.strictEqual(typeof CONST.headerAddBlankLineAfterMultiline,
'boolean');
122 assert.strictEqual(typeof CONST.headerKeyDefinitionSeparator,
'string');
123 assert.ok(CONST.headerKeyDefinitionSeparator.includes(
':'));
131 test(
'Header metadata keys are properly defined', () => {
134 CONST.headerProjectKey,
136 CONST.headerCreationDateKey,
137 CONST.headerLastModifiedKey,
138 CONST.headerDescriptionKey,
139 CONST.headerCopyrightKey,
141 CONST.headerPurposeKey
144 keys.forEach((key, index) => {
145 assert.ok(key.length > 0, `Header key ${index} should not be empty`);
146 assert.strictEqual(typeof key,
'string', `Header key ${index} should be
string`);
154 test(
'Header keys are unique', () => {
157 CONST.headerProjectKey,
159 CONST.headerCreationDateKey,
160 CONST.headerLastModifiedKey,
161 CONST.headerDescriptionKey,
162 CONST.headerCopyrightKey,
164 CONST.headerPurposeKey
167 const uniqueKeys =
new Set(keys);
168 assert.strictEqual(keys.length, uniqueKeys.size,
'All header keys should be unique');
176 test(
'Date and time separators are consistently defined', () => {
178 CONST.headerTimeSeperatorHour,
179 CONST.headerTimeSeperatorMinute,
180 CONST.headerTimeSeperatorSecond,
181 CONST.headerTimeAndDateSeperator,
182 CONST.headerDateSeperatorDay,
183 CONST.headerDateSeperatorMonth,
184 CONST.headerDateSeperatorYear
187 separators.forEach((separator, index) => {
188 assert.strictEqual(typeof separator,
'string', `Separator ${index} should be
string`);
197 test(
'Time separators follow expected patterns', () => {
198 assert.strictEqual(CONST.headerTimeSeperatorHour,
':');
199 assert.strictEqual(CONST.headerTimeSeperatorMinute,
':');
200 assert.strictEqual(CONST.headerDateSeperatorDay,
'-');
201 assert.strictEqual(CONST.headerDateSeperatorMonth,
'-');
209 test(
'Default header logo is properly structured', () => {
210 assert.ok(Array.isArray(CONST.defaultHeaderLogo),
'Logo should be an array');
211 assert.ok(CONST.defaultHeaderLogo.length > 0,
'Logo should have content');
213 CONST.defaultHeaderLogo.forEach((line, index) => {
214 assert.strictEqual(typeof line,
'string', `Logo line ${index} should be
string`);
215 assert.ok(line.length > 0, `Logo line ${index} should not be empty`);
223 test(
'ASCII art logo format consistency', () => {
224 const logo = CONST.defaultHeaderLogo;
225 const maxLength = Math.max(...
logo.map(line => line.length));
226 const minLength = Math.min(...
logo.map(line => line.length));
229 assert.ok(maxLength > 20,
'Logo should have reasonable width');
230 assert.ok(
logo.length > 10,
'Logo should have reasonable height');
231 assert.ok((maxLength - minLength) < maxLength * 0.5,
'Logo lines should have relatively consistent length');
240 test(
'ASCII art contains only valid characters', () => {
241 const validChars = /^[.\#\+\s]*$/;
243 CONST.defaultHeaderLogo.forEach((line, index) => {
244 assert.ok(validChars.test(line), `Logo line ${index} should contain only valid ASCII art characters (., #, +, space)`);
252 test(
'Versioned logos contain only valid characters', () => {
253 const validChars = /^[.\#\+\s]*$/;
254 Object.entries(CONST.headerLogoVersions).forEach(([version,
logo]) => {
255 assert.ok(Array.isArray(
logo), `Logo version ${version} should be an array`);
256 assert.ok(
logo.length > 0, `Logo version ${version} should not be empty`);
257 logo.forEach((line, index) => {
258 assert.ok(validChars.test(line), `Logo version ${version} line ${index} should contain only valid ASCII art characters (., #, +, space)`);
267 test(
'Default logo matches v2 version', () => {
269 assert.deepStrictEqual(CONST.defaultHeaderLogo, CONST.headerLogoVersions[
"v2"],
'defaultHeaderLogo should match v2 version');
276 test(
'All logo versions have reasonable dimensions', () => {
277 const allLogos: Record<string, string[]> = {
278 default: CONST.defaultHeaderLogo,
279 ...CONST.headerLogoVersions
281 Object.entries(allLogos).forEach(([name,
logo]) => {
282 assert.ok(
logo.length >= 10 &&
logo.length <= 40, `Logo ${name} height ${logo.length} should be between 10 and 40 lines`);
283 const maxLen = Math.max(...
logo.map(l => l.length));
284 const minLen = Math.min(...
logo.map(l => l.length));
285 assert.ok(maxLen > 20, `Logo ${name} should have reasonable width`);
286 assert.ok((maxLen - minLen) < maxLen * 0.5, `Logo ${name} lines should have relatively consistent length`);
295 test(
'Operational configuration values are valid', () => {
296 assert.strictEqual(typeof CONST.defaultMaxScanLength,
'number');
297 assert.strictEqual(typeof CONST.enableDebug,
'boolean');
298 assert.ok(CONST.defaultMaxScanLength > 0,
'Max scan length should be positive');
299 assert.ok(CONST.defaultMaxScanLength < 10000,
'Max scan length should be reasonable');
307 test(
'Feature toggles are properly typed', () => {
308 assert.strictEqual(typeof CONST.refreshOnSave,
'boolean');
309 assert.strictEqual(typeof CONST.promptToCreateIfMissing,
'boolean');
310 assert.strictEqual(typeof CONST.randomLogo,
'boolean');
311 assert.strictEqual(typeof CONST.useWorkspaceNameWhenAvailable,
'boolean');
319 test(
'Extension ignore list is properly formatted', () => {
320 assert.ok(Array.isArray(CONST.extensionIgnore),
'Extension ignore should be array');
322 CONST.extensionIgnore.forEach((ext, index) => {
323 assert.strictEqual(typeof ext,
'string', `Extension ${index} should be
string`);
332 test(
'Author logo is valid base64', () => {
333 assert.strictEqual(typeof CONST.authorLogo,
'string');
334 assert.ok(CONST.authorLogo.startsWith(
'data:image/png;base64,'),
'Author logo should be base64 PNG');
335 assert.ok(CONST.authorLogo.length > 100,
'Author logo should have substantial content');
338 const base64Part = CONST.authorLogo.split(
',')[1];
339 const base64Regex = /^[A-Za-z0-9+/]*={0,2}$/;
340 assert.ok(base64Regex.test(base64Part),
'Author logo should be valid base64');
348 test(
'Telegraph markers are distinct', () => {
350 CONST.telegraphBegin,
352 CONST.telegraphBlockStop,
353 CONST.telegraphEndOfTransmission
356 const uniqueMarkers =
new Set(markers);
357 assert.strictEqual(markers.length, uniqueMarkers.size,
'Telegraph markers should be unique');
364 test(
'Header keys follow consistent naming convention', () => {
367 CONST.headerProjectKey,
369 CONST.headerCreationDateKey,
370 CONST.headerLastModifiedKey,
371 CONST.headerDescriptionKey,
372 CONST.headerCopyrightKey,
374 CONST.headerPurposeKey
377 keys.forEach(key => {
378 assert.ok(key === key.toUpperCase() || key.includes(
' '),
379 'Header keys should be either all caps or contain spaces for readability');
388 test(
'Logo array is efficiently structured', () => {
389 const logo = CONST.defaultHeaderLogo;
390 const totalChars =
logo.reduce((sum, line) => sum + line.length, 0);
392 assert.ok(totalChars < 5000,
'Logo should not be excessively large for memory efficiency');
393 assert.ok(totalChars > 100,
'Logo should have sufficient detail');
400 test(
'Constants are immutable (frozen)', () => {
402 const originalName = CONST.extensionName;
406 assert.strictEqual(CONST.extensionName, originalName,
'Constants should be immutable');
import *as assert from assert
export const extensionName
Human-readable name of the extension.
Structure representing a loaded ASCII art logo with metadata.