Skip to content

Commit

Permalink
test: cover path empty string case
Browse files Browse the repository at this point in the history
In path.toNamespacePath was a case when the path
was empty string and it wasn't covered in the tests.

I covered this case both in Windows and Unix environments.

PR-URL: #24569
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
lakatostamas authored and BethGriggs committed Feb 12, 2019
1 parent ef68349 commit 288a421
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/parallel/test-path-makelong.js
Expand Up @@ -43,6 +43,7 @@ if (common.isWindows) {
'\\\\.\\pipe\\somepipe'); '\\\\.\\pipe\\somepipe');
} }


assert.strictEqual(path.toNamespacedPath(''), '');
assert.strictEqual(path.toNamespacedPath(null), null); assert.strictEqual(path.toNamespacedPath(null), null);
assert.strictEqual(path.toNamespacedPath(100), 100); assert.strictEqual(path.toNamespacedPath(100), 100);
assert.strictEqual(path.toNamespacedPath(path), path); assert.strictEqual(path.toNamespacedPath(path), path);
Expand All @@ -60,6 +61,7 @@ assert.strictEqual(path.posix.toNamespacedPath(emptyObj), emptyObj);
if (common.isWindows) { if (common.isWindows) {
// These tests cause resolve() to insert the cwd, so we cannot test them from // These tests cause resolve() to insert the cwd, so we cannot test them from
// non-Windows platforms (easily) // non-Windows platforms (easily)
assert.strictEqual(path.toNamespacedPath(''), '');
assert.strictEqual(path.win32.toNamespacedPath('foo\\bar').toLowerCase(), assert.strictEqual(path.win32.toNamespacedPath('foo\\bar').toLowerCase(),
`\\\\?\\${process.cwd().toLowerCase()}\\foo\\bar`); `\\\\?\\${process.cwd().toLowerCase()}\\foo\\bar`);
assert.strictEqual(path.win32.toNamespacedPath('foo/bar').toLowerCase(), assert.strictEqual(path.win32.toNamespacedPath('foo/bar').toLowerCase(),
Expand Down

0 comments on commit 288a421

Please sign in to comment.