@@ -68,6 +68,7 @@ describe('th generate (UI template)', function () {
6868
6969 expect ( fs . existsSync ( path . join ( outDir , 'ui' , 'package.json' ) ) ) . to . equal ( true ) ;
7070 expect ( fs . existsSync ( path . join ( outDir , 'ui' , 'app' , 'page.tsx' ) ) ) . to . equal ( true ) ;
71+ expect ( fs . existsSync ( path . join ( outDir , 'ui' , 'tests' ) ) ) . to . equal ( false ) ;
7172
7273 const generatedThs = fs . readFileSync ( path . join ( outDir , 'ui' , 'src' , 'generated' , 'ths.ts' ) , 'utf-8' ) ;
7374 expect ( generatedThs ) . to . include ( 'export const ths =' ) ;
@@ -110,4 +111,29 @@ describe('th generate (UI template)', function () {
110111 expect ( fs . existsSync ( path . join ( outDir , 'contracts' , 'App.sol' ) ) ) . to . equal ( true ) ;
111112 expect ( fs . existsSync ( path . join ( outDir , 'ui' ) ) ) . to . equal ( false ) ;
112113 } ) ;
114+
115+ it ( 'emits generated app test scaffold with --with-tests' , function ( ) {
116+ const dir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , 'th-ui-gen-tests-' ) ) ;
117+ const schemaPath = path . join ( dir , 'schema.json' ) ;
118+ const outDir = path . join ( dir , 'out' ) ;
119+ writeJson ( schemaPath , minimalSchema ( ) ) ;
120+
121+ const res = runTh ( [ 'generate' , schemaPath , '--out' , outDir , '--with-tests' ] , process . cwd ( ) ) ;
122+ expect ( res . status , res . stderr || res . stdout ) . to . equal ( 0 ) ;
123+
124+ const uiDir = path . join ( outDir , 'ui' ) ;
125+ expect ( fs . existsSync ( path . join ( uiDir , 'tests' , 'contract' , 'smoke.mjs' ) ) ) . to . equal ( true ) ;
126+ expect ( fs . existsSync ( path . join ( uiDir , 'tests' , 'ui' , 'smoke.mjs' ) ) ) . to . equal ( true ) ;
127+
128+ const pkg = JSON . parse ( fs . readFileSync ( path . join ( uiDir , 'package.json' ) , 'utf-8' ) ) ;
129+ expect ( pkg ?. scripts ?. test ) . to . equal ( 'pnpm run test:contract && pnpm run test:ui' ) ;
130+ expect ( pkg ?. scripts ?. [ 'test:contract' ] ) . to . equal ( 'node tests/contract/smoke.mjs' ) ;
131+ expect ( pkg ?. scripts ?. [ 'test:ui' ] ) . to . equal ( 'node tests/ui/smoke.mjs' ) ;
132+
133+ const contractSmoke = runCmd ( 'node' , [ 'tests/contract/smoke.mjs' ] , uiDir ) ;
134+ expect ( contractSmoke . status , contractSmoke . stderr || contractSmoke . stdout ) . to . equal ( 0 ) ;
135+
136+ const uiSmoke = runCmd ( 'node' , [ 'tests/ui/smoke.mjs' ] , uiDir ) ;
137+ expect ( uiSmoke . status , uiSmoke . stderr || uiSmoke . stdout ) . to . equal ( 0 ) ;
138+ } ) ;
113139} ) ;
0 commit comments