import { path } from '../path' describe('POSIX path conversion tests', () => { test('Ensure windows are converted to POSIX automatically', () => { expect(path.join('C:\\this\\is\\a\\path', 'to', 'file.txt')).toBe('C:/this/is/a/path/to/file.txt') expect(path.parse('C:\\this\\is\\a\\path\\to\\file.txt')).toEqual({ root: 'C:', dir: 'C:/this/is/a/path/to', base: 'file.txt', ext: '.txt', name: 'file', }) expect( path.format({ root: 'C:', dir: 'C:/this/is/a/path/to', base: 'file.txt', ext: '.txt', name: 'file', }) ).toBe('C:/this/is/a/path/to/file.txt') expect(path.resolve('C:\\this\\is\\a\\path', 'to', 'file.txt')).toBe('C:/this/is/a/path/to/file.txt') expect(path.dirname('C:\\this\\is\\a\\path\\to\\file.txt')).toBe('C:/this/is/a/path/to') expect(path.extname('C:\\this\\is\\a\\path\\to\\file.txt')).toBe('.txt') expect(path.basename('C:\\this\\is\\a\\path\\to\\file.txt')).toBe('file.txt') expect(path.relative('C:\\this\\is\\a\\path', 'C:\\this\\is\\a\\path\\to\\file.txt')).toBe('to/file.txt') expect(path.normalize('C:\\this\\is\\a\\path\\to\\file.txt')).toBe('C:/this/is/a/path/to/file.txt') expect(path.isAbsolute('C:\\this\\is\\a\\path\\to\\file.txt')).toBe(true) }) test('Ensure POSIX paths are handled normally', () => { expect(path.join('/this/is/a/path', 'to', 'file.txt')).toBe('/this/is/a/path/to/file.txt') expect(path.parse('/this/is/a/path/to/file.txt')).toEqual({ root: '/', dir: '/this/is/a/path/to', base: 'file.txt', ext: '.txt', name: 'file', }) expect( path.format({ root: '/', dir: '/this/is/a/path/to', base: 'file.txt', ext: '.txt', name: 'file', }) ).toBe('/this/is/a/path/to/file.txt') expect(path.resolve('/this/is/a/path', 'to', 'file.txt')).toBe('/this/is/a/path/to/file.txt') expect(path.dirname('/this/is/a/path/to/file.txt')).toBe('/this/is/a/path/to') expect(path.extname('/this/is/a/path/to/file.txt')).toBe('.txt') expect(path.basename('/this/is/a/path/to/file.txt')).toBe('file.txt') expect(path.relative('/this/is/a/path', '/this/is/a/path/to/file.txt')).toBe('to/file.txt') expect(path.normalize('/this/is/a/path/to/file.txt')).toBe('/this/is/a/path/to/file.txt') expect(path.isAbsolute('/this/is/a/path/to/file.txt,')).toBe(true) }) })