@@ -462,6 +462,38 @@ describe('Environment', () => {
462
462
} ) ;
463
463
} ) ;
464
464
465
+ describe . only ( '#getGeneratorMeta{}' , ( ) => {
466
+ it ( 'importGenerator should return a class' , async function ( ) {
467
+ this . env
468
+ . register ( path . join ( __dirname , './fixtures/generator-module/generators/app' ) , 'fixtures:generator-module' ) ;
469
+ const meta = this . env . getGeneratorMeta ( 'fixtures:generator-module' ) ;
470
+ assert . equal ( typeof await meta . importGeneratorClass ( ) , 'function' ) ;
471
+ } ) ;
472
+ it ( 'importModule should return the generator module' , async function ( ) {
473
+ this . env
474
+ . register ( path . join ( __dirname , './fixtures/generator-module/generators/app' ) , 'fixtures:generator-module' ) ;
475
+ const meta = this . env . getGeneratorMeta ( 'fixtures:generator-module' ) ;
476
+ const Generator = await meta . importGeneratorClass ( ) ;
477
+ const module = await meta . importModule ( ) ;
478
+ assert . strictEqual ( Generator , module . default ) ;
479
+ } ) ;
480
+ it ( 'intantiate should return an instance' , async function ( ) {
481
+ this . env
482
+ . register ( path . join ( __dirname , './fixtures/generator-module/generators/app' ) , 'fixtures:generator-module' ) ;
483
+ const meta = this . env . getGeneratorMeta ( 'fixtures:generator-module' ) ;
484
+ const Generator = await meta . importGeneratorClass ( ) ;
485
+ const generator = await meta . instantiate ( ) ;
486
+ assert . ok ( generator instanceof Generator ) ;
487
+ } ) ;
488
+ it ( 'intantiateHelp should return an instance with help option' , async function ( ) {
489
+ this . env
490
+ . register ( path . join ( __dirname , './fixtures/generator-module/generators/app' ) , 'fixtures:generator-module' ) ;
491
+ const meta = this . env . getGeneratorMeta ( 'fixtures:generator-module' ) ;
492
+ const generator = await meta . instantiateHelp ( ) ;
493
+ assert . strictEqual ( generator . options . help , true ) ;
494
+ } ) ;
495
+ } ) ;
496
+
465
497
describe ( '#run() a ts generator' , ( ) => {
466
498
beforeEach ( function ( ) {
467
499
this . env
0 commit comments