mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-30 13:30:31 +00:00
Co-authored-by: Mikael Finstad <finstaden@gmail.com> Co-authored-by: Nick Rutten <2504906+nickrttn@users.noreply.github.com> Co-authored-by: Murderlon <merlijn@soverin.net> Co-authored-by: Artur Paikin <artur@arturpaikin.com>
18 lines
560 B
TypeScript
18 lines
560 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import getSpeed from './getSpeed.ts'
|
|
|
|
describe('getSpeed', () => {
|
|
it('should calculate the speed given a fileProgress object', () => {
|
|
const dateNow = new Date()
|
|
const date5SecondsAgo = new Date(dateNow.getTime() - 5 * 1000)
|
|
const fileProgress = {
|
|
bytesUploaded: 1024,
|
|
uploadStarted: date5SecondsAgo.getTime(),
|
|
progress: 0,
|
|
uploadComplete: false,
|
|
percentage: 0,
|
|
bytesTotal: 0,
|
|
}
|
|
expect(Math.round(getSpeed(fileProgress))).toEqual(Math.round(205))
|
|
})
|
|
})
|