@@ -7,7 +7,7 @@ import create from '../../cli-test-utils/createTestProject'
77import runServer from '../../cli-test-utils/createTestProjectServer'
88import runBuild from '../../cli-test-utils/buildTestProject'
99import {
10- defaultOptions ,
10+ defaultOptionsForTest ,
1111 getConfigs ,
1212} from '../../cli-test-utils/getPluginConfig'
1313import { formatToLf } from '../src/utils/formatCrlf'
@@ -156,6 +156,43 @@ test('ori init without plugins', async () => {
156156 expect ( project . has ( 'src/assets/originjs_readme.md' ) ) . toEqual ( false )
157157} , 10000 )
158158
159+ test ( 'ori init with store utils' , async ( ) => {
160+ const storeConfigs = [ 'pinia' , 'vuex' , 'none' ]
161+ const ProjectPath = path . join (
162+ process . cwd ( ) ,
163+ 'packages' ,
164+ 'cli-test-utils' ,
165+ DEMO_PATH ,
166+ )
167+
168+ for ( const value of storeConfigs ) {
169+ const config = Object . assign ( { } , defaultOptionsForTest , { store : value } )
170+ await initializeModules ( `store_utils_${ value } ` , config , true , ProjectPath )
171+ try {
172+ // skip files
173+ expect (
174+ fs . pathExistsSync (
175+ path . join ( ProjectPath , `store_utils_${ value } ` , 'src/store' ) ,
176+ ) ,
177+ ) . toEqual ( value !== 'none' )
178+ if ( value === 'none' ) {
179+ continue
180+ }
181+ const storeContent = formatToLf ( fs . readFileSync (
182+ path . join ( ProjectPath , `store_utils_${ value } ` , 'src/store/index.ts' ) , 'utf-8' ) )
183+ if ( value === 'pinia' ) {
184+ expect ( storeContent ) . toMatch ( results . storeCreationImportWithPinia )
185+ expect ( formatToLf ( storeContent ) ) . toMatch ( results . storeCreationWithPinia )
186+ } else if ( value === 'store' ) {
187+ expect ( storeContent ) . toMatch ( results . storeCreationImportWithVuex )
188+ expect ( formatToLf ( storeContent ) ) . toMatch ( results . storeCreationWithVuex )
189+ }
190+ } finally {
191+ fs . remove ( path . join ( ProjectPath , `store_utils_${ value } ` ) )
192+ }
193+ }
194+ } , 30000 )
195+
159196test ( 'ori init with test utils' , async ( ) => {
160197 const testConfigs = [ 'none' , 'jest' , 'vitest' ]
161198 const ProjectPath = path . join (
@@ -166,13 +203,13 @@ test('ori init with test utils', async () => {
166203 )
167204
168205 for ( const value of testConfigs ) {
169- const config = Object . assign ( { } , defaultOptions , { test : value } )
206+ const config = Object . assign ( { } , defaultOptionsForTest , { test : value } )
170207 await initializeModules ( `test_utils_${ value } ` , config , true , ProjectPath )
171- const packageJsonContent = fs . readFileSync (
172- path . join ( ProjectPath , `test_utils_${ value } ` , 'package.json' ) , 'utf-8' )
173- const viteConfigContent = formatToLf ( fs . readFileSync (
174- path . join ( ProjectPath , `test_utils_${ value } ` , 'vite.config.ts' ) , 'utf-8' ) )
175208 try {
209+ const packageJsonContent = fs . readFileSync (
210+ path . join ( ProjectPath , `test_utils_${ value } ` , 'package.json' ) , 'utf-8' )
211+ const viteConfigContent = formatToLf ( fs . readFileSync (
212+ path . join ( ProjectPath , `test_utils_${ value } ` , 'vite.config.ts' ) , 'utf-8' ) )
176213 if ( value === 'jest' ) {
177214 expect ( packageJsonContent ) . toMatch ( results . packageJsonScriptWithJest )
178215 } else if ( value === 'vitest' ) {
0 commit comments