test: cover path empty string case

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: https://github.com/nodejs/node/pull/24569
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
lakatostamas 2018-11-22 14:27:39 +01:00 committed by James M Snell
parent 36f483b79b
commit 13920ef41d
No known key found for this signature in database
GPG Key ID: 7341B15C070877AC

View File

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