@@ -155,37 +155,48 @@ describe('Credentials Storage Integration', () => {
155155 expect ( keys [ 0 ] ) . toBe ( 'default' )
156156 } )
157157
158- test ( 'should use manicode-dev directory in development environment' , ( ) => {
158+ test ( 'should use manicode-test directory in test environment' , async ( ) => {
159159 // Restore getConfigDir to use real implementation for this test
160160 mock . restore ( )
161- mockModule ( '@codebuff/common/env' , ( ) => {
162- return {
163- env : { NEXT_PUBLIC_CB_ENVIRONMENT : 'dev' } ,
164- }
165- } )
161+
162+ await mockModule ( '@codebuff/common/env' , ( ) => ( {
163+ env : { NEXT_PUBLIC_CB_ENVIRONMENT : 'test' } ,
164+ } ) )
166165
167166 // Call real getConfigDir to verify it includes '-dev'
168167 const configDir = authModule . getConfigDir ( )
169- expect ( configDir ) . toContain ( 'manicode-dev' )
170- expect ( configDir ) . not . toContain ( ' manicode/' )
171- expect ( configDir ) . not . toBe ( path . join ( os . homedir ( ) , '.config' , 'manicode' ) )
168+ expect ( configDir ) . toEqual (
169+ path . join ( os . homedir ( ) , '.config' , ' manicode-test' ) ,
170+ )
172171 } )
173172
174- test ( 'should use manicode directory in production environment' , ( ) => {
173+ test ( 'should use manicode-dev directory in development environment' , async ( ) => {
174+ // Restore getConfigDir to use real implementation for this test
175+ mock . restore ( )
176+
177+ await mockModule ( '@codebuff/common/env' , ( ) => ( {
178+ env : { NEXT_PUBLIC_CB_ENVIRONMENT : 'dev' } ,
179+ } ) )
180+
181+ // Call real getConfigDir to verify it includes '-dev'
182+ const configDir = authModule . getConfigDir ( )
183+ expect ( configDir ) . toEqual (
184+ path . join ( os . homedir ( ) , '.config' , 'manicode-dev' ) ,
185+ )
186+ } )
187+
188+ test ( 'should use manicode directory in production environment' , async ( ) => {
175189 // Restore getConfigDir to use real implementation
176190 mock . restore ( )
177191
178192 // Set environment to prod (or unset it)
179- mockModule ( '@codebuff/common/env' , ( ) => {
180- return {
181- env : { NEXT_PUBLIC_CB_ENVIRONMENT : 'prod' } ,
182- }
183- } )
193+ await mockModule ( '@codebuff/common/env' , ( ) => ( {
194+ env : { NEXT_PUBLIC_CB_ENVIRONMENT : 'prod' } ,
195+ } ) )
184196
185197 // Call real getConfigDir to verify it doesn't include '-dev'
186198 const configDir = authModule . getConfigDir ( )
187- expect ( configDir ) . toBe ( path . join ( os . homedir ( ) , '.config' , 'manicode' ) )
188- expect ( configDir ) . not . toContain ( 'manicode-dev' )
199+ expect ( configDir ) . toEqual ( path . join ( os . homedir ( ) , '.config' , 'manicode' ) )
189200 } )
190201
191202 test ( 'should allow credentials to persist across simulated CLI restarts' , ( ) => {
0 commit comments