From 392fcd82c34494957c815c9e4faeab9ec8d66da5 Mon Sep 17 00:00:00 2001 From: Timo Date: Fri, 23 May 2025 17:41:16 +0200 Subject: [PATCH] fix tests --- src/useAudioContext.test.tsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/useAudioContext.test.tsx b/src/useAudioContext.test.tsx index f2e2efdb..814df8e9 100644 --- a/src/useAudioContext.test.tsx +++ b/src/useAudioContext.test.tsx @@ -9,6 +9,7 @@ import { expect, vi, afterEach, beforeEach, test } from "vitest"; import { type FC } from "react"; import { render } from "@testing-library/react"; import userEvent, { type UserEvent } from "@testing-library/user-event"; +import { BrowserRouter } from "react-router-dom"; import { deviceStub, MediaDevicesContext } from "./livekit/MediaDevicesContext"; import { useAudioContext } from "./useAudioContext"; @@ -38,6 +39,13 @@ const TestComponent: FC = () => { ); }; +const TestComponentWrapper: FC = () => { + return ( + + + + ); +}; const gainNode = vi.mocked( { @@ -94,13 +102,13 @@ afterEach(() => { }); test("can play a single sound", async () => { - const { findByText } = render(); + const { findByText } = render(); await user.click(await findByText("Valid sound")); expect(testAudioContext.createBufferSource).toHaveBeenCalledOnce(); }); test("will ignore sounds that are not registered", async () => { - const { findByText } = render(); + const { findByText } = render(); await user.click(await findByText("Invalid sound")); expect(testAudioContext.createBufferSource).not.toHaveBeenCalled(); }); @@ -122,7 +130,7 @@ test("will use the correct device", () => { stopUsingDeviceNames: () => {}, }} > - + , ); expect(testAudioContext.createBufferSource).not.toHaveBeenCalled(); @@ -131,7 +139,7 @@ test("will use the correct device", () => { test("will use the correct volume level", async () => { soundEffectVolumeSetting.setValue(0.33); - const { findByText } = render(); + const { findByText } = render(); await user.click(await findByText("Valid sound")); expect(testAudioContext.gain.gain.setValueAtTime).toHaveBeenCalledWith( 0.33, @@ -157,7 +165,7 @@ test("will use the pan if earpiece is selected", async () => { stopUsingDeviceNames: () => {}, }} > - + , ); await user.click(await findByText("Valid sound"));