22'use strict' ;
33
44const common = require ( '../common' ) ;
5+ const assert = require ( 'assert' ) ;
56const fs = require ( 'internal/fs/utils' ) ;
67
78// Valid encodings and no args should not throw.
@@ -12,3 +13,41 @@ common.expectsError(
1213 ( ) => fs . assertEncoding ( 'foo' ) ,
1314 { code : 'ERR_INVALID_OPT_VALUE_ENCODING' , type : TypeError }
1415) ;
16+
17+ // Test junction symlinks
18+ {
19+ const pathString = 'c:\\test1' ;
20+ const linkPathString = '\\test2' ;
21+
22+ const preprocessSymlinkDestination = fs . preprocessSymlinkDestination (
23+ pathString ,
24+ 'junction' ,
25+ linkPathString
26+ ) ;
27+
28+ if ( process . platform === 'win32' ) {
29+ assert . strictEqual ( / ^ \\ \\ \? \\ / . test ( preprocessSymlinkDestination ) , true ) ;
30+ } else {
31+ assert . strictEqual ( preprocessSymlinkDestination , pathString ) ;
32+ }
33+ }
34+
35+ // Test none junction symlinks
36+ {
37+ const pathString = 'c:\\test1' ;
38+ const linkPathString = '\\test2' ;
39+
40+ const preprocessSymlinkDestination = fs . preprocessSymlinkDestination (
41+ pathString ,
42+ undefined ,
43+ linkPathString
44+ ) ;
45+
46+ if ( process . platform === 'win32' ) {
47+ // There should not be any forward slashes
48+ assert . strictEqual (
49+ / \/ / . test ( preprocessSymlinkDestination ) , false ) ;
50+ } else {
51+ assert . strictEqual ( preprocessSymlinkDestination , pathString ) ;
52+ }
53+ }
0 commit comments