fix(files): filepicker circular dependency

This commit is contained in:
Karol Sójko
2022-08-04 17:32:49 +02:00
parent 696b82b9d3
commit 183f68c9c1
33 changed files with 64 additions and 64 deletions

View File

@@ -0,0 +1,23 @@
import { OrderedByteChunker } from './OrderedByteChunker'
const chunkOfSize = (size: number) => {
return new TextEncoder().encode('a'.repeat(size))
}
describe('ordered byte chunker', () => {
it('should callback multiple times if added bytes matches multiple chunk sizes', async () => {
const chunkSizes = [10, 10, 10]
let receivedBytes = new Uint8Array()
let numCallbacks = 0
const chunker = new OrderedByteChunker(chunkSizes, async (bytes) => {
numCallbacks++
receivedBytes = new Uint8Array([...receivedBytes, ...bytes])
})
await chunker.addBytes(chunkOfSize(30))
expect(numCallbacks).toEqual(3)
expect(receivedBytes.length).toEqual(30)
})
})