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.
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { normalizationAlmostEqual } from './normalizationCompare';
|
|
|
|
describe('normalizationAlmostEqual', () => {
|
|
it('returns true for two nulls', () => {
|
|
expect(normalizationAlmostEqual(null, null)).toBe(true);
|
|
});
|
|
|
|
it('returns false for mixed null / number', () => {
|
|
expect(normalizationAlmostEqual(null, 0)).toBe(false);
|
|
expect(normalizationAlmostEqual(0, null)).toBe(false);
|
|
});
|
|
|
|
it('returns true for values within the default epsilon (0.12)', () => {
|
|
expect(normalizationAlmostEqual(-14.0, -14.05)).toBe(true);
|
|
expect(normalizationAlmostEqual(-14.0, -14.12)).toBe(true);
|
|
});
|
|
|
|
it('returns false just past the default epsilon', () => {
|
|
expect(normalizationAlmostEqual(-14.0, -14.13)).toBe(false);
|
|
});
|
|
|
|
it('honours a custom epsilon', () => {
|
|
expect(normalizationAlmostEqual(-14.0, -14.5, 1.0)).toBe(true);
|
|
expect(normalizationAlmostEqual(-14.0, -14.5, 0.4)).toBe(false);
|
|
});
|
|
|
|
it('treats exact equality as equal', () => {
|
|
expect(normalizationAlmostEqual(-10, -10)).toBe(true);
|
|
expect(normalizationAlmostEqual(0, 0)).toBe(true);
|
|
});
|
|
});
|