11import { jest } from '@jest/globals' ;
22import { Config } from '@oclif/core' ;
33
4+ import { DEFAULT_ENV_PATH } from '../src/shared/index.js' ;
5+
46interface GetEnvResult {
57 envFilePath : string ;
68 env : Record < string , string > ;
@@ -24,7 +26,7 @@ jest.mock('@salesforce/sf-plugins-core', () => ({
2426 logSensitive = jest . fn ( ) ;
2527 } ,
2628 Flags : {
27- string : ( opts ?: { default ?: string } ) => opts ?. default ?? '.env' ,
29+ string : ( opts ?: { default ?: string } ) => opts ?. default ?? DEFAULT_ENV_PATH ,
2830 boolean : ( opts ?: { default ?: boolean } ) => opts ?. default ?? false ,
2931 } ,
3032} ) ) ;
@@ -43,7 +45,7 @@ describe('dotenv command', () => {
4345 beforeEach ( ( ) => {
4446 jest . clearAllMocks ( ) ;
4547 mockGetEnv . mockResolvedValue ( {
46- envFilePath : '.env' ,
48+ envFilePath : DEFAULT_ENV_PATH ,
4749 env : { FOO : 'bar' , BAZ : 'qux' } ,
4850 } ) ;
4951 } ) ;
@@ -54,7 +56,7 @@ describe('dotenv command', () => {
5456 ) : Promise < void > {
5557 const cmd = new DotEnv ( argv , mockConfig ) ;
5658 const resolvedFlags = {
57- env : flags . env ?? '.env' ,
59+ env : flags . env ?? DEFAULT_ENV_PATH ,
5860 'show-values' : flags [ 'show-values' ] ?? false ,
5961 } ;
6062 const mockParse = jest . fn ( ) as jest . Mock < ( ) => Promise < ParseResult > > ;
@@ -69,7 +71,7 @@ describe('dotenv command', () => {
6971 await runCommand ( [ 'dotenv' ] ) ;
7072
7173 expect ( mockGetEnv ) . toHaveBeenCalledTimes ( 1 ) ;
72- expect ( mockGetEnv ) . toHaveBeenCalledWith ( expect . any ( Array ) , true , '.env' ) ;
74+ expect ( mockGetEnv ) . toHaveBeenCalledWith ( expect . any ( Array ) , true , DEFAULT_ENV_PATH ) ;
7375 } ) ;
7476
7577 it ( 'calls getEnv with explicit path when --env is provided' , async ( ) => {
@@ -97,7 +99,7 @@ describe('dotenv command', () => {
9799
98100 expect ( mockDisplayLoadedEnvVars ) . toHaveBeenCalledTimes ( 1 ) ;
99101 expect ( mockDisplayLoadedEnvVars ) . toHaveBeenCalledWith (
100- { envFilePath : '.env' , env : { FOO : 'bar' , BAZ : 'qux' } } ,
102+ { envFilePath : DEFAULT_ENV_PATH , env : { FOO : 'bar' , BAZ : 'qux' } } ,
101103 { showValues : false }
102104 ) ;
103105 } ) ;
@@ -109,7 +111,7 @@ describe('dotenv command', () => {
109111
110112 expect ( mockDisplayLoadedEnvVars ) . toHaveBeenCalledTimes ( 1 ) ;
111113 const call = mockDisplayLoadedEnvVars . mock . calls [ 0 ] ;
112- expect ( call [ 0 ] ) . toEqual ( { envFilePath : '.env' , env : { FOO : 'bar' , BAZ : 'qux' } } ) ;
114+ expect ( call [ 0 ] ) . toEqual ( { envFilePath : DEFAULT_ENV_PATH , env : { FOO : 'bar' , BAZ : 'qux' } } ) ;
113115 expect ( call [ 1 ] ) . toMatchObject ( { showValues : true } ) ;
114116 } ) ;
115117 } ) ;
@@ -119,7 +121,7 @@ describe('dotenv command', () => {
119121 const cmd = new DotEnv ( [ 'dotenv' ] , mockConfig ) ;
120122 const mockParse = jest . fn ( ) as jest . Mock < ( ) => Promise < ParseResult > > ;
121123 mockParse . mockResolvedValue ( {
122- flags : { env : '.env' , 'show-values' : false } ,
124+ flags : { env : DEFAULT_ENV_PATH , 'show-values' : false } ,
123125 } ) ;
124126 ( cmd as unknown as { parse : typeof mockParse } ) . parse = mockParse ;
125127 jest . spyOn ( cmd , 'jsonEnabled' ) . mockReturnValue ( true ) ;
0 commit comments