Skip to content

Commit 0896584

Browse files
committed
fixup: add tests so windows tests posix paths
1 parent 680b730 commit 0896584

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

lib/npa.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ function isFileSpec (spec) {
6666
if (isWindows) {
6767
return isWindowsFile.test(spec)
6868
}
69-
// We never hit this in windows tests, obviously
70-
/* istanbul ignore next */
7169
return isPosixFile.test(spec)
7270
}
7371

test/posix.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// redefine process.platform before any requires so that we don't cache a require that got the non-redefined value
2+
const { platform } = process
3+
Object.defineProperty(process, 'platform', { value: 'linux' })
4+
5+
const t = require('tap')
6+
const npa = require('..')
7+
8+
t.teardown(() => {
9+
Object.defineProperty(process, 'platform', { value: platform })
10+
})
11+
12+
// These are purely for coverage
13+
// We need tests that act like linux so that code paths are covered both ways when testing in windows itself.
14+
//
15+
t.test('file spec', t => {
16+
const actual = npa('./local')
17+
t.equal(actual.type, 'directory')
18+
t.equal(actual.raw, './local')
19+
t.end()
20+
})
21+
22+
t.test('encoded path', t => {
23+
const actual = npa('./path\\backslash')
24+
t.equal(actual.saveSpec, 'file:path/backslash')
25+
t.end()
26+
})

0 commit comments

Comments
 (0)