diff --git a/test/parallel/test-internal-fs.js b/test/parallel/test-internal-fs.js index 2e47e2a3823a9c..bfdf0022f421c3 100644 --- a/test/parallel/test-internal-fs.js +++ b/test/parallel/test-internal-fs.js @@ -2,6 +2,7 @@ 'use strict'; const common = require('../common'); +const assert = require('assert'); const fs = require('internal/fs/utils'); // Valid encodings and no args should not throw. @@ -12,3 +13,41 @@ common.expectsError( () => fs.assertEncoding('foo'), { code: 'ERR_INVALID_OPT_VALUE_ENCODING', type: TypeError } ); + +// Test junction symlinks +{ + const pathString = 'c:\\test1'; + const linkPathString = '\\test2'; + + const preprocessSymlinkDestination = fs.preprocessSymlinkDestination( + pathString, + 'junction', + linkPathString + ); + + if (process.platform === 'win32') { + assert.strictEqual(/^\\\\\?\\/.test(preprocessSymlinkDestination), true); + } else { + assert.strictEqual(preprocessSymlinkDestination, pathString); + } +} + +// Test none junction symlinks +{ + const pathString = 'c:\\test1'; + const linkPathString = '\\test2'; + + const preprocessSymlinkDestination = fs.preprocessSymlinkDestination( + pathString, + undefined, + linkPathString + ); + + if (process.platform === 'win32') { + // There should not be any forward slashes + assert.strictEqual( + /\//.test(preprocessSymlinkDestination), false); + } else { + assert.strictEqual(preprocessSymlinkDestination, pathString); + } +}