@@ -10,8 +10,12 @@ describe('codegen', () => {
1010 const manifestPath = `${ basePath } /manifests/manifest.yaml`
1111 const typesDirectory = `${ basePath } /src/types`
1212
13+ beforeEach ( 'clean generated files before each test' , ( ) => {
14+ if ( fs . existsSync ( typesDirectory ) ) fs . rmSync ( typesDirectory , { recursive : true , force : true } )
15+ } )
16+
1317 afterEach ( 'delete generated files' , ( ) => {
14- if ( fs . existsSync ( typesDirectory ) ) fs . rmSync ( typesDirectory , { recursive : true } )
18+ if ( fs . existsSync ( typesDirectory ) ) fs . rmSync ( typesDirectory , { recursive : true , force : true } )
1519 } )
1620
1721 context ( 'when the manifest exists' , ( ) => {
@@ -25,6 +29,20 @@ describe('codegen', () => {
2529 expect ( fs . existsSync ( `${ typesDirectory } /ERC20.ts` ) ) . to . be . true
2630 expect ( fs . existsSync ( `${ typesDirectory } /index.ts` ) ) . to . be . true
2731 } )
32+
33+ it ( 'accepts the function flag without affecting generated files' , async ( ) => {
34+ const { error } = await runCommand ( [ ...command , '--function' , `${ basePath } /functions/function.ts` ] )
35+ expect ( error ) . to . be . undefined
36+ expect ( fs . existsSync ( `${ typesDirectory } /ERC20.ts` ) ) . to . be . true
37+ expect ( fs . existsSync ( `${ typesDirectory } /index.ts` ) ) . to . be . true
38+ } )
39+
40+ it ( 'accepts the function shorthand flag without affecting generated files' , async ( ) => {
41+ const { error } = await runCommand ( [ ...command , `-f ${ basePath } /functions/function.ts` ] )
42+ expect ( error ) . to . be . undefined
43+ expect ( fs . existsSync ( `${ typesDirectory } /ERC20.ts` ) ) . to . be . true
44+ expect ( fs . existsSync ( `${ typesDirectory } /index.ts` ) ) . to . be . true
45+ } )
2846 } )
2947
3048 context ( 'when there are no inputs or abis' , ( ) => {
0 commit comments