@@ -865,4 +865,40 @@ describe(`ZipFS`, () => {
865
865
866
866
zipFs . discardAndClose ( ) ;
867
867
} ) ;
868
+
869
+ it ( `should throw ENOTDIR when trying to stat a file as a directory` , ( ) => {
870
+ const zipFs = new ZipFS ( null , { libzip : getLibzipSync ( ) } ) ;
871
+
872
+ zipFs . writeFileSync ( `/foo.txt` as PortablePath , `` ) ;
873
+ expect ( ( ) => zipFs . statSync ( `/foo.txt/` as PortablePath ) ) . toThrowError ( `ENOTDIR` ) ;
874
+
875
+ zipFs . symlinkSync ( `/foo.txt` as PortablePath , `/bar.txt` as PortablePath ) ;
876
+ expect ( ( ) => zipFs . lstatSync ( `/bar.txt/` as PortablePath ) ) . toThrowError ( `ENOTDIR` ) ;
877
+
878
+ zipFs . discardAndClose ( ) ;
879
+ } ) ;
880
+
881
+ it ( `should throw ENOTDIR when trying to create a file when the dirname is a file` , ( ) => {
882
+ const zipFs = new ZipFS ( null , { libzip : getLibzipSync ( ) } ) ;
883
+
884
+ zipFs . writeFileSync ( `/foo.txt` as PortablePath , `` ) ;
885
+ expect ( ( ) => zipFs . writeFileSync ( `/foo.txt/bar.txt` as PortablePath , `` ) ) . toThrowError ( `ENOTDIR` ) ;
886
+
887
+ zipFs . symlinkSync ( `/foo.txt` as PortablePath , `/bar.txt` as PortablePath ) ;
888
+ expect ( ( ) => zipFs . writeFileSync ( `/bar.txt/baz.txt` as PortablePath , `` ) ) . toThrowError ( `ENOTDIR` ) ;
889
+
890
+ zipFs . discardAndClose ( ) ;
891
+ } ) ;
892
+
893
+ it ( `should throw ENOENT when reading a file that doesn't exist` , ( ) => {
894
+ const zipFs = new ZipFS ( null , { libzip : getLibzipSync ( ) } ) ;
895
+
896
+ // File doesn't exist
897
+ expect ( ( ) => zipFs . readFileSync ( `/foo` as PortablePath , `` ) ) . toThrowError ( `ENOENT` ) ;
898
+
899
+ // Parent entry doesn't exist
900
+ expect ( ( ) => zipFs . readFileSync ( `/foo/bar` as PortablePath , `` ) ) . toThrowError ( `ENOENT` ) ;
901
+
902
+ zipFs . discardAndClose ( ) ;
903
+ } ) ;
868
904
} ) ;
0 commit comments