@@ -9,6 +9,7 @@ describe("Path Utilities", () => {
99 Object . defineProperty ( process , "platform" , {
1010 value : originalPlatform ,
1111 } )
12+ jest . restoreAllMocks ( )
1213 } )
1314
1415 describe ( "String.prototype.toPosix" , ( ) => {
@@ -78,20 +79,26 @@ describe("Path Utilities", () => {
7879 describe ( "edge cases" , ( ) => {
7980 it ( "should handle undefined paths" , ( ) => {
8081 expect ( arePathsEqual ( undefined , undefined ) ) . toBe ( true )
81- expect ( arePathsEqual ( "/test" , undefined ) ) . toBe ( false )
82- expect ( arePathsEqual ( undefined , "/test" ) ) . toBe ( false )
8382 } )
83+ expect ( arePathsEqual ( "/test" , undefined ) ) . toBe ( false )
84+ expect ( arePathsEqual ( undefined , "/test" ) ) . toBe ( false )
85+ } )
8486
85- it ( "should handle root paths with trailing slashes" , ( ) => {
86- expect ( arePathsEqual ( "/" , "/" ) ) . toBe ( true )
87- expect ( arePathsEqual ( "C:\\" , "C:\\" ) ) . toBe ( true )
88- } )
87+ it ( "should handle root paths with trailing slashes" , ( ) => {
88+ expect ( arePathsEqual ( "/" , "/" ) ) . toBe ( true )
89+ expect ( arePathsEqual ( "C:\\" , "C:\\" ) ) . toBe ( true )
8990 } )
9091 } )
9192
9293 describe ( "getReadablePath" , ( ) => {
93- const homeDir = os . homedir ( )
94- const desktop = path . join ( homeDir , "Desktop" )
94+ beforeEach ( ( ) => {
95+ jest . spyOn ( os , 'platform' ) . mockReturnValue ( 'linux' ) ;
96+ jest . spyOn ( os , 'platform' ) . mockReturnValue ( 'linux' ) ;
97+ // jest.spyOn(os, 'homedir').mockReturnValue('/Users/test');
98+ } )
99+
100+ // const homeDir = os.homedir()
101+ // const desktop = path.posix.join(homeDir, "Desktop")
95102
96103 it ( "should return basename when path equals cwd" , ( ) => {
97104 const cwd = "/Users/test/project"
@@ -111,8 +118,9 @@ describe("Path Utilities", () => {
111118 } )
112119
113120 it ( "should handle Desktop as cwd" , ( ) => {
114- const filePath = path . join ( desktop , "file.txt" )
115- expect ( getReadablePath ( desktop , filePath ) ) . toBe ( filePath . toPosix ( ) )
121+ const desktop = "/Users/test/Desktop"
122+ const filePath = "/Users/test/Desktop/file.txt"
123+ expect ( getReadablePath ( desktop , filePath ) ) . toBe ( filePath )
116124 } )
117125
118126 it ( "should handle undefined relative path" , ( ) => {
0 commit comments