@@ -11,56 +11,60 @@ jest.mock('fs/promises', () => ({
1111describe ( 'ResourceMonitor' ,  ( )  =>  { 
1212  describe ( 'getOutputDir' ,  ( )  =>  { 
1313    it ( 'prioritizes SF_RESOURCE_REPORTS_PATH' ,  async  ( )  =>  { 
14-       const  sfResourceReportsPath : string  =  '/ sf-resource-reports-path' ; 
14+       const  sfResourceReportsPath : string  =  ` ${ path . sep } ` ; 
1515      const  env : TestEnvironment  =  new  TestEnvironment ( { 
1616        SF_RESOURCE_REPORTS_PATH : sfResourceReportsPath , 
17-         XDG_DATA_HOME : '/ xdg-data-home' , 
18-         HOME : '/ home' 
17+         XDG_DATA_HOME : ` ${ path . sep } ` , 
18+         HOME : ` ${ path . sep } ` 
1919      } ) ; 
2020      const  expectedDir : string  =  sfResourceReportsPath ; 
2121      // SUT 
2222      await  env . monitor . record ( ) ; 
2323      expect ( mockFsPromises . writeFileCalls . length ) . toBeGreaterThan ( 0 ) ; 
24-       expect ( mockFsPromises . writeFileCalls [ 0 ] ) . toContain ( `${ expectedDir } / heap-info.csv` ) ; 
24+       expect ( mockFsPromises . writeFileCalls [ 0 ] ) . toContain ( `${ expectedDir } ${ path . sep }  ) ; 
2525      expect ( mockFsPromises . mkdirCalls . length ) . toBeGreaterThan ( 0 ) ; 
2626      expect ( mockFsPromises . mkdirCalls ) . toContain ( expectedDir ) ; 
2727    } ) ; 
2828
2929    it ( 'uses XDG_DATA_HOME when SF_RESOURCE_REPORTS_PATH is unset' ,  async  ( )  =>  { 
30-       const  xdgDataHome  =  '/xdg-data-home' ; 
31-       const  env  =  new  TestEnvironment ( {  SF_RESOURCE_REPORTS_PATH : null ,  XDG_DATA_HOME : xdgDataHome ,  HOME : '/home'  } ) ; 
30+       const  xdgDataHome  =  `${ path . sep }  ; 
31+       const  env  =  new  TestEnvironment ( { 
32+         SF_RESOURCE_REPORTS_PATH : null , 
33+         XDG_DATA_HOME : xdgDataHome , 
34+         HOME : `${ path . sep }  
35+       } ) ; 
3236      const  reportDirName : string  =  'sf-resource-reports' ; 
3337      const  expectedDir : string  =  path . join ( xdgDataHome ,  reportDirName ) ; 
3438      // SUT 
3539      await  env . monitor . record ( ) ; 
3640      expect ( mockFsPromises . writeFileCalls . length ) . toBeGreaterThan ( 0 ) ; 
37-       expect ( mockFsPromises . writeFileCalls [ 0 ] ) . toContain ( `${ expectedDir } / heap-info.csv` ) ; 
41+       expect ( mockFsPromises . writeFileCalls [ 0 ] ) . toContain ( `${ expectedDir } ${ path . sep }  ) ; 
3842      expect ( mockFsPromises . mkdirCalls . length ) . toBeGreaterThan ( 0 ) ; 
3943      expect ( mockFsPromises . mkdirCalls ) . toContain ( expectedDir ) ; 
4044    } ) ; 
4145
4246    it ( 'uses HOME when SF_RESOURCE_REPORTS_PATH and XDG_DATA_HOME are unset' ,  async  ( )  =>  { 
43-       const  env  =  new  TestEnvironment ( {  SF_RESOURCE_REPORTS_PATH : null ,  XDG_DATA_HOME : null ,  HOME : '/ home' } ) ; 
47+       const  env  =  new  TestEnvironment ( {  SF_RESOURCE_REPORTS_PATH : null ,  XDG_DATA_HOME : null ,  HOME : ` ${ path . sep } ` } ) ; 
4448      const  reportDirName : string  =  'sf-resource-reports' ; 
45-       const  expectedDir : string  =  path . join ( '/ home' ,  '.local' ,  'share' ,  reportDirName ) ; 
49+       const  expectedDir : string  =  path . join ( ` ${ path . sep } ` ,  '.local' ,  'share' ,  reportDirName ) ; 
4650      // SUT 
4751      await  env . monitor . record ( ) ; 
4852      expect ( mockFsPromises . writeFileCalls . length ) . toBeGreaterThan ( 0 ) ; 
49-       expect ( mockFsPromises . writeFileCalls [ 0 ] ) . toContain ( `${ expectedDir } / heap-info.csv` ) ; 
53+       expect ( mockFsPromises . writeFileCalls [ 0 ] ) . toContain ( `${ expectedDir } ${ path . sep }  ) ; 
5054      expect ( mockFsPromises . mkdirCalls . length ) . toBeGreaterThan ( 0 ) ; 
5155      expect ( mockFsPromises . mkdirCalls ) . toContain ( expectedDir ) ; 
5256    } ) ; 
5357
5458    it ( 'uses HOME when SF_RESOURCE_REPORTS_PATH is unset and XDG_DATA_HOME is empty' ,  async  ( )  =>  { 
5559      // XDG_DATA_HOME is not used if unset or empty 
5660      // (https://specifications.freedesktop.org/basedir-spec/latest/#variables). 
57-       const  env  =  new  TestEnvironment ( {  SF_RESOURCE_REPORTS_PATH : null ,  XDG_DATA_HOME : '' ,  HOME : '/ home' } ) ; 
61+       const  env  =  new  TestEnvironment ( {  SF_RESOURCE_REPORTS_PATH : null ,  XDG_DATA_HOME : '' ,  HOME : ` ${ path . sep } ` } ) ; 
5862      const  reportDirName : string  =  'sf-resource-reports' ; 
59-       const  expectedDir : string  =  path . join ( '/ home' ,  '.local' ,  'share' ,  reportDirName ) ; 
63+       const  expectedDir : string  =  path . join ( ` ${ path . sep } ` ,  '.local' ,  'share' ,  reportDirName ) ; 
6064      // SUT 
6165      await  env . monitor . record ( ) ; 
6266      expect ( mockFsPromises . writeFileCalls . length ) . toBeGreaterThan ( 0 ) ; 
63-       expect ( mockFsPromises . writeFileCalls [ 0 ] ) . toContain ( `${ expectedDir } / heap-info.csv` ) ; 
67+       expect ( mockFsPromises . writeFileCalls [ 0 ] ) . toContain ( `${ expectedDir } ${ path . sep }  ) ; 
6468      expect ( mockFsPromises . mkdirCalls . length ) . toBeGreaterThan ( 0 ) ; 
6569      expect ( mockFsPromises . mkdirCalls ) . toContain ( expectedDir ) ; 
6670    } ) ; 
@@ -72,7 +76,7 @@ describe('ResourceMonitor', () => {
7276      // SUT 
7377      await  env . monitor . record ( ) ; 
7478      expect ( mockFsPromises . writeFileCalls . length ) . toBeGreaterThan ( 0 ) ; 
75-       expect ( mockFsPromises . writeFileCalls [ 0 ] ) . toContain ( `${ expectedDir } / heap-info.csv` ) ; 
79+       expect ( mockFsPromises . writeFileCalls [ 0 ] ) . toContain ( `${ expectedDir } ${ path . sep }  ) ; 
7680      expect ( mockFsPromises . mkdirCalls . length ) . toBeGreaterThan ( 0 ) ; 
7781      expect ( mockFsPromises . mkdirCalls ) . toContain ( expectedDir ) ; 
7882    } ) ; 
0 commit comments