node-tar/test/normalize-windows-path.js

29 lines
891 B
JavaScript
Raw Permalink Normal View History

const t = require('tap')
const realPlatform = process.platform
const fakePlatform = realPlatform === 'win32' ? 'posix' : 'win32'
t.test('posix', t => {
2024-06-18 15:34:22 +08:00
if (realPlatform === 'win32') {
process.env.TESTING_TAR_FAKE_PLATFORM = fakePlatform
2024-06-18 15:34:22 +08:00
} else {
delete process.env.TESTING_TAR_FAKE_PLATFORM
2024-06-18 15:34:22 +08:00
}
const normPath = t.mock('../lib/normalize-windows-path.js')
t.equal(normPath('/some/path/back\\slashes'), '/some/path/back\\slashes')
t.equal(normPath('c:\\foo\\bar'), 'c:\\foo\\bar')
t.end()
})
t.test('win32', t => {
2024-06-18 15:34:22 +08:00
if (realPlatform !== 'win32') {
process.env.TESTING_TAR_FAKE_PLATFORM = fakePlatform
2024-06-18 15:34:22 +08:00
} else {
delete process.env.TESTING_TAR_FAKE_PLATFORM
2024-06-18 15:34:22 +08:00
}
const normPath = t.mock('../lib/normalize-windows-path.js')
t.equal(normPath('/some/path/back\\slashes'), '/some/path/back/slashes')
t.equal(normPath('c:\\foo\\bar'), 'c:/foo/bar')
t.end()
})