1- /* eslint-disable @typescript-eslint/ban-ts-comment */
2- // @ts -nocheck
31import path , { dirname } from 'node:path' ;
42import { fileURLToPath } from 'node:url' ;
53import { beforeEach , describe , esmocha , expect , it } from 'esmocha' ;
@@ -15,6 +13,9 @@ type ParsedGenerator = {
1513const __filename = fileURLToPath ( import . meta. url ) ;
1614const __dirname = dirname ( __filename ) ;
1715
16+ const getRepository = ( env : Environment ) => ( env as any ) . repository ;
17+ const getComposedStore = ( env : Environment ) => ( env as any ) . composedStore ;
18+
1819describe ( 'environment (command)' , ( ) => {
1920 describe ( '#execute()' , ( ) => {
2021 let environment : Environment ;
@@ -30,22 +31,22 @@ describe('environment (command)', () => {
3031 adapter . addAnswers ( {
3132 aproveInstall : false ,
3233 } ) ;
33- environment . repository . install = esmocha . fn ( ) . mockReturnValue ( Promise . resolve ( [ ] ) ) ;
34+ getRepository ( environment ) . install = esmocha . fn ( ) . mockReturnValue ( Promise . resolve ( [ ] ) ) ;
3435 await expect ( environment . execute ( 'commands:options' ) ) . rejects . toThrow (
3536 / I n s t a l l a t i o n o f g e n e r a t o r - c o m m a n d s i s d e c l i n e d b y t h e u s e r . I n s t a l l m a n u a l l y a n d t r y a g a i n / ,
3637 ) ;
37- expect ( environment . repository . install ) . not . toHaveBeenCalled ( ) ;
38+ expect ( getRepository ( environment ) . install ) . not . toHaveBeenCalled ( ) ;
3839 } ) ;
3940
4041 it ( 'approving installation' , async ( ) => {
4142 adapter . addAnswers ( {
4243 aproveInstall : true ,
4344 } ) ;
44- environment . repository . install = esmocha . fn ( ) . mockReturnValue ( Promise . resolve ( [ ] ) ) ;
45+ getRepository ( environment ) . install = esmocha . fn ( ) . mockReturnValue ( Promise . resolve ( [ ] ) ) ;
4546 await expect ( environment . execute ( 'commands:options' ) ) . rejects . toThrow (
4647 / Y o u d o n ' t s e e m t o h a v e a g e n e r a t o r w i t h t h e n a m e “ g e n e r a t o r - c o m m a n d s ” i n s t a l l e d ./ ,
4748 ) ;
48- expect ( environment . repository . install ) . toHaveBeenCalledWith ( [ 'generator-commands' ] ) ;
49+ expect ( getRepository ( environment ) . install ) . toHaveBeenCalledWith ( [ 'generator-commands' ] ) ;
4950 } ) ;
5051 } ) ;
5152 } ) ;
@@ -55,7 +56,7 @@ describe('environment (command)', () => {
5556
5657 beforeEach ( async ( ) => {
5758 environment = new Environment ( { skipInstall : true , dryRun : true } ) ;
58- environment . adapter . log = esmocha . fn ( ) ;
59+ environment . adapter . log = esmocha . fn ( ) as any ;
5960 await environment . register ( path . join ( __dirname , 'fixtures/generator-commands/generators/options' ) ) ;
6061 } ) ;
6162
@@ -64,7 +65,7 @@ describe('environment (command)', () => {
6465 let generator : ParsedGenerator ;
6566 beforeEach ( async ( ) => {
6667 await environment . execute ( 'commands:options' ) ;
67- const generators = Object . values ( environment . composedStore . getGenerators ( ) ) as ParsedGenerator [ ] ;
68+ const generators = Object . values ( getComposedStore ( environment ) . getGenerators ( ) ) as ParsedGenerator [ ] ;
6869 expect ( generators . length ) . toEqual ( 1 ) ;
6970 generator = generators [ 0 ] ;
7071 } ) ;
@@ -90,7 +91,7 @@ describe('environment (command)', () => {
9091 'newValue' ,
9192 ] ) ;
9293
93- const generators = Object . values ( environment . composedStore . getGenerators ( ) ) as ParsedGenerator [ ] ;
94+ const generators = Object . values ( getComposedStore ( environment ) . getGenerators ( ) ) as ParsedGenerator [ ] ;
9495 expect ( generators . length ) . toEqual ( 1 ) ;
9596 generator = generators [ 0 ] ;
9697 } ) ;
@@ -108,7 +109,7 @@ describe('environment (command)', () => {
108109 let generator : ParsedGenerator ;
109110 beforeEach ( async ( ) => {
110111 await environment . execute ( 'commands:options' , [ '-b' , '-s' , 'customValue' ] ) ;
111- const generators = Object . values ( environment . composedStore . getGenerators ( ) ) as ParsedGenerator [ ] ;
112+ const generators = Object . values ( getComposedStore ( environment ) . getGenerators ( ) ) as ParsedGenerator [ ] ;
112113 expect ( generators . length ) . toEqual ( 1 ) ;
113114 generator = generators [ 0 ] ;
114115 } ) ;
@@ -126,7 +127,7 @@ describe('environment (command)', () => {
126127
127128 beforeEach ( ( ) => {
128129 environment = new Environment ( { skipInstall : true , dryRun : true } ) ;
129- environment . adapter . log = esmocha . fn ( ) ;
130+ environment . adapter . log = esmocha . fn ( ) as any ;
130131 environment . register ( path . join ( __dirname , 'fixtures/generator-commands/generators/arguments' ) ) ;
131132 } ) ;
132133
@@ -135,7 +136,7 @@ describe('environment (command)', () => {
135136 let generator : ParsedGenerator ;
136137 beforeEach ( async ( ) => {
137138 await environment . execute ( 'commands:arguments' ) ;
138- const generators = Object . values ( environment . composedStore . getGenerators ( ) ) as ParsedGenerator [ ] ;
139+ const generators = Object . values ( getComposedStore ( environment ) . getGenerators ( ) ) as ParsedGenerator [ ] ;
139140 expect ( generators . length ) . toEqual ( 1 ) ;
140141 generator = generators [ 0 ] ;
141142 } ) ;
@@ -149,7 +150,7 @@ describe('environment (command)', () => {
149150 let generator : ParsedGenerator ;
150151 beforeEach ( async ( ) => {
151152 await environment . execute ( 'commands:arguments' , [ 'foo' ] ) ;
152- const generators = Object . values ( environment . composedStore . getGenerators ( ) ) as ParsedGenerator [ ] ;
153+ const generators = Object . values ( getComposedStore ( environment ) . getGenerators ( ) ) as ParsedGenerator [ ] ;
153154 expect ( generators . length ) . toEqual ( 1 ) ;
154155 generator = generators [ 0 ] ;
155156 } ) ;
@@ -177,8 +178,8 @@ describe('environment (command)', () => {
177178 } ) ;
178179 await command . parseAsync ( [ 'node' , 'yo' , 'bar' ] ) ;
179180
180- environment = command . env ;
181- const generators = Object . values ( environment . composedStore . getGenerators ( ) ) as ParsedGenerator [ ] ;
181+ environment = command . env as Environment ;
182+ const generators = Object . values ( getComposedStore ( environment ) . getGenerators ( ) ) as ParsedGenerator [ ] ;
182183 expect ( generators . length ) . toEqual ( 1 ) ;
183184 generator = generators [ 0 ] ;
184185 } ) ;
@@ -208,8 +209,8 @@ describe('environment (command)', () => {
208209 'newValue' ,
209210 ] ) ;
210211
211- environment = command . env ;
212- const generators = Object . values ( environment . composedStore . getGenerators ( ) ) as ParsedGenerator [ ] ;
212+ environment = command . env as Environment ;
213+ const generators = Object . values ( getComposedStore ( environment ) . getGenerators ( ) ) as ParsedGenerator [ ] ;
213214 expect ( generators . length ) . toEqual ( 1 ) ;
214215 generator = generators [ 0 ] ;
215216 } ) ;
0 commit comments