-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathuseSoundPlayer.test.ts
More file actions
27 lines (23 loc) · 940 Bytes
/
useSoundPlayer.test.ts
File metadata and controls
27 lines (23 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { renderHook } from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest';
import { generateEmptyFft } from './generateEmptyFft';
import { useSoundPlayer } from './useSoundPlayer';
describe('useSoundPlayer', () => {
it('should initialize with correct default state', () => {
const mockOnError = vi.fn();
const mockOnPlayAudio = vi.fn();
const mockOnStopAudio = vi.fn();
const { result } = renderHook(() =>
useSoundPlayer({
onError: mockOnError,
onPlayAudio: mockOnPlayAudio,
onStopAudio: mockOnStopAudio,
}),
);
expect(result.current.volume).toBe(1.0); // full volume
expect(result.current.isAudioMuted).toBe(false); // not muted
expect(result.current.isPlaying).toBe(false); // not playing
expect(result.current.queueLength).toBe(0); // empty queue
expect(result.current.fft).toEqual(generateEmptyFft()); // empty fft
});
});