mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-06 08:04:37 +00:00
feat(upload): simplify upload file list display and add live speed & ETA (#513)
* feat(upload): simplify upload file list display and add live speed and ETA * fix(upload): retain authoritative server search results and handle local failed upload state gracefully
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { formatRemainingTime, getTrashDaysLeft } from './time'
|
||||
import { formatRemainingTime, formatRemainingTimeSeconds, getTrashDaysLeft } from './time'
|
||||
|
||||
describe('formatRemainingTime', () => {
|
||||
const baseNow = new Date('2026-08-17T12:00:00Z')
|
||||
@@ -45,6 +45,33 @@ describe('formatRemainingTime', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('formatRemainingTimeSeconds', () => {
|
||||
it('formats hours and minutes', () => {
|
||||
expect(formatRemainingTimeSeconds(3 * 3600 + 18 * 60)).toBe('3h 18m')
|
||||
})
|
||||
|
||||
it('formats exact hours', () => {
|
||||
expect(formatRemainingTimeSeconds(3 * 3600)).toBe('3h')
|
||||
})
|
||||
|
||||
it('formats minutes', () => {
|
||||
expect(formatRemainingTimeSeconds(8 * 60)).toBe('8m')
|
||||
expect(formatRemainingTimeSeconds(45 * 60 + 20)).toBe('45m')
|
||||
})
|
||||
|
||||
it('formats seconds', () => {
|
||||
expect(formatRemainingTimeSeconds(45)).toBe('45s')
|
||||
expect(formatRemainingTimeSeconds(1)).toBe('1s')
|
||||
})
|
||||
|
||||
it('handles zero, negative, or invalid numbers', () => {
|
||||
expect(formatRemainingTimeSeconds(0)).toBe('< 1s')
|
||||
expect(formatRemainingTimeSeconds(-5)).toBe('< 1s')
|
||||
expect(formatRemainingTimeSeconds(NaN)).toBe('< 1s')
|
||||
expect(formatRemainingTimeSeconds(Infinity)).toBe('< 1s')
|
||||
})
|
||||
})
|
||||
|
||||
describe('getTrashDaysLeft', () => {
|
||||
const now = new Date('2026-08-17T12:00:00Z')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user