11import { describe , expect , it } from "vitest" ;
2- import { VirtualFs } from "./fs.js" ;
2+ import { InMemoryFs } from "./in-memory- fs.js" ;
33
4- describe ( "VirtualFs Buffer and Encoding Support" , ( ) => {
4+ describe ( "InMemoryFs Buffer and Encoding Support" , ( ) => {
55 describe ( "basic Buffer operations" , ( ) => {
66 it ( "should write and read Uint8Array" , async ( ) => {
7- const fs = new VirtualFs ( ) ;
7+ const fs = new InMemoryFs ( ) ;
88 const data = new Uint8Array ( [ 0x48 , 0x65 , 0x6c , 0x6c , 0x6f ] ) ; // "Hello"
99
1010 await fs . writeFile ( "/binary.bin" , data ) ;
@@ -14,7 +14,7 @@ describe("VirtualFs Buffer and Encoding Support", () => {
1414 } ) ;
1515
1616 it ( "should write Uint8Array and read as string" , async ( ) => {
17- const fs = new VirtualFs ( ) ;
17+ const fs = new InMemoryFs ( ) ;
1818 const data = new Uint8Array ( [ 0x48 , 0x65 , 0x6c , 0x6c , 0x6f ] ) ; // "Hello"
1919
2020 await fs . writeFile ( "/test.txt" , data ) ;
@@ -24,7 +24,7 @@ describe("VirtualFs Buffer and Encoding Support", () => {
2424 } ) ;
2525
2626 it ( "should write string and read as Uint8Array" , async ( ) => {
27- const fs = new VirtualFs ( ) ;
27+ const fs = new InMemoryFs ( ) ;
2828
2929 await fs . writeFile ( "/test.txt" , "Hello" ) ;
3030 const result = await fs . readFileBuffer ( "/test.txt" ) ;
@@ -33,7 +33,7 @@ describe("VirtualFs Buffer and Encoding Support", () => {
3333 } ) ;
3434
3535 it ( "should handle binary data with null bytes" , async ( ) => {
36- const fs = new VirtualFs ( ) ;
36+ const fs = new InMemoryFs ( ) ;
3737 const data = new Uint8Array ( [ 0x00 , 0x01 , 0x00 , 0xff , 0x00 ] ) ;
3838
3939 await fs . writeFile ( "/binary.bin" , data ) ;
@@ -43,7 +43,7 @@ describe("VirtualFs Buffer and Encoding Support", () => {
4343 } ) ;
4444
4545 it ( "should calculate correct size for binary files" , async ( ) => {
46- const fs = new VirtualFs ( ) ;
46+ const fs = new InMemoryFs ( ) ;
4747 const data = new Uint8Array ( [ 0x00 , 0x01 , 0x02 , 0x03 , 0x04 ] ) ;
4848
4949 await fs . writeFile ( "/binary.bin" , data ) ;
@@ -55,7 +55,7 @@ describe("VirtualFs Buffer and Encoding Support", () => {
5555
5656 describe ( "encoding support" , ( ) => {
5757 it ( "should write and read with utf8 encoding" , async ( ) => {
58- const fs = new VirtualFs ( ) ;
58+ const fs = new InMemoryFs ( ) ;
5959
6060 await fs . writeFile ( "/test.txt" , "Hello 世界" , "utf8" ) ;
6161 const result = await fs . readFile ( "/test.txt" , "utf8" ) ;
@@ -64,7 +64,7 @@ describe("VirtualFs Buffer and Encoding Support", () => {
6464 } ) ;
6565
6666 it ( "should write and read with base64 encoding" , async ( ) => {
67- const fs = new VirtualFs ( ) ;
67+ const fs = new InMemoryFs ( ) ;
6868
6969 // "Hello" in base64 is "SGVsbG8="
7070 await fs . writeFile ( "/test.txt" , "SGVsbG8=" , "base64" ) ;
@@ -74,7 +74,7 @@ describe("VirtualFs Buffer and Encoding Support", () => {
7474 } ) ;
7575
7676 it ( "should read as base64" , async ( ) => {
77- const fs = new VirtualFs ( ) ;
77+ const fs = new InMemoryFs ( ) ;
7878
7979 await fs . writeFile ( "/test.txt" , "Hello" ) ;
8080 const result = await fs . readFile ( "/test.txt" , "base64" ) ;
@@ -83,7 +83,7 @@ describe("VirtualFs Buffer and Encoding Support", () => {
8383 } ) ;
8484
8585 it ( "should write and read with hex encoding" , async ( ) => {
86- const fs = new VirtualFs ( ) ;
86+ const fs = new InMemoryFs ( ) ;
8787
8888 // "Hello" in hex is "48656c6c6f"
8989 await fs . writeFile ( "/test.txt" , "48656c6c6f" , "hex" ) ;
@@ -93,7 +93,7 @@ describe("VirtualFs Buffer and Encoding Support", () => {
9393 } ) ;
9494
9595 it ( "should read as hex" , async ( ) => {
96- const fs = new VirtualFs ( ) ;
96+ const fs = new InMemoryFs ( ) ;
9797
9898 await fs . writeFile ( "/test.txt" , "Hello" ) ;
9999 const result = await fs . readFile ( "/test.txt" , "hex" ) ;
@@ -102,7 +102,7 @@ describe("VirtualFs Buffer and Encoding Support", () => {
102102 } ) ;
103103
104104 it ( "should write with latin1 encoding" , async ( ) => {
105- const fs = new VirtualFs ( ) ;
105+ const fs = new InMemoryFs ( ) ;
106106
107107 // Latin1 character é is 0xe9
108108 await fs . writeFile ( "/test.txt" , "café" , "latin1" ) ;
@@ -112,7 +112,7 @@ describe("VirtualFs Buffer and Encoding Support", () => {
112112 } ) ;
113113
114114 it ( "should support encoding in options object" , async ( ) => {
115- const fs = new VirtualFs ( ) ;
115+ const fs = new InMemoryFs ( ) ;
116116
117117 await fs . writeFile ( "/test.txt" , "SGVsbG8=" , { encoding : "base64" } ) ;
118118 const result = await fs . readFile ( "/test.txt" , { encoding : "utf8" } ) ;
@@ -123,7 +123,7 @@ describe("VirtualFs Buffer and Encoding Support", () => {
123123
124124 describe ( "appendFile with Buffer" , ( ) => {
125125 it ( "should append Uint8Array to existing file" , async ( ) => {
126- const fs = new VirtualFs ( ) ;
126+ const fs = new InMemoryFs ( ) ;
127127
128128 await fs . writeFile ( "/test.txt" , "Hello" ) ;
129129 await fs . appendFile (
@@ -136,7 +136,7 @@ describe("VirtualFs Buffer and Encoding Support", () => {
136136 } ) ;
137137
138138 it ( "should append string to file with Buffer content" , async ( ) => {
139- const fs = new VirtualFs ( ) ;
139+ const fs = new InMemoryFs ( ) ;
140140 const initial = new Uint8Array ( [ 0x48 , 0x65 , 0x6c , 0x6c , 0x6f ] ) ; // "Hello"
141141
142142 await fs . writeFile ( "/test.txt" , initial ) ;
@@ -147,7 +147,7 @@ describe("VirtualFs Buffer and Encoding Support", () => {
147147 } ) ;
148148
149149 it ( "should append with encoding" , async ( ) => {
150- const fs = new VirtualFs ( ) ;
150+ const fs = new InMemoryFs ( ) ;
151151
152152 await fs . writeFile ( "/test.txt" , "Hello" ) ;
153153 // " World" in base64 is "IFdvcmxk"
@@ -160,7 +160,7 @@ describe("VirtualFs Buffer and Encoding Support", () => {
160160
161161 describe ( "constructor with Buffer content" , ( ) => {
162162 it ( "should initialize files with Uint8Array content" , async ( ) => {
163- const fs = new VirtualFs ( {
163+ const fs = new InMemoryFs ( {
164164 "/binary.bin" : new Uint8Array ( [ 0x00 , 0x01 , 0x02 ] ) ,
165165 "/text.txt" : "Hello" ,
166166 } ) ;
@@ -175,7 +175,7 @@ describe("VirtualFs Buffer and Encoding Support", () => {
175175
176176 describe ( "edge cases" , ( ) => {
177177 it ( "should handle empty Uint8Array" , async ( ) => {
178- const fs = new VirtualFs ( ) ;
178+ const fs = new InMemoryFs ( ) ;
179179
180180 await fs . writeFile ( "/empty.bin" , new Uint8Array ( 0 ) ) ;
181181 const result = await fs . readFileBuffer ( "/empty.bin" ) ;
@@ -185,7 +185,7 @@ describe("VirtualFs Buffer and Encoding Support", () => {
185185 } ) ;
186186
187187 it ( "should handle large binary files" , async ( ) => {
188- const fs = new VirtualFs ( ) ;
188+ const fs = new InMemoryFs ( ) ;
189189 const size = 1024 * 1024 ; // 1MB
190190 const data = new Uint8Array ( size ) ;
191191 for ( let i = 0 ; i < size ; i ++ ) {
@@ -202,7 +202,7 @@ describe("VirtualFs Buffer and Encoding Support", () => {
202202 } ) ;
203203
204204 it ( "should preserve binary content through copy" , async ( ) => {
205- const fs = new VirtualFs ( ) ;
205+ const fs = new InMemoryFs ( ) ;
206206 const data = new Uint8Array ( [ 0x00 , 0xff , 0x00 , 0xff ] ) ;
207207
208208 await fs . writeFile ( "/src.bin" , data ) ;
@@ -213,7 +213,7 @@ describe("VirtualFs Buffer and Encoding Support", () => {
213213 } ) ;
214214
215215 it ( "should follow symlinks for binary files" , async ( ) => {
216- const fs = new VirtualFs ( ) ;
216+ const fs = new InMemoryFs ( ) ;
217217 const data = new Uint8Array ( [ 0x48 , 0x69 ] ) ;
218218
219219 await fs . writeFile ( "/real.bin" , data ) ;
0 commit comments