@@ -7,78 +7,78 @@ import type { GeneratorOptions } from '../interface.js';
77const tmpDir = join ( tmpdir ( ) , 'cpa-app-test' ) ;
88
99afterEach ( async ( ) => {
10- await remove ( tmpDir ) ;
10+ await remove ( tmpDir ) ;
1111} ) ;
1212
1313async function getAppContent ( options : GeneratorOptions ) : Promise < string > {
14- const { generateApp } = await import ( './app.js' ) ;
15- await generateApp ( tmpDir , options ) ;
16- return readFile ( join ( tmpDir , 'src/app.ts' ) , 'utf-8' ) ;
14+ const { generateApp } = await import ( './app.js' ) ;
15+ await generateApp ( tmpDir , options ) ;
16+ return readFile ( join ( tmpDir , 'src/app.ts' ) , 'utf-8' ) ;
1717}
1818
1919describe ( 'generateApp' , ( ) => {
20- it ( 'always imports express and oauthRouter' , async ( ) => {
21- const content = await getAppContent ( {
22- projectName : 'test-app' ,
23- database : 'postgres' ,
24- webhooks : false ,
25- appExtensions : [ ] ,
26- } ) ;
27- expect ( content ) . toContain ( "from 'express'" ) ;
28- expect ( content ) . toContain ( "from './oauth/index.js'" ) ;
29- expect ( content ) . toContain ( "app.use('/oauth'" ) ;
30- } ) ;
20+ it ( 'always imports express and oauthRouter' , async ( ) => {
21+ const content = await getAppContent ( {
22+ projectName : 'test-app' ,
23+ database : 'postgres' ,
24+ webhooks : false ,
25+ appExtensions : [ ] ,
26+ } ) ;
27+ expect ( content ) . toContain ( "from 'express'" ) ;
28+ expect ( content ) . toContain ( "from './oauth/index.js'" ) ;
29+ expect ( content ) . toContain ( "app.use('/oauth'" ) ;
30+ } ) ;
3131
32- it ( 'includes webhooks import and mount when webhooks is true' , async ( ) => {
33- const content = await getAppContent ( {
34- projectName : 'test-app' ,
35- database : 'postgres' ,
36- webhooks : true ,
37- appExtensions : [ ] ,
38- } ) ;
39- expect ( content ) . toContain ( "from './webhooks/index.js'" ) ;
40- expect ( content ) . toContain ( "app.use('/webhooks'" ) ;
41- } ) ;
32+ it ( 'includes webhooks import and mount when webhooks is true' , async ( ) => {
33+ const content = await getAppContent ( {
34+ projectName : 'test-app' ,
35+ database : 'postgres' ,
36+ webhooks : true ,
37+ appExtensions : [ ] ,
38+ } ) ;
39+ expect ( content ) . toContain ( "from './webhooks/index.js'" ) ;
40+ expect ( content ) . toContain ( "app.use('/webhooks'" ) ;
41+ } ) ;
4242
43- it ( 'excludes webhooks when webhooks is false' , async ( ) => {
44- const content = await getAppContent ( {
45- projectName : 'test-app' ,
46- database : 'postgres' ,
47- webhooks : false ,
48- appExtensions : [ ] ,
49- } ) ;
50- expect ( content ) . not . toContain ( './webhooks/index.js' ) ;
51- } ) ;
43+ it ( 'excludes webhooks when webhooks is false' , async ( ) => {
44+ const content = await getAppContent ( {
45+ projectName : 'test-app' ,
46+ database : 'postgres' ,
47+ webhooks : false ,
48+ appExtensions : [ ] ,
49+ } ) ;
50+ expect ( content ) . not . toContain ( './webhooks/index.js' ) ;
51+ } ) ;
5252
53- it ( 'includes panel import and mount when custom-panel is selected' , async ( ) => {
54- const content = await getAppContent ( {
55- projectName : 'test-app' ,
56- database : 'postgres' ,
57- webhooks : false ,
58- appExtensions : [ 'custom-panel' ] ,
59- } ) ;
60- expect ( content ) . toContain ( "from './app-extensions/panel/index.js'" ) ;
61- expect ( content ) . toContain ( "app.use('/extensions/panel'" ) ;
62- } ) ;
53+ it ( 'includes panel import and mount when custom-panel is selected' , async ( ) => {
54+ const content = await getAppContent ( {
55+ projectName : 'test-app' ,
56+ database : 'postgres' ,
57+ webhooks : false ,
58+ appExtensions : [ 'custom-panel' ] ,
59+ } ) ;
60+ expect ( content ) . toContain ( "from './app-extensions/panel/index.js'" ) ;
61+ expect ( content ) . toContain ( "app.use('/extensions/panel'" ) ;
62+ } ) ;
6363
64- it ( 'includes modal import and mount when custom-modal is selected' , async ( ) => {
65- const content = await getAppContent ( {
66- projectName : 'test-app' ,
67- database : 'postgres' ,
68- webhooks : false ,
69- appExtensions : [ 'custom-modal' ] ,
70- } ) ;
71- expect ( content ) . toContain ( "from './app-extensions/modal/index.js'" ) ;
72- expect ( content ) . toContain ( "app.use('/extensions/modal'" ) ;
73- } ) ;
64+ it ( 'includes modal import and mount when custom-modal is selected' , async ( ) => {
65+ const content = await getAppContent ( {
66+ projectName : 'test-app' ,
67+ database : 'postgres' ,
68+ webhooks : false ,
69+ appExtensions : [ 'custom-modal' ] ,
70+ } ) ;
71+ expect ( content ) . toContain ( "from './app-extensions/modal/index.js'" ) ;
72+ expect ( content ) . toContain ( "app.use('/extensions/modal'" ) ;
73+ } ) ;
7474
75- it ( 'excludes extension imports when appExtensions is empty' , async ( ) => {
76- const content = await getAppContent ( {
77- projectName : 'test-app' ,
78- database : 'sqlite' ,
79- webhooks : false ,
80- appExtensions : [ ] ,
81- } ) ;
82- expect ( content ) . not . toContain ( './app-extensions' ) ;
83- } ) ;
75+ it ( 'excludes extension imports when appExtensions is empty' , async ( ) => {
76+ const content = await getAppContent ( {
77+ projectName : 'test-app' ,
78+ database : 'sqlite' ,
79+ webhooks : false ,
80+ appExtensions : [ ] ,
81+ } ) ;
82+ expect ( content ) . not . toContain ( './app-extensions' ) ;
83+ } ) ;
8484} ) ;
0 commit comments