All files / blacktrigram/test test-utils.tsx

0% Statements 0/55
100% Branches 1/1
100% Functions 1/1
0% Lines 0/55

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74                                                                                                                                                   
import React from "react";
import { render, RenderOptions } from "@testing-library/react";
import { Application } from "@pixi/react";
import { AudioProvider } from "../src/audio/AudioProvider";
import type { IAudioManager } from "../src/types/audio";
 
// Mock audio manager for testing
class MockAudioManager implements IAudioManager {
  isInitialized = true;
 
  async init() {}
  playSFX() {
    return null;
  }
  playMusic() {
    return null;
  }
  stopMusic() {}
  setMasterVolume() {}
  setSFXVolume() {}
  setMusicVolume() {}
  setMuted() {}
  getState() {
    return {
      masterVolume: 0.7,
      sfxVolume: 0.8,
      musicVolume: 0.5,
      muted: false,
      currentMusicTrack: null,
      isInitialized: true,
      fallbackMode: false,
    };
  }
  playAttackSound() {}
  playHitSound() {}
  playTechniqueSound() {}
  playStanceChangeSound() {}
  playBlockSound() {}
  stopAllSounds() {}
  async loadAudioAsset() {}
  isMusicPlaying() {
    return false;
  }
}
 
// Test wrapper with providers
interface TestWrapperProps {
  children: React.ReactNode;
}
 
function TestWrapper({ children }: TestWrapperProps) {
  const mockAudioManager = new MockAudioManager();
 
  return (
    <AudioProvider manager={mockAudioManager}>
      <Application width={800} height={600}>
        {children}
      </Application>
    </AudioProvider>
  );
}
 
// Custom render function
function customRender(
  ui: React.ReactElement,
  options?: Omit<RenderOptions, "wrapper">
) {
  return render(ui, { wrapper: TestWrapper, ...options });
}
 
// Re-export everything
export * from "@testing-library/react";
export { customRender as render };