1
1
import { describe , expect , test } from 'vitest'
2
2
3
- import { createApp } from '../src/create-app.js'
4
- import { finalizeAddOns } from '../src/add-ons.js' ;
3
+ import { createApp } from '@tanstack/cta-engine'
4
+ import { finalizeAddOns , getFrameworkById } from '@tanstack/cta-core'
5
+
6
+ import { register as registerReactCra } from '@tanstack/cta-templates-react-cra'
7
+ import { register as registerSolid } from '@tanstack/cta-templates-solid'
8
+
5
9
import { cleanupOutput , createTestEnvironment } from './test-utilities.js'
6
10
11
+ registerReactCra ( )
12
+ registerSolid ( )
13
+
7
14
describe ( 'React Templates' , ( ) => {
8
15
test ( 'code router in javascript on npm' , async ( ) => {
9
16
const projectName = 'TEST'
10
17
const { environment, output } = createTestEnvironment ( projectName )
18
+ const framework = getFrameworkById ( 'react-cra' ) !
11
19
await createApp (
12
20
{
13
21
addOns : false ,
14
- framework : 'react' ,
22
+ framework,
15
23
chosenAddOns : [ ] ,
16
24
git : true ,
17
25
mode : 'code-router' ,
@@ -36,10 +44,11 @@ describe('React Templates', () => {
36
44
test ( 'code router in typescript on npm' , async ( ) => {
37
45
const projectName = 'TEST'
38
46
const { environment, output } = createTestEnvironment ( projectName )
47
+ const framework = getFrameworkById ( 'react-cra' ) !
39
48
await createApp (
40
49
{
41
50
addOns : false ,
42
- framework : 'react' ,
51
+ framework,
43
52
chosenAddOns : [ ] ,
44
53
git : true ,
45
54
mode : 'code-router' ,
@@ -64,10 +73,11 @@ describe('React Templates', () => {
64
73
test ( 'file router on npm' , async ( ) => {
65
74
const projectName = 'TEST'
66
75
const { environment, output } = createTestEnvironment ( projectName )
76
+ const framework = getFrameworkById ( 'react-cra' ) !
67
77
await createApp (
68
78
{
69
79
addOns : false ,
70
- framework : 'react' ,
80
+ framework,
71
81
chosenAddOns : [ ] ,
72
82
git : true ,
73
83
mode : 'file-router' ,
@@ -92,10 +102,11 @@ describe('React Templates', () => {
92
102
test ( 'file router with tailwind on npm' , async ( ) => {
93
103
const projectName = 'TEST'
94
104
const { environment, output } = createTestEnvironment ( projectName )
105
+ const framework = getFrameworkById ( 'react-cra' ) !
95
106
await createApp (
96
107
{
97
108
addOns : false ,
98
- framework : 'react' ,
109
+ framework,
99
110
chosenAddOns : [ ] ,
100
111
git : true ,
101
112
mode : 'file-router' ,
@@ -117,45 +128,46 @@ describe('React Templates', () => {
117
128
)
118
129
} )
119
130
120
- test ( 'file router with add-on start on npm' , async ( ) => {
121
- const projectName = 'TEST' ;
122
- const framework = 'react'
123
- const template = 'file-router'
124
- const { environment, output } = createTestEnvironment ( projectName ) ;
125
- await createApp (
126
- {
127
- addOns : true ,
128
- framework,
129
- chosenAddOns : await finalizeAddOns ( framework , template , [ 'start' ] ) ,
130
- git : true ,
131
- mode : template ,
132
- packageManager : 'npm' ,
133
- projectName,
134
- tailwind : true ,
135
- toolchain : 'none' ,
136
- typescript : true ,
137
- variableValues : { } ,
138
- } ,
139
- {
140
- silent : true ,
141
- environment,
142
- } ,
143
- ) ;
144
- cleanupOutput ( output ) ;
145
- await expect ( JSON . stringify ( output , null , 2 ) ) . toMatchFileSnapshot (
146
- './snapshots/cra/cr-ts-start-npm.json' ,
147
- ) ;
148
- } ) ;
131
+ test ( 'file router with add-on start on npm' , async ( ) => {
132
+ const projectName = 'TEST'
133
+ const framework = getFrameworkById ( 'react-cra' ) !
134
+ const template = 'file-router'
135
+ const { environment, output } = createTestEnvironment ( projectName )
136
+ await createApp (
137
+ {
138
+ addOns : true ,
139
+ framework,
140
+ chosenAddOns : await finalizeAddOns ( framework , template , [ 'start' ] ) ,
141
+ git : true ,
142
+ mode : template ,
143
+ packageManager : 'npm' ,
144
+ projectName,
145
+ tailwind : true ,
146
+ toolchain : 'none' ,
147
+ typescript : true ,
148
+ variableValues : { } ,
149
+ } ,
150
+ {
151
+ silent : true ,
152
+ environment,
153
+ } ,
154
+ )
155
+ cleanupOutput ( output )
156
+ await expect ( JSON . stringify ( output , null , 2 ) ) . toMatchFileSnapshot (
157
+ './snapshots/cra/cr-ts-start-npm.json' ,
158
+ )
159
+ } )
149
160
} )
150
161
151
162
describe ( 'Solid Templates' , ( ) => {
152
163
test ( 'code router in javascript on npm' , async ( ) => {
153
164
const projectName = 'TEST'
154
165
const { environment, output } = createTestEnvironment ( projectName )
166
+ const framework = getFrameworkById ( 'solid' ) !
155
167
await createApp (
156
168
{
157
169
addOns : false ,
158
- framework : 'solid' ,
170
+ framework,
159
171
chosenAddOns : [ ] ,
160
172
git : true ,
161
173
mode : 'code-router' ,
@@ -180,10 +192,11 @@ describe('Solid Templates', () => {
180
192
test ( 'code router in typescript on npm' , async ( ) => {
181
193
const projectName = 'TEST'
182
194
const { environment, output } = createTestEnvironment ( projectName )
195
+ const framework = getFrameworkById ( 'solid' ) !
183
196
await createApp (
184
197
{
185
198
addOns : false ,
186
- framework : 'solid' ,
199
+ framework,
187
200
chosenAddOns : [ ] ,
188
201
git : true ,
189
202
mode : 'code-router' ,
@@ -208,10 +221,11 @@ describe('Solid Templates', () => {
208
221
test ( 'file router on npm' , async ( ) => {
209
222
const projectName = 'TEST'
210
223
const { environment, output } = createTestEnvironment ( projectName )
224
+ const framework = getFrameworkById ( 'solid' ) !
211
225
await createApp (
212
226
{
213
227
addOns : false ,
214
- framework : 'solid' ,
228
+ framework,
215
229
chosenAddOns : [ ] ,
216
230
git : true ,
217
231
mode : 'file-router' ,
@@ -236,10 +250,11 @@ describe('Solid Templates', () => {
236
250
test ( 'file router with tailwind on npm' , async ( ) => {
237
251
const projectName = 'TEST'
238
252
const { environment, output } = createTestEnvironment ( projectName )
253
+ const framework = getFrameworkById ( 'solid' ) !
239
254
await createApp (
240
255
{
241
256
addOns : false ,
242
- framework : 'solid' ,
257
+ framework,
243
258
chosenAddOns : [ ] ,
244
259
git : true ,
245
260
mode : 'file-router' ,
@@ -261,33 +276,33 @@ describe('Solid Templates', () => {
261
276
)
262
277
} )
263
278
264
- test ( 'file router with add-on start on npm' , async ( ) => {
265
- const projectName = 'TEST' ;
266
- const framework = 'solid' ;
267
- const template = 'file-router' ;
268
- const { environment, output } = createTestEnvironment ( projectName ) ;
269
- await createApp (
270
- {
271
- addOns : true ,
272
- framework,
273
- chosenAddOns : await finalizeAddOns ( framework , template , [ 'start' ] ) ,
274
- git : true ,
275
- mode : template ,
276
- packageManager : 'npm' ,
277
- projectName,
278
- tailwind : true ,
279
- toolchain : 'none' ,
280
- typescript : true ,
281
- variableValues : { } ,
282
- } ,
283
- {
284
- silent : true ,
285
- environment,
286
- } ,
287
- ) ;
288
- cleanupOutput ( output ) ;
289
- await expect ( JSON . stringify ( output , null , 2 ) ) . toMatchFileSnapshot (
290
- './snapshots/cra/solid-cr-ts-start-npm.json' ,
291
- ) ;
292
- } ) ;
279
+ test ( 'file router with add-on start on npm' , async ( ) => {
280
+ const projectName = 'TEST'
281
+ const framework = getFrameworkById ( 'solid' ) !
282
+ const template = 'file-router'
283
+ const { environment, output } = createTestEnvironment ( projectName )
284
+ await createApp (
285
+ {
286
+ addOns : true ,
287
+ framework,
288
+ chosenAddOns : await finalizeAddOns ( framework , template , [ 'start' ] ) ,
289
+ git : true ,
290
+ mode : template ,
291
+ packageManager : 'npm' ,
292
+ projectName,
293
+ tailwind : true ,
294
+ toolchain : 'none' ,
295
+ typescript : true ,
296
+ variableValues : { } ,
297
+ } ,
298
+ {
299
+ silent : true ,
300
+ environment,
301
+ } ,
302
+ )
303
+ cleanupOutput ( output )
304
+ await expect ( JSON . stringify ( output , null , 2 ) ) . toMatchFileSnapshot (
305
+ './snapshots/cra/solid-cr-ts-start-npm.json' ,
306
+ )
307
+ } )
293
308
} )
0 commit comments