getETA.test.js 458 B

123456789101112131415
  1. import { describe, expect, it } from 'vitest'
  2. import getETA from './getETA.ts'
  3. describe('getETA', () => {
  4. it('should get the ETA remaining based on a fileProgress object', () => {
  5. const dateNow = new Date()
  6. const date5SecondsAgo = new Date(dateNow.getTime() - 5 * 1000)
  7. const fileProgress = {
  8. bytesUploaded: 1024,
  9. bytesTotal: 3096,
  10. uploadStarted: date5SecondsAgo,
  11. }
  12. expect(getETA(fileProgress)).toEqual(10.1)
  13. })
  14. })