2
2
'use strict' ;
3
3
4
4
const common = require ( '../common' ) ;
5
+ const assert = require ( 'assert' ) ;
5
6
const fs = require ( 'internal/fs/utils' ) ;
6
7
7
8
// Valid encodings and no args should not throw.
@@ -12,3 +13,41 @@ common.expectsError(
12
13
( ) => fs . assertEncoding ( 'foo' ) ,
13
14
{ code : 'ERR_INVALID_OPT_VALUE_ENCODING' , type : TypeError }
14
15
) ;
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