feat(uploads): show batch format counts and quality ranges
This commit is contained in:
1 parent
e78cab6ce6
commit
1e3a149aef
7 files changed
+63
-1
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import { expect, it } from 'vitest';
|
||||
import { batchSummary } from './batchSummary';
|
||||
|
||||
it('counts formats and combines measured quality ranges without repeating equal values', () => {
|
||||
const summary = batchSummary([
|
||||
{ format: 'FLAC', original_name: 'one.flac', bitrate: 778000, sample_rate: 44100, bit_depth: 16 },
|
||||
{ format: 'flac', original_name: 'two.flac', bitrate: 924000, sample_rate: 44100, bit_depth: 16 },
|
||||
{ format: null, original_name: 'three.mp3', bitrate: 320000, sample_rate: 48000, bit_depth: null },
|
||||
]);
|
||||
expect(summary.formats).toEqual([['FLAC', 2], ['MP3', 1]]);
|
||||
expect(summary.quality).toBe('320–924 kbps · 44.1–48 kHz · 16 bit');
|
||||
});
|
||||
|
||||
it('ignores missing and invalid measurements and retains fractional sample rates', () => {
|
||||
expect(batchSummary([
|
||||
{ format: null, original_name: 'unknown', bitrate: 0, sample_rate: null, bit_depth: null },
|
||||
{ format: 'WAV', original_name: 'one.wav', bitrate: null, sample_rate: 11025, bit_depth: 24 },
|
||||
{ format: 'wav', original_name: 'two.wav', bitrate: NaN, sample_rate: 96000, bit_depth: 32 },
|
||||
])).toEqual({ formats: [['WAV', 2], ['', 1]], quality: '11.025–96 kHz · 24–32 bit' });
|
||||
expect(batchSummary([]).quality).toBe('');
|
||||
});
|
||||
Reference in new issue
Block a user