File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -76,4 +76,7 @@ async function start() {
7676
7777export { start } ;
7878
79- start ( ) ;
79+ /* istanbul ignore next */
80+ if ( process . argv [ 1 ] === fileURLToPath ( import . meta. url ) ) {
81+ start ( ) ;
82+ }
Original file line number Diff line number Diff line change @@ -36,10 +36,16 @@ describe('start function', () => {
3636 } ) ;
3737
3838 test ( 'should throw an error if no finance data is found' , async ( ) => {
39- const readdirSyncSpy = jest . spyOn ( fs , 'readdirSync' ) . mockReturnValue ( [ ] ) ;
39+ const originalReaddirSync = fs . readdirSync ;
40+ const readdirSyncSpy = jest . spyOn ( fs , 'readdirSync' ) . mockImplementation ( ( path ) => {
41+ if ( typeof path === 'string' && path . includes ( 'finance' ) ) {
42+ return [ ] as any ;
43+ }
44+ return originalReaddirSync ( path as any ) ;
45+ } ) ;
4046
4147 await expect ( start ( ) ) . rejects . toThrow ( 'No finance data found in the finance directory.' ) ;
42- expect ( readdirSyncSpy ) . toHaveBeenCalledTimes ( 1 ) ;
48+ expect ( readdirSyncSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( 'finance' ) ) ;
4349 expect ( buildFinanceInfoList ) . not . toHaveBeenCalled ( ) ;
4450
4551 readdirSyncSpy . mockRestore ( ) ;
You can’t perform that action at this time.
0 commit comments