Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions test/parallel/test-internal-fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
}
}