@@ -4,12 +4,12 @@ import { describe, expect, it, vi } from 'vitest';
44
55import { createExec , process } from '../../testing/helpers/cli.js' ;
66
7- const { resolveAbsoluteImportPathFromCwd } = vi . hoisted ( ( ) => ( {
8- resolveAbsoluteImportPathFromCwd : vi . fn ( )
7+ const { resolveAbsoluteImportPath } = vi . hoisted ( ( ) => ( {
8+ resolveAbsoluteImportPath : vi . fn ( )
99} ) ) ;
1010
11- vi . mock ( '../../utils/ meta.utils .js' , ( ) => ( {
12- resolveAbsoluteImportPathFromCwd
11+ vi . mock ( '../../meta/resolve .js' , ( ) => ( {
12+ resolveAbsoluteImportPath
1313} ) ) ;
1414
1515const exec = createExec ( {
@@ -28,16 +28,17 @@ describe('libnest', () => {
2828 ) ;
2929 } ) ;
3030 it ( 'should throw an InvalidArgumentError if the config path cannot be resolved' , async ( ) => {
31+ process . cwd . mockReturnValueOnce ( '/app' ) ;
3132 const parseAsync = vi . spyOn ( Command . prototype , 'parseAsync' ) ;
32- resolveAbsoluteImportPathFromCwd . mockReturnValueOnce ( err ( 'Failed' ) ) ;
33+ resolveAbsoluteImportPath . mockReturnValueOnce ( err ( 'Failed' ) ) ;
3334 const result = await exec ( [ '-c' , 'libnest.config.ts' ] ) ;
3435 expect ( parseAsync ) . toHaveBeenCalledExactlyOnceWith ( [ 'node' , '../libnest.js' , '-c' , 'libnest.config.ts' ] ) ;
35- expect ( resolveAbsoluteImportPathFromCwd ) . toHaveBeenLastCalledWith ( 'libnest.config.ts' ) ;
36+ expect ( resolveAbsoluteImportPath ) . toHaveBeenLastCalledWith ( 'libnest.config.ts' , '/app ') ;
3637 expect ( result ) . toMatchObject ( { code : 'commander.invalidArgument' , exitCode : 1 } ) ;
3738 } ) ;
3839 it ( 'should pass the resolved config file to the subcommand' , async ( ) => {
3940 const hook = vi . spyOn ( Command . prototype , 'hook' ) ;
40- resolveAbsoluteImportPathFromCwd . mockReturnValueOnce ( ok ( '/root/path/to/file.js' ) ) ;
41+ resolveAbsoluteImportPath . mockReturnValueOnce ( ok ( '/root/path/to/file.js' ) ) ;
4142 await exec ( [ '-c' , 'libnest.config.ts' ] ) ;
4243 expect ( hook ) . toHaveBeenCalledExactlyOnceWith ( 'preSubcommand' , expect . any ( Function ) ) ;
4344 const callback = hook . mock . lastCall ! [ 1 ] ;
0 commit comments