mirror of https://github.com/kern/filepizza
fix chunk final detection and add test (#287)
parent
4db3b94b68
commit
ec70693b54
@ -0,0 +1,15 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { isFinalChunk, MAX_CHUNK_SIZE } from '../../src/hooks/useUploaderConnections'
|
||||
|
||||
describe('isFinalChunk', () => {
|
||||
it('marks last chunk when file size is exact multiple of chunk size', () => {
|
||||
const fileSize = MAX_CHUNK_SIZE * 2
|
||||
// when offset points to start of last chunk
|
||||
expect(isFinalChunk(MAX_CHUNK_SIZE, fileSize)).toBe(true)
|
||||
})
|
||||
|
||||
it('returns false for middle chunks', () => {
|
||||
const fileSize = MAX_CHUNK_SIZE * 3 + 123
|
||||
expect(isFinalChunk(MAX_CHUNK_SIZE, fileSize)).toBe(false)
|
||||
})
|
||||
})
|
||||
Loading…
Reference in New Issue