Skip to content

Commit c3b26fa

Browse files
olaservoclaude
andcommitted
Fix platform-dependent relative path test in filesystem
The test was expecting forward slashes to always be converted to backslashes, but normalizePath() only does this on Windows (process.platform === 'win32'). On Linux/Unix, forward slashes are preserved. Improved the fix by: 1. Removing relative path assertion from the "as is" test since it doesn't match intent 2. Adding a dedicated test that validates platform-specific behavior naturally without mocking 3. Using the actual platform instead of unreliable Object.defineProperty mocking This approach is more reliable and clearly documents expected behavior per platform. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent bbbc0c6 commit c3b26fa

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

src/filesystem/__tests__/path-utils.test.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,8 @@ describe('Path Utilities', () => {
196196
});
197197

198198
it('returns normalized non-Windows/WSL/Unix-style Windows paths as is after basic normalization', () => {
199-
// Relative path
200-
const relativePath = 'some/relative/path';
201-
expect(normalizePath(relativePath)).toBe(relativePath.replace(/\//g, '\\'));
202-
203199
// A path that looks somewhat absolute but isn't a drive or recognized Unix root for Windows conversion
200+
// These paths should be preserved as-is (not converted to Windows C:\ format or WSL format)
204201
const otherAbsolutePath = '\\someserver\\share\\file';
205202
expect(normalizePath(otherAbsolutePath)).toBe(otherAbsolutePath);
206203
});
@@ -350,5 +347,19 @@ describe('Path Utilities', () => {
350347
expect(result).not.toContain('C:');
351348
expect(result).not.toContain('\\');
352349
});
350+
351+
it('should handle relative path slash conversion based on platform', () => {
352+
// This test verifies platform-specific behavior naturally without mocking
353+
// On Windows: forward slashes converted to backslashes
354+
// On Linux/Unix: forward slashes preserved
355+
const relativePath = 'some/relative/path';
356+
const result = normalizePath(relativePath);
357+
358+
if (originalPlatform === 'win32') {
359+
expect(result).toBe('some\\relative\\path');
360+
} else {
361+
expect(result).toBe('some/relative/path');
362+
}
363+
});
353364
});
354365
});

0 commit comments

Comments
 (0)