@@ -795,6 +795,62 @@ describe('volume', () => {
795
795
expect ( vol . readFileSync ( '/c1/c2/c3/c4/c5/final/a3/a4/a5/hello.txt' , 'utf8' ) ) . toBe ( 'world a' ) ;
796
796
} ) ;
797
797
} ) ;
798
+ describe ( 'Relative paths' , ( ) => {
799
+ it ( 'Creates symlinks with relative paths correctly' , ( ) => {
800
+ const vol = Volume . fromJSON ( {
801
+ '/test/target' : 'foo' ,
802
+ '/test/folder' : null ,
803
+ } ) ;
804
+
805
+ // Create symlink using relative path
806
+ vol . symlinkSync ( '../target' , '/test/folder/link' ) ;
807
+
808
+ // Verify we can read through the symlink
809
+ expect ( vol . readFileSync ( '/test/folder/link' , 'utf8' ) ) . toBe ( 'foo' ) ;
810
+
811
+ // Verify the symlink points to the correct location
812
+ const linkPath = vol . readlinkSync ( '/test/folder/link' ) ;
813
+ expect ( linkPath ) . toBe ( '../target' ) ;
814
+ } ) ;
815
+
816
+ it ( 'Handles nested relative symlinks' , ( ) => {
817
+ const vol = Volume . fromJSON ( {
818
+ '/a/b/target.txt' : 'content' ,
819
+ '/a/c/d' : null ,
820
+ } ) ;
821
+
822
+ // Create symlink in nested directory using relative path
823
+ vol . symlinkSync ( '../../b/target.txt' , '/a/c/d/link' ) ;
824
+
825
+ // Should be able to read through the symlink
826
+ expect ( vol . readFileSync ( '/a/c/d/link' , 'utf8' ) ) . toBe ( 'content' ) ;
827
+
828
+ // Create another symlink pointing to the first symlink
829
+ vol . symlinkSync ( './d/link' , '/a/c/link2' ) ;
830
+
831
+ // Should be able to read through both symlinks
832
+ expect ( vol . readFileSync ( '/a/c/link2' , 'utf8' ) ) . toBe ( 'content' ) ;
833
+ } ) ;
834
+
835
+ it ( 'Maintains relative paths when reading symlinks' , ( ) => {
836
+ const vol = Volume . fromJSON ( {
837
+ '/x/y/file.txt' : 'test content' ,
838
+ '/x/z' : null ,
839
+ } ) ;
840
+
841
+ // Create symlinks with different relative path patterns
842
+ vol . symlinkSync ( '../y/file.txt' , '/x/z/link1' ) ;
843
+ vol . symlinkSync ( '../../x/y/file.txt' , '/x/z/link2' ) ;
844
+
845
+ // Verify that readlink returns the original relative paths
846
+ expect ( vol . readlinkSync ( '/x/z/link1' ) ) . toBe ( '../y/file.txt' ) ;
847
+ expect ( vol . readlinkSync ( '/x/z/link2' ) ) . toBe ( '../../x/y/file.txt' ) ;
848
+
849
+ // Verify that all symlinks resolve correctly
850
+ expect ( vol . readFileSync ( '/x/z/link1' , 'utf8' ) ) . toBe ( 'test content' ) ;
851
+ expect ( vol . readFileSync ( '/x/z/link2' , 'utf8' ) ) . toBe ( 'test content' ) ;
852
+ } ) ;
853
+ } ) ;
798
854
} ) ;
799
855
describe ( '.symlink(target, path[, type], callback)' , ( ) => {
800
856
xit ( '...' , ( ) => { } ) ;
@@ -806,7 +862,7 @@ describe('volume', () => {
806
862
mootools . getNode ( ) . setString ( data ) ;
807
863
808
864
const symlink = vol . root . createChild ( 'mootools.link.js' ) ;
809
- symlink . getNode ( ) . makeSymlink ( [ 'mootools.js' ] ) ;
865
+ symlink . getNode ( ) . makeSymlink ( 'mootools.js' ) ;
810
866
811
867
it ( 'Symlink works' , ( ) => {
812
868
const resolved = vol . resolveSymlinks ( symlink ) ;
@@ -828,7 +884,7 @@ describe('volume', () => {
828
884
mootools . getNode ( ) . setString ( data ) ;
829
885
830
886
const symlink = vol . root . createChild ( 'mootools.link.js' ) ;
831
- symlink . getNode ( ) . makeSymlink ( [ 'mootools.js' ] ) ;
887
+ symlink . getNode ( ) . makeSymlink ( 'mootools.js' ) ;
832
888
833
889
it ( 'Basic one-jump symlink resolves' , done => {
834
890
vol . realpath ( '/mootools.link.js' , ( err , path ) => {
0 commit comments