veza/apps/web/src/features/player/hooks/useCastSupport.test.ts
senke 32cacdcf09 feat(v0.13.4): polish audio & player — PiP canvas, visualizer, Cast/AirPlay stubs
TASK-APLSH-001: Enhanced PiP with canvas-based display showing cover art + track info
TASK-APLSH-002: Chromecast detection hook (useCastSupport) — full casting deferred
TASK-APLSH-003: AirPlay detection hook (useAirPlaySupport) — Safari target picker
TASK-APLSH-004: AudioVisualizer component with 3 modes (bars/wave/spectrogram)
  - useSpectrumAnalyser hook (64 bands, high-res FFT)
  - Canvas-based rendering with SUMI color palette
  - Integrated into PlayerExpanded with toggle button

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 13:59:30 +01:00

32 lines
1.1 KiB
TypeScript

import { describe, it, expect, vi, beforeEach } from 'vitest';
import { renderHook } from '@testing-library/react';
import { useCastSupport } from './useCastSupport';
describe('useCastSupport', () => {
beforeEach(() => {
vi.clearAllMocks();
});
it('should report cast as unavailable by default', () => {
const { result } = renderHook(() => useCastSupport());
expect(result.current.isAvailable).toBe(false);
expect(result.current.isConnected).toBe(false);
});
it('should provide requestSession callback', () => {
const { result } = renderHook(() => useCastSupport());
expect(typeof result.current.requestSession).toBe('function');
// Should not throw
result.current.requestSession();
});
it('should detect Chrome Cast when available', () => {
(window as Window & { chrome?: { cast?: { isAvailable?: boolean } } }).chrome = {
cast: { isAvailable: true },
};
const { result } = renderHook(() => useCastSupport());
expect(result.current.isAvailable).toBe(true);
// Cleanup
delete (window as Window & { chrome?: unknown }).chrome;
});
});