@@ -19,10 +19,6 @@ import ImportCommand from '@contentstack/cli-cm-import';
1919import * as path from 'node:path' ;
2020import * as cliUtilities from '@contentstack/cli-utilities' ;
2121
22- // Mock process.chdir
23- const mockChdir = jest . fn ( ) ;
24- jest . spyOn ( process , 'chdir' ) . mockImplementation ( mockChdir ) ;
25-
2622describe ( 'Importer' , ( ) => {
2723 const mockOptions = {
2824 master_locale : 'en-us' ,
@@ -52,7 +48,6 @@ describe('Importer', () => {
5248 const expectedPath = path . resolve ( mockOptions . tmpPath , 'stack' ) ;
5349 expect ( cliUtilities . pathValidator ) . toHaveBeenCalledWith ( expectedPath ) ;
5450 expect ( cliUtilities . sanitizePath ) . toHaveBeenCalledWith ( mockOptions . tmpPath ) ;
55- expect ( mockChdir ) . toHaveBeenCalledWith ( mockOptions . tmpPath ) ;
5651 expect ( ImportCommand . run ) . toHaveBeenCalledWith ( [ '-k' , mockOptions . api_key , '-d' , expectedPath , '--skip-audit' ] ) ;
5752 } ) ;
5853
@@ -124,7 +119,6 @@ describe('Importer', () => {
124119
125120 const expectedPath = path . resolve ( testPath , 'stack' ) ;
126121 expect ( cliUtilities . pathValidator ) . toHaveBeenCalledWith ( expectedPath ) ;
127- expect ( mockChdir ) . toHaveBeenCalledWith ( testPath ) ;
128122 }
129123 } ) ;
130124
@@ -159,16 +153,6 @@ describe('Importer', () => {
159153 expect ( cliUtilities . pathValidator ) . toHaveBeenCalled ( ) ;
160154 } ) ;
161155
162- it ( 'should change directory before running import' , async ( ) => {
163- await importer . run ( mockOptions ) ;
164-
165- // Verify chdir is called before ImportCommand.run
166- const chdirCallOrder = mockChdir . mock . invocationCallOrder [ 0 ] ;
167- const importCallOrder = ( ImportCommand . run as jest . Mock ) . mock . invocationCallOrder [ 0 ] ;
168-
169- expect ( chdirCallOrder ) . toBeLessThan ( importCallOrder ) ;
170- } ) ;
171-
172156 it ( 'should handle import command errors' , async ( ) => {
173157 const mockError = new Error ( 'Import failed' ) ;
174158 ( ImportCommand . run as jest . Mock ) = jest . fn ( ) . mockRejectedValue ( mockError ) ;
0 commit comments