Skip to content

Commit

Permalink
Add tests and change formatPath to always format from win32
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristiano Belloni committed Jul 5, 2022
1 parent 8fd1e0d commit 799b789
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/modular-scripts/src/__tests__/utils/formatPath.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { normalizeToPosix } from '../../esbuild-scripts/utils/formatPath';

describe('Normalize path to Posix', () => {
it('should convert a Win32 path into a Posix path', () => {
expect(normalizeToPosix('\\this\\is\\my\\win32\\path')).toBe(
'/this/is/my/win32/path',
);
});
it('should convert a mixed path into a Posix path', () => {
expect(normalizeToPosix('/this/is\\my/mixed\\path')).toBe(
'/this/is/my/mixed/path',
);
});
it('should leave a Posix path untouched', () => {
expect(normalizeToPosix('/this/is/my/posix/path')).toBe(
'/this/is/my/posix/path',
);
});
it('should return undefined if undefined is passed', () => {
expect(normalizeToPosix(undefined)).toBeUndefined();
});
it('should convert a relative path to a relative Posix path', () => {
expect(normalizeToPosix('this\\is/my/relative\\mixed/path')).toBe(
'this/is/my/relative/mixed/path',
);
});
});

0 comments on commit 799b789

Please sign in to comment.