quackage 1.0.50 → 1.0.53

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.
@@ -6,9 +6,24 @@
6
6
 
7
7
  var libQuackage = require('../source/Quackage-CLIProgram.js');
8
8
 
9
+ var libFS = require('fs');
10
+ var libPath = require('path');
11
+
9
12
  var Chai = require("chai");
10
13
  var Expect = Chai.expect;
11
14
 
15
+ // Helper to get the list of registered commander command names
16
+ var getCommandNames = function()
17
+ {
18
+ return libQuackage.CommandLineUtility._Command.commands.map((pCmd) => pCmd.name());
19
+ };
20
+
21
+ // Helper to get a registered commander command by name
22
+ var getCommand = function(pName)
23
+ {
24
+ return libQuackage.CommandLineUtility._Command.commands.find((pCmd) => pCmd.name() === pName);
25
+ };
26
+
12
27
  suite
13
28
  (
14
29
  'Quackage',
@@ -33,5 +48,799 @@ suite
33
48
  );
34
49
  }
35
50
  );
51
+
52
+ suite
53
+ (
54
+ 'All Commands Registration',
55
+ function()
56
+ {
57
+ test
58
+ (
59
+ 'All expected commands should be registered in the CLI.',
60
+ function()
61
+ {
62
+ let tmpCommandNames = getCommandNames();
63
+
64
+ // explain-config is auto-added by AutoAddConfigurationExplanationCommand
65
+ Expect(tmpCommandNames).to.include('explain-config');
66
+
67
+ // Package management
68
+ Expect(tmpCommandNames).to.include('updatepackage');
69
+ Expect(tmpCommandNames).to.include('luxuryupdatepackage');
70
+ Expect(tmpCommandNames).to.include('lint');
71
+
72
+ // Testing
73
+ Expect(tmpCommandNames).to.include('run-mocha-tests');
74
+
75
+ // Building
76
+ Expect(tmpCommandNames).to.include('build');
77
+ Expect(tmpCommandNames).to.include('copy-files-from-to');
78
+
79
+ // Documentation generation
80
+ Expect(tmpCommandNames).to.include('generate-documentation');
81
+
82
+ // Templates
83
+ Expect(tmpCommandNames).to.include('assemble_json_views');
84
+ Expect(tmpCommandNames).to.include('boilerplate');
85
+ Expect(tmpCommandNames).to.include('listtemplates');
86
+ Expect(tmpCommandNames).to.include('buildtemplates');
87
+
88
+ // Stricture
89
+ Expect(tmpCommandNames).to.include('stricture-compile');
90
+ Expect(tmpCommandNames).to.include('stricture-legaacy');
91
+
92
+ // Docuserve / Indoctrinate
93
+ Expect(tmpCommandNames).to.include('indoctrinate');
94
+ Expect(tmpCommandNames).to.include('indoctrinate-index');
95
+ Expect(tmpCommandNames).to.include('docuserve-inject');
96
+ Expect(tmpCommandNames).to.include('prepare-local');
97
+ Expect(tmpCommandNames).to.include('prepare-docs');
98
+ Expect(tmpCommandNames).to.include('docs-serve');
99
+
100
+ // HTML example serving
101
+ Expect(tmpCommandNames).to.include('examples-build');
102
+ Expect(tmpCommandNames).to.include('examples-serve');
103
+ Expect(tmpCommandNames).to.include('examples');
104
+ }
105
+ );
106
+
107
+ test
108
+ (
109
+ 'Commands should have correct aliases.',
110
+ function()
111
+ {
112
+ Expect(getCommand('updatepackage').aliases()).to.include('update_package');
113
+
114
+ Expect(getCommand('luxuryupdatepackage').aliases()).to.include('luxury_update_package');
115
+ Expect(getCommand('luxuryupdatepackage').aliases()).to.include('lux');
116
+
117
+ Expect(getCommand('run-mocha-tests').aliases()).to.include('test');
118
+
119
+ Expect(getCommand('copy-files-from-to').aliases()).to.include('copy');
120
+ Expect(getCommand('copy-files-from-to').aliases()).to.include('cp');
121
+
122
+ Expect(getCommand('generate-documentation').aliases()).to.include('dgen');
123
+
124
+ Expect(getCommand('assemble_json_views').aliases()).to.include('ajv');
125
+
126
+ Expect(getCommand('boilerplate').aliases()).to.include('boil');
127
+ Expect(getCommand('boilerplate').aliases()).to.include('bp');
128
+
129
+ Expect(getCommand('listtemplates').aliases()).to.include('list');
130
+ Expect(getCommand('listtemplates').aliases()).to.include('ls');
131
+ Expect(getCommand('listtemplates').aliases()).to.include('lt');
132
+
133
+ Expect(getCommand('buildtemplates').aliases()).to.include('bt');
134
+
135
+ Expect(getCommand('stricture-compile').aliases()).to.include('scomp');
136
+ Expect(getCommand('stricture-legaacy').aliases()).to.include('str');
137
+
138
+ Expect(getCommand('indoctrinate').aliases()).to.include('indoc');
139
+
140
+ Expect(getCommand('indoctrinate-index').aliases()).to.include('indoc-index');
141
+ Expect(getCommand('indoctrinate-index').aliases()).to.include('keyword-index');
142
+
143
+ Expect(getCommand('docuserve-inject').aliases()).to.include('docuserve');
144
+ Expect(getCommand('docuserve-inject').aliases()).to.include('inject-docs');
145
+
146
+ Expect(getCommand('prepare-local').aliases()).to.include('local-docs');
147
+ Expect(getCommand('prepare-local').aliases()).to.include('stage-local');
148
+
149
+ Expect(getCommand('prepare-docs').aliases()).to.include('docs');
150
+ Expect(getCommand('prepare-docs').aliases()).to.include('prep-docs');
151
+
152
+ Expect(getCommand('docs-serve').aliases()).to.include('serve-docs');
153
+ }
154
+ );
155
+ }
156
+ );
157
+
158
+ suite
159
+ (
160
+ 'Package Management Commands',
161
+ function()
162
+ {
163
+ test
164
+ (
165
+ 'UpdatePackage command class should require and have onRunAsync.',
166
+ function()
167
+ {
168
+ let tmpClass = require('../source/commands/Quackage-Command-UpdatePackage.js');
169
+ Expect(tmpClass).to.be.a('function');
170
+ Expect(tmpClass.prototype.onRunAsync).to.be.a('function');
171
+ }
172
+ );
173
+
174
+ test
175
+ (
176
+ 'UpdatePackage-Luxury command class should require and have onRunAsync.',
177
+ function()
178
+ {
179
+ let tmpClass = require('../source/commands/Quackage-Command-UpdatePackage-Luxury.js');
180
+ Expect(tmpClass).to.be.a('function');
181
+ Expect(tmpClass.prototype.onRunAsync).to.be.a('function');
182
+ }
183
+ );
184
+
185
+ test
186
+ (
187
+ 'Lint command class should require and have onRunAsync.',
188
+ function()
189
+ {
190
+ let tmpClass = require('../source/commands/Quackage-Command-Lint.js');
191
+ Expect(tmpClass).to.be.a('function');
192
+ Expect(tmpClass.prototype.onRunAsync).to.be.a('function');
193
+ }
194
+ );
195
+ }
196
+ );
197
+
198
+ suite
199
+ (
200
+ 'Test Execution Commands',
201
+ function()
202
+ {
203
+ test
204
+ (
205
+ 'RunMochaTests command class should require and have onRunAsync.',
206
+ function()
207
+ {
208
+ let tmpClass = require('../source/commands/Quackage-Command-RunMochaTests.js');
209
+ Expect(tmpClass).to.be.a('function');
210
+ Expect(tmpClass.prototype.onRunAsync).to.be.a('function');
211
+ }
212
+ );
213
+ }
214
+ );
215
+
216
+ suite
217
+ (
218
+ 'Build Commands',
219
+ function()
220
+ {
221
+ test
222
+ (
223
+ 'Build command class should require and have onRunAsync.',
224
+ function()
225
+ {
226
+ let tmpClass = require('../source/commands/Quackage-Command-Build.js');
227
+ Expect(tmpClass).to.be.a('function');
228
+ Expect(tmpClass.prototype.onRunAsync).to.be.a('function');
229
+ }
230
+ );
231
+
232
+ test
233
+ (
234
+ 'CopyFilesFromTo command class should require and have onRunAsync.',
235
+ function()
236
+ {
237
+ let tmpClass = require('../source/commands/Quackage-Command-CopyFilesFromTo.js');
238
+ Expect(tmpClass).to.be.a('function');
239
+ Expect(tmpClass.prototype.onRunAsync).to.be.a('function');
240
+ }
241
+ );
242
+ }
243
+ );
244
+
245
+ suite
246
+ (
247
+ 'Documentation Generation Commands',
248
+ function()
249
+ {
250
+ test
251
+ (
252
+ 'GenerateDocumentation command class should require and have expected methods.',
253
+ function()
254
+ {
255
+ let tmpClass = require('../source/commands/Quackage-Command-GenerateDocumentation.js');
256
+ Expect(tmpClass).to.be.a('function');
257
+ Expect(tmpClass.prototype.onRunAsync).to.be.a('function');
258
+ Expect(tmpClass.prototype.runJSDocCLI).to.be.a('function');
259
+ }
260
+ );
261
+ }
262
+ );
263
+
264
+ suite
265
+ (
266
+ 'Template Commands',
267
+ function()
268
+ {
269
+ test
270
+ (
271
+ 'AssembleJSONViews command class should require and have expected methods.',
272
+ function()
273
+ {
274
+ let tmpClass = require('../source/commands/Quackage-Command-AssembleJSONViews.js');
275
+ Expect(tmpClass).to.be.a('function');
276
+ Expect(tmpClass.prototype.onRunAsync).to.be.a('function');
277
+ Expect(tmpClass.prototype.generateView).to.be.a('function');
278
+ Expect(tmpClass.prototype.addView).to.be.a('function');
279
+ Expect(tmpClass.prototype.generateViewsRecursively).to.be.a('function');
280
+ Expect(tmpClass.prototype.generateViewsFromFolder).to.be.a('function');
281
+ }
282
+ );
283
+
284
+ test
285
+ (
286
+ 'Boilerplate command class should require and have onRunAsync.',
287
+ function()
288
+ {
289
+ let tmpClass = require('../source/commands/Quackage-Command-Boilerplate.js');
290
+ Expect(tmpClass).to.be.a('function');
291
+ Expect(tmpClass.prototype.onRunAsync).to.be.a('function');
292
+ }
293
+ );
294
+
295
+ test
296
+ (
297
+ 'ListTemplates command class should require and have onRunAsync.',
298
+ function()
299
+ {
300
+ let tmpClass = require('../source/commands/Quackage-Command-ListTemplates.js');
301
+ Expect(tmpClass).to.be.a('function');
302
+ Expect(tmpClass.prototype.onRunAsync).to.be.a('function');
303
+ }
304
+ );
305
+
306
+ test
307
+ (
308
+ 'BuildTemplates command class should require and have expected methods.',
309
+ function()
310
+ {
311
+ let tmpClass = require('../source/commands/Quackage-Command-BuildTemplates.js');
312
+ Expect(tmpClass).to.be.a('function');
313
+ Expect(tmpClass.prototype.onRunAsync).to.be.a('function');
314
+ Expect(tmpClass.prototype.getTemplateSet).to.be.a('function');
315
+ Expect(tmpClass.prototype.addTemplateToSet).to.be.a('function');
316
+ Expect(tmpClass.prototype.generateTemplatesRecursively).to.be.a('function');
317
+ Expect(tmpClass.prototype.generateTemplatesFromFolder).to.be.a('function');
318
+ }
319
+ );
320
+ }
321
+ );
322
+
323
+ suite
324
+ (
325
+ 'Stricture Commands',
326
+ function()
327
+ {
328
+ test
329
+ (
330
+ 'StrictureCompile command class should require and have onRunAsync.',
331
+ function()
332
+ {
333
+ let tmpClass = require('../source/commands/stricture/Quackage-Command-Stricture-Compile.js');
334
+ Expect(tmpClass).to.be.a('function');
335
+ Expect(tmpClass.prototype.onRunAsync).to.be.a('function');
336
+ }
337
+ );
338
+
339
+ test
340
+ (
341
+ 'StrictureLegacy command class should require and have onRunAsync.',
342
+ function()
343
+ {
344
+ let tmpClass = require('../source/commands/stricture/Quackage-Command-StrictureLegacy.js');
345
+ Expect(tmpClass).to.be.a('function');
346
+ Expect(tmpClass.prototype.onRunAsync).to.be.a('function');
347
+ }
348
+ );
349
+ }
350
+ );
351
+
352
+ suite
353
+ (
354
+ 'Docuserve and Indoctrinate Commands',
355
+ function()
356
+ {
357
+ test
358
+ (
359
+ 'Indoctrinate command class should require and have expected methods.',
360
+ function()
361
+ {
362
+ let tmpClass = require('../source/commands/Quackage-Command-Indoctrinate.js');
363
+ Expect(tmpClass).to.be.a('function');
364
+ Expect(tmpClass.prototype.onRunAsync).to.be.a('function');
365
+ Expect(tmpClass.prototype.resolveExecutable).to.be.a('function');
366
+ }
367
+ );
368
+
369
+ test
370
+ (
371
+ 'IndoctrinateIndex command class should require and have expected methods.',
372
+ function()
373
+ {
374
+ let tmpClass = require('../source/commands/Quackage-Command-IndoctrinateIndex.js');
375
+ Expect(tmpClass).to.be.a('function');
376
+ Expect(tmpClass.prototype.onRunAsync).to.be.a('function');
377
+ Expect(tmpClass.prototype.resolveExecutable).to.be.a('function');
378
+ }
379
+ );
380
+
381
+ test
382
+ (
383
+ 'DocuserveInject command class should require and have expected methods.',
384
+ function()
385
+ {
386
+ let tmpClass = require('../source/commands/Quackage-Command-DocuserveInject.js');
387
+ Expect(tmpClass).to.be.a('function');
388
+ Expect(tmpClass.prototype.onRunAsync).to.be.a('function');
389
+ Expect(tmpClass.prototype.resolveExecutable).to.be.a('function');
390
+ }
391
+ );
392
+
393
+ test
394
+ (
395
+ 'DocuservePrepareLocal command class should require and have expected methods.',
396
+ function()
397
+ {
398
+ let tmpClass = require('../source/commands/Quackage-Command-DocuservePrepareLocal.js');
399
+ Expect(tmpClass).to.be.a('function');
400
+ Expect(tmpClass.prototype.onRunAsync).to.be.a('function');
401
+ Expect(tmpClass.prototype.resolveExecutable).to.be.a('function');
402
+ }
403
+ );
404
+
405
+ test
406
+ (
407
+ 'PrepareDocs command class should require and have expected methods.',
408
+ function()
409
+ {
410
+ let tmpClass = require('../source/commands/Quackage-Command-PrepareDocs.js');
411
+ Expect(tmpClass).to.be.a('function');
412
+ Expect(tmpClass.prototype.onRunAsync).to.be.a('function');
413
+ Expect(tmpClass.prototype.resolveExecutable).to.be.a('function');
414
+ }
415
+ );
416
+
417
+ test
418
+ (
419
+ 'DocuserveServe command class should require and have expected methods.',
420
+ function()
421
+ {
422
+ let tmpClass = require('../source/commands/Quackage-Command-DocuserveServe.js');
423
+ Expect(tmpClass).to.be.a('function');
424
+ Expect(tmpClass.prototype.onRunAsync).to.be.a('function');
425
+ Expect(tmpClass.prototype.resolveExecutable).to.be.a('function');
426
+ }
427
+ );
428
+ }
429
+ );
430
+
431
+ suite
432
+ (
433
+ 'HTML Example Serving Commands',
434
+ function()
435
+ {
436
+ test
437
+ (
438
+ 'ExamplesBuild command class should require and have expected methods.',
439
+ function()
440
+ {
441
+ let tmpExamplesBuild = require('../source/commands/html_example_serving/Quackage-Command-ExamplesBuild.js');
442
+ Expect(tmpExamplesBuild).to.be.a('function');
443
+ Expect(tmpExamplesBuild.prototype.gatherExampleFolders).to.be.a('function');
444
+ Expect(tmpExamplesBuild.prototype.resolveExecutable).to.be.a('function');
445
+ Expect(tmpExamplesBuild.prototype.onRunAsync).to.be.a('function');
446
+ }
447
+ );
448
+
449
+ test
450
+ (
451
+ 'ExamplesServe command class should require and have expected methods.',
452
+ function()
453
+ {
454
+ let tmpExamplesServe = require('../source/commands/html_example_serving/Quackage-Command-ExamplesServe.js');
455
+ Expect(tmpExamplesServe).to.be.a('function');
456
+ Expect(tmpExamplesServe.prototype.gatherServableExamples).to.be.a('function');
457
+ Expect(tmpExamplesServe.prototype.hashProjectNameToPort).to.be.a('function');
458
+ Expect(tmpExamplesServe.prototype.generateIndexHTML).to.be.a('function');
459
+ Expect(tmpExamplesServe.prototype.formatDisplayName).to.be.a('function');
460
+ Expect(tmpExamplesServe.prototype.getMimeType).to.be.a('function');
461
+ Expect(tmpExamplesServe.prototype.onRunAsync).to.be.a('function');
462
+ }
463
+ );
464
+
465
+ test
466
+ (
467
+ 'Examples combined command class should require and have expected methods.',
468
+ function()
469
+ {
470
+ let tmpExamples = require('../source/commands/html_example_serving/Quackage-Command-Examples.js');
471
+ Expect(tmpExamples).to.be.a('function');
472
+ Expect(tmpExamples.prototype.onRunAsync).to.be.a('function');
473
+ }
474
+ );
475
+
476
+ test
477
+ (
478
+ 'ExamplesBuild.gatherExampleFolders should return empty array for nonexistent path.',
479
+ function()
480
+ {
481
+ let tmpExamplesBuild = require('../source/commands/html_example_serving/Quackage-Command-ExamplesBuild.js');
482
+ // Call the method without instantiation by borrowing it with a mock context
483
+ let tmpResult = tmpExamplesBuild.prototype.gatherExampleFolders.call({}, '/nonexistent/path/that/does/not/exist');
484
+ Expect(tmpResult).to.be.an('array');
485
+ Expect(tmpResult).to.have.length(0);
486
+ }
487
+ );
488
+
489
+ test
490
+ (
491
+ 'ExamplesServe.gatherServableExamples should return empty array for nonexistent path.',
492
+ function()
493
+ {
494
+ let tmpExamplesServe = require('../source/commands/html_example_serving/Quackage-Command-ExamplesServe.js');
495
+ let tmpResult = tmpExamplesServe.prototype.gatherServableExamples.call({
496
+ formatDisplayName: tmpExamplesServe.prototype.formatDisplayName
497
+ }, '/nonexistent/path/that/does/not/exist');
498
+ Expect(tmpResult).to.be.an('array');
499
+ Expect(tmpResult).to.have.length(0);
500
+ }
501
+ );
502
+
503
+ test
504
+ (
505
+ 'ExamplesServe.hashProjectNameToPort should return a port in the expected range.',
506
+ function()
507
+ {
508
+ let tmpExamplesServe = require('../source/commands/html_example_serving/Quackage-Command-ExamplesServe.js');
509
+ let tmpHash = tmpExamplesServe.prototype.hashProjectNameToPort;
510
+
511
+ let tmpPort1 = tmpHash('pict-section-form');
512
+ Expect(tmpPort1).to.be.at.least(9000);
513
+ Expect(tmpPort1).to.be.at.most(9500);
514
+
515
+ let tmpPort2 = tmpHash('pict-section-objecteditor');
516
+ Expect(tmpPort2).to.be.at.least(9000);
517
+ Expect(tmpPort2).to.be.at.most(9500);
518
+
519
+ // Same input should produce same output (deterministic)
520
+ let tmpPort3 = tmpHash('pict-section-form');
521
+ Expect(tmpPort3).to.equal(tmpPort1);
522
+
523
+ // Different inputs should (very likely) produce different ports
524
+ Expect(tmpPort1).to.not.equal(tmpPort2);
525
+ }
526
+ );
527
+
528
+ test
529
+ (
530
+ 'ExamplesServe.formatDisplayName should convert folder names to title case.',
531
+ function()
532
+ {
533
+ let tmpExamplesServe = require('../source/commands/html_example_serving/Quackage-Command-ExamplesServe.js');
534
+ let tmpFormat = tmpExamplesServe.prototype.formatDisplayName;
535
+
536
+ Expect(tmpFormat('simple_form')).to.equal('Simple Form');
537
+ Expect(tmpFormat('complex-table')).to.equal('Complex Table');
538
+ Expect(tmpFormat('debug')).to.equal('Debug');
539
+ Expect(tmpFormat('my_cool-example')).to.equal('My Cool Example');
540
+ }
541
+ );
542
+
543
+ test
544
+ (
545
+ 'ExamplesServe.getMimeType should return correct MIME types.',
546
+ function()
547
+ {
548
+ let tmpExamplesServe = require('../source/commands/html_example_serving/Quackage-Command-ExamplesServe.js');
549
+ let tmpMime = tmpExamplesServe.prototype.getMimeType;
550
+
551
+ Expect(tmpMime('.html')).to.equal('text/html');
552
+ Expect(tmpMime('.js')).to.equal('text/javascript');
553
+ Expect(tmpMime('.css')).to.equal('text/css');
554
+ Expect(tmpMime('.json')).to.equal('application/json');
555
+ Expect(tmpMime('.png')).to.equal('image/png');
556
+ Expect(tmpMime('.svg')).to.equal('image/svg+xml');
557
+ Expect(tmpMime('.map')).to.equal('application/json');
558
+ Expect(tmpMime('.xyz')).to.equal('application/octet-stream');
559
+ }
560
+ );
561
+
562
+ test
563
+ (
564
+ 'ExamplesServe.generateIndexHTML should produce valid HTML with example links.',
565
+ function()
566
+ {
567
+ let tmpExamplesServe = require('../source/commands/html_example_serving/Quackage-Command-ExamplesServe.js');
568
+ let tmpGenerate = tmpExamplesServe.prototype.generateIndexHTML;
569
+
570
+ let tmpExamples = [
571
+ { Name: 'simple_form', DisplayName: 'Simple Form', RelativePath: 'simple_form/dist/index.html', Type: 'example' },
572
+ { Name: 'debug', DisplayName: 'Debug', RelativePath: 'debug/index.html', Type: 'debug' }
573
+ ];
574
+
575
+ let tmpHTML = tmpGenerate('test-project', tmpExamples, 9123);
576
+
577
+ Expect(tmpHTML).to.be.a('string');
578
+ Expect(tmpHTML).to.include('<!DOCTYPE html>');
579
+ Expect(tmpHTML).to.include('test-project');
580
+ Expect(tmpHTML).to.include('simple_form/dist/index.html');
581
+ Expect(tmpHTML).to.include('Simple Form');
582
+ Expect(tmpHTML).to.include('debug/index.html');
583
+ Expect(tmpHTML).to.include('Debug');
584
+ Expect(tmpHTML).to.include('9123');
585
+ Expect(tmpHTML).to.include('2 example(s) found');
586
+ // Debug example should have the debug badge
587
+ Expect(tmpHTML).to.include('type-badge debug');
588
+ }
589
+ );
590
+
591
+ test
592
+ (
593
+ 'ExamplesBuild.gatherExampleFolders should find folders with package.json in a temp fixture.',
594
+ function()
595
+ {
596
+ let tmpExamplesBuild = require('../source/commands/html_example_serving/Quackage-Command-ExamplesBuild.js');
597
+ let tmpGather = tmpExamplesBuild.prototype.gatherExampleFolders;
598
+
599
+ // Create a temporary fixture
600
+ let tmpFixtureBase = libPath.join(__dirname, 'tmp_fixture_examples');
601
+ let tmpFixtureAppA = libPath.join(tmpFixtureBase, 'app_a');
602
+ let tmpFixtureAppB = libPath.join(tmpFixtureBase, 'app_b');
603
+ let tmpFixtureNoPackage = libPath.join(tmpFixtureBase, 'no_package');
604
+
605
+ libFS.mkdirSync(tmpFixtureAppA, { recursive: true });
606
+ libFS.mkdirSync(tmpFixtureAppB, { recursive: true });
607
+ libFS.mkdirSync(tmpFixtureNoPackage, { recursive: true });
608
+
609
+ libFS.writeFileSync(libPath.join(tmpFixtureAppA, 'package.json'), '{"name":"app_a"}');
610
+ libFS.writeFileSync(libPath.join(tmpFixtureAppB, 'package.json'), '{"name":"app_b"}');
611
+
612
+ let tmpResult = tmpGather.call({}, tmpFixtureBase);
613
+ Expect(tmpResult).to.be.an('array');
614
+ Expect(tmpResult).to.have.length(2);
615
+ Expect(tmpResult.map((pR) => pR.Name)).to.include('app_a');
616
+ Expect(tmpResult.map((pR) => pR.Name)).to.include('app_b');
617
+
618
+ // Cleanup
619
+ libFS.unlinkSync(libPath.join(tmpFixtureAppA, 'package.json'));
620
+ libFS.unlinkSync(libPath.join(tmpFixtureAppB, 'package.json'));
621
+ libFS.rmdirSync(tmpFixtureAppA);
622
+ libFS.rmdirSync(tmpFixtureAppB);
623
+ libFS.rmdirSync(tmpFixtureNoPackage);
624
+ libFS.rmdirSync(tmpFixtureBase);
625
+ }
626
+ );
627
+
628
+ test
629
+ (
630
+ 'ExamplesServe.gatherServableExamples should find examples with dist/index.html in a temp fixture.',
631
+ function()
632
+ {
633
+ let tmpExamplesServe = require('../source/commands/html_example_serving/Quackage-Command-ExamplesServe.js');
634
+ let tmpGather = tmpExamplesServe.prototype.gatherServableExamples;
635
+ let tmpFormat = tmpExamplesServe.prototype.formatDisplayName;
636
+
637
+ // Create a temporary fixture
638
+ let tmpFixtureBase = libPath.join(__dirname, 'tmp_fixture_serve');
639
+ let tmpFixtureDist = libPath.join(tmpFixtureBase, 'my_app', 'dist');
640
+ let tmpFixtureDebug = libPath.join(tmpFixtureBase, 'debug');
641
+ let tmpFixtureEmpty = libPath.join(tmpFixtureBase, 'empty_app');
642
+
643
+ libFS.mkdirSync(tmpFixtureDist, { recursive: true });
644
+ libFS.mkdirSync(tmpFixtureDebug, { recursive: true });
645
+ libFS.mkdirSync(tmpFixtureEmpty, { recursive: true });
646
+
647
+ libFS.writeFileSync(libPath.join(tmpFixtureDist, 'index.html'), '<html></html>');
648
+ libFS.writeFileSync(libPath.join(tmpFixtureDebug, 'index.html'), '<html></html>');
649
+
650
+ let tmpResult = tmpGather.call({ formatDisplayName: tmpFormat }, tmpFixtureBase);
651
+ Expect(tmpResult).to.be.an('array');
652
+ Expect(tmpResult).to.have.length(2);
653
+
654
+ let tmpNames = tmpResult.map((pR) => pR.Name);
655
+ Expect(tmpNames).to.include('my_app');
656
+ Expect(tmpNames).to.include('debug');
657
+
658
+ let tmpMyApp = tmpResult.find((pR) => pR.Name === 'my_app');
659
+ Expect(tmpMyApp.RelativePath).to.equal('my_app/dist/index.html');
660
+ Expect(tmpMyApp.Type).to.equal('example');
661
+
662
+ let tmpDebug = tmpResult.find((pR) => pR.Name === 'debug');
663
+ Expect(tmpDebug.RelativePath).to.equal('debug/index.html');
664
+ Expect(tmpDebug.Type).to.equal('debug');
665
+
666
+ // Cleanup
667
+ libFS.unlinkSync(libPath.join(tmpFixtureDist, 'index.html'));
668
+ libFS.unlinkSync(libPath.join(tmpFixtureDebug, 'index.html'));
669
+ libFS.rmdirSync(tmpFixtureDist);
670
+ libFS.rmdirSync(libPath.join(tmpFixtureBase, 'my_app'));
671
+ libFS.rmdirSync(tmpFixtureDebug);
672
+ libFS.rmdirSync(tmpFixtureEmpty);
673
+ libFS.rmdirSync(tmpFixtureBase);
674
+ }
675
+ );
676
+ }
677
+ );
678
+
679
+ suite
680
+ (
681
+ 'Default Configuration',
682
+ function()
683
+ {
684
+ test
685
+ (
686
+ 'Default configuration should have expected GulpExecutions.',
687
+ function()
688
+ {
689
+ let tmpConfig = require('../source/Default-Quackage-Configuration.json');
690
+ Expect(tmpConfig).to.be.an('object');
691
+ Expect(tmpConfig.GulpExecutions).to.be.an('array');
692
+ Expect(tmpConfig.GulpExecutions.length).to.be.at.least(1);
693
+ Expect(tmpConfig.GulpExecutions[0]).to.have.property('Hash');
694
+ Expect(tmpConfig.GulpExecutions[0]).to.have.property('Name');
695
+ Expect(tmpConfig.GulpExecutions[0]).to.have.property('BuildFileLabel');
696
+ Expect(tmpConfig.GulpExecutions[0]).to.have.property('BrowsersListRC');
697
+ }
698
+ );
699
+
700
+ test
701
+ (
702
+ 'Default configuration should have GulpfileConfiguration with template placeholders.',
703
+ function()
704
+ {
705
+ let tmpConfig = require('../source/Default-Quackage-Configuration.json');
706
+ Expect(tmpConfig.GulpfileConfiguration).to.be.an('object');
707
+ Expect(tmpConfig.GulpfileConfiguration).to.have.property('EntrypointInputSourceFile');
708
+ Expect(tmpConfig.GulpfileConfiguration).to.have.property('LibraryObjectName');
709
+ Expect(tmpConfig.GulpfileConfiguration).to.have.property('LibraryOutputFolder');
710
+ Expect(tmpConfig.GulpfileConfiguration).to.have.property('LibraryUniminifiedFileName');
711
+ Expect(tmpConfig.GulpfileConfiguration).to.have.property('LibraryMinifiedFileName');
712
+ }
713
+ );
714
+
715
+ test
716
+ (
717
+ 'Default configuration should have DefaultBabelRC with preset-env.',
718
+ function()
719
+ {
720
+ let tmpConfig = require('../source/Default-Quackage-Configuration.json');
721
+ Expect(tmpConfig.DefaultBabelRC).to.be.an('object');
722
+ Expect(tmpConfig.DefaultBabelRC.presets).to.be.an('array');
723
+ Expect(tmpConfig.DefaultBabelRC.presets).to.include('@babel/preset-env');
724
+ }
725
+ );
726
+
727
+ test
728
+ (
729
+ 'Default configuration should have PackageScripts.',
730
+ function()
731
+ {
732
+ let tmpConfig = require('../source/Default-Quackage-Configuration.json');
733
+ Expect(tmpConfig.PackageScripts).to.be.an('object');
734
+ Expect(tmpConfig.PackageScripts).to.have.property('test');
735
+ Expect(tmpConfig.PackageScripts).to.have.property('build');
736
+ Expect(tmpConfig.PackageScripts).to.have.property('coverage');
737
+ }
738
+ );
739
+
740
+ test
741
+ (
742
+ 'Default configuration should have LuxuryPackageScripts.',
743
+ function()
744
+ {
745
+ let tmpConfig = require('../source/Default-Quackage-Configuration.json');
746
+ Expect(tmpConfig.LuxuryPackageScripts).to.be.an('object');
747
+ Expect(tmpConfig.LuxuryPackageScripts).to.have.property('docker-dev-build');
748
+ Expect(tmpConfig.LuxuryPackageScripts).to.have.property('docker-dev-run');
749
+ Expect(tmpConfig.LuxuryPackageScripts).to.have.property('docker-dev-shell');
750
+ }
751
+ );
752
+ }
753
+ );
754
+
755
+ suite
756
+ (
757
+ 'Services',
758
+ function()
759
+ {
760
+ test
761
+ (
762
+ 'QuackageProcess service should be instantiated.',
763
+ function()
764
+ {
765
+ Expect(libQuackage.QuackageProcess).to.be.an('object');
766
+ Expect(libQuackage.QuackageProcess.execute).to.be.a('function');
767
+ Expect(libQuackage.QuackageProcess.cwd).to.be.a('function');
768
+ Expect(libQuackage.QuackageProcess.quackageFolder).to.be.a('function');
769
+ }
770
+ );
771
+
772
+ test
773
+ (
774
+ 'QuackageProcess.cwd should return a valid directory string.',
775
+ function()
776
+ {
777
+ let tmpCWD = libQuackage.QuackageProcess.cwd();
778
+ Expect(tmpCWD).to.be.a('string');
779
+ Expect(tmpCWD.length).to.be.greaterThan(0);
780
+ Expect(libFS.existsSync(tmpCWD)).to.equal(true);
781
+ }
782
+ );
783
+
784
+ test
785
+ (
786
+ 'QuackageProcess.quackageFolder should return a valid directory string.',
787
+ function()
788
+ {
789
+ let tmpFolder = libQuackage.QuackageProcess.quackageFolder();
790
+ Expect(tmpFolder).to.be.a('string');
791
+ Expect(tmpFolder.length).to.be.greaterThan(0);
792
+ Expect(libFS.existsSync(tmpFolder)).to.equal(true);
793
+ }
794
+ );
795
+
796
+ test
797
+ (
798
+ 'FilePersistence service should be instantiated.',
799
+ function()
800
+ {
801
+ Expect(libQuackage.FilePersistence).to.be.an('object');
802
+ }
803
+ );
804
+
805
+ test
806
+ (
807
+ 'AppData should have CWD and Package loaded.',
808
+ function()
809
+ {
810
+ Expect(libQuackage.AppData).to.be.an('object');
811
+ Expect(libQuackage.AppData.CWD).to.be.a('string');
812
+ Expect(libQuackage.AppData.QuackageFolder).to.be.a('string');
813
+ Expect(libQuackage.AppData.Package).to.be.an('object');
814
+ Expect(libQuackage.AppData.Package.name).to.equal('quackage');
815
+ }
816
+ );
817
+ }
818
+ );
819
+
820
+ suite
821
+ (
822
+ 'ProgramConfiguration',
823
+ function()
824
+ {
825
+ test
826
+ (
827
+ 'ProgramConfiguration should be loaded and have GulpExecutions.',
828
+ function()
829
+ {
830
+ Expect(libQuackage.ProgramConfiguration).to.be.an('object');
831
+ Expect(libQuackage.ProgramConfiguration.GulpExecutions).to.be.an('array');
832
+ }
833
+ );
834
+
835
+ test
836
+ (
837
+ 'ProgramConfiguration should have GulpfileConfiguration.',
838
+ function()
839
+ {
840
+ Expect(libQuackage.ProgramConfiguration.GulpfileConfiguration).to.be.an('object');
841
+ }
842
+ );
843
+ }
844
+ );
36
845
  }
37
- );
846
+ );