mirror of
https://github.com/vector-im/element-call.git
synced 2026-09-25 22:35:49 +00:00
- The suggestion renamed the field in the type only. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
/*
|
|
Copyright 2026 Element Creations Ltd.
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
Please see LICENSE in the repository root for full details.
|
|
*/
|
|
|
|
import { afterEach, describe, expect, test } from "vitest";
|
|
import { renderHook } from "@testing-library/react";
|
|
|
|
import { useMicrophoneLevel } from "./useMicrophoneLevel";
|
|
import { restoreAudioCapture, stubAudioCapture } from "../utils/test";
|
|
|
|
// Capture and release are covered in MicrophoneLevel.test.ts; this covers the bridge.
|
|
describe("useMicrophoneLevel", () => {
|
|
afterEach(restoreAudioCapture);
|
|
|
|
test("holds no capture while the meter is not shown", () => {
|
|
const capture = stubAudioCapture();
|
|
|
|
renderHook(() => useMicrophoneLevel("mic1", false));
|
|
|
|
expect(capture.getUserMedia).not.toHaveBeenCalled();
|
|
});
|
|
|
|
test("starts from nothing rather than the previous device's level", () => {
|
|
const capture = stubAudioCapture();
|
|
|
|
const { result, rerender } = renderHook(
|
|
({ id }: { id: string }) => useMicrophoneLevel(id, true),
|
|
{ initialProps: { id: "mic1" } },
|
|
);
|
|
capture.grant();
|
|
|
|
rerender({ id: "mic2" });
|
|
|
|
// No level carried over from the previous device.
|
|
const state = result.current;
|
|
expect(state.type === "level" ? state.level$.value : state.type).toBe(0);
|
|
});
|
|
});
|