Skip to content

Commit

Permalink
test virtual io
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinidadec committed Nov 15, 2023
1 parent 77ce277 commit cb0d82f
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -209,23 +209,22 @@ const virtualFsTest = async () => {
/** @type {FileSystem} */
const fs = {}
const io = virtual(fs)
io.write('test', new Uint8Array([0, 1, 2]))
let buffer = io.read('test')
console.log(buffer)
console.log(fs)

io.write('test', new Uint8Array([3, 4, 5]))
buffer = io.read('test')
console.log(buffer)
console.log(fs)

io.append('test', new Uint8Array([6, 7, 8]))
buffer = io.read('test')
console.log(buffer)
console.log(fs)

io.rename('test', 'test-new')
console.log(fs)
await io.write('test', new Uint8Array([0, 1, 2]))
let buffer = await io.read('test')
if (buffer.toString() !== '0,1,2') { throw buffer }

await io.write('test', new Uint8Array([3, 4, 5]))
buffer = await io.read('test')
if (buffer.toString() !== '3,4,5') { throw buffer }

await io.append('test', new Uint8Array([6, 7, 8]))
buffer = await io.read('test')
if (buffer.toString() !== '3,4,5,6,7,8') { throw buffer }

await io.rename('test', 'test-new')
//buffer = await io.read('test') //catch error
buffer = await io.read('test-new')
if (buffer.toString() !== '3,4,5,6,7,8') { throw buffer }
}

virtualFsTest()
Expand Down

0 comments on commit cb0d82f

Please sign in to comment.