mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +00:00
d24514d67e
Three small tranches out of playerStore.ts: - src/utils/waveformParse.ts — waveformBlobLenOk + coerceWaveformBins (the parser that handles number[] / Uint8Array / ArrayLike payloads Rust serializes as). - src/utils/normalizationCompare.ts — normalizationAlmostEqual (tolerant null-aware dB comparison). - src/utils/seekErrors.ts — isRecoverableSeekError (retry classifier for the Rust seek pipeline). Each gets focused unit tests. All four were file-private, no external callers — pure code move. playerStore 3556 → 3516 LOC.
29 lines
1003 B
TypeScript
29 lines
1003 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { isRecoverableSeekError } from './seekErrors';
|
|
|
|
describe('isRecoverableSeekError', () => {
|
|
it.each([
|
|
'not seekable',
|
|
'audio sink not ready',
|
|
'audio seek busy',
|
|
'audio seek timeout',
|
|
])('classifies "%s" as recoverable', msg => {
|
|
expect(isRecoverableSeekError(msg)).toBe(true);
|
|
});
|
|
|
|
it('matches when the marker is embedded in a longer message', () => {
|
|
expect(isRecoverableSeekError('seek failed: audio sink not ready yet')).toBe(true);
|
|
expect(isRecoverableSeekError('error: audio seek timeout after 6000ms')).toBe(true);
|
|
});
|
|
|
|
it('returns false for unrelated errors', () => {
|
|
expect(isRecoverableSeekError('decoder failed')).toBe(false);
|
|
expect(isRecoverableSeekError('file not found')).toBe(false);
|
|
expect(isRecoverableSeekError('')).toBe(false);
|
|
});
|
|
|
|
it('is case-sensitive (Rust messages are stable)', () => {
|
|
expect(isRecoverableSeekError('Audio Sink Not Ready')).toBe(false);
|
|
});
|
|
});
|