Files
psysonic/src/store/infiniteQueueState.test.ts
T
Frank Stellmacher 14bdcde33f refactor(player): E.24 — extract radio session + infinite-queue guards (#588)
Cluster of four small mutables in two modules:

  - `src/store/radioSessionState.ts` — `radioFetching` (concurrent
    fetch guard) + `currentRadioArtistId` (seed artist that survives
    track advances) + `radioSessionSeenIds` (dedupe set including
    HISTORY_KEEP-evicted entries, fixes issue #500).
  - `src/store/infiniteQueueState.ts` — `infiniteQueueFetching`
    concurrent fetch guard.

Sed-driven bulk rewrite for the >35 direct-access sites. The four
`= new Set()` resets become `clearRadioSessionSeenIds()` calls and
the `setRadioArtistId` / `enqueueRadio` actions read through
`getCurrentRadioArtistId()` instead of touching the mutable directly.

15 focused tests across the two modules.

playerStore 2867 → 2865 LOC.
2026-05-12 17:26:15 +02:00

30 lines
803 B
TypeScript

import { afterEach, describe, expect, it } from 'vitest';
import {
_resetInfiniteQueueStateForTest,
isInfiniteQueueFetching,
setInfiniteQueueFetching,
} from './infiniteQueueState';
afterEach(() => {
_resetInfiniteQueueStateForTest();
});
describe('infiniteQueueFetching', () => {
it('starts false', () => {
expect(isInfiniteQueueFetching()).toBe(false);
});
it('round-trips through set/get', () => {
setInfiniteQueueFetching(true);
expect(isInfiniteQueueFetching()).toBe(true);
setInfiniteQueueFetching(false);
expect(isInfiniteQueueFetching()).toBe(false);
});
it('_resetInfiniteQueueStateForTest resets to false', () => {
setInfiniteQueueFetching(true);
_resetInfiniteQueueStateForTest();
expect(isInfiniteQueueFetching()).toBe(false);
});
});