add missing mocking

This commit is contained in:
Valere
2026-02-26 17:02:43 +01:00
parent 15aa67ebb9
commit ae8b1f840f
2 changed files with 34 additions and 2 deletions

View File

@@ -6,7 +6,7 @@ Please see LICENSE in the repository root for full details.
*/
import { type RemoteTrackPublication } from "livekit-client";
import { test, expect } from "vitest";
import { test, expect, beforeAll } from "vitest";
import { render, screen } from "@testing-library/react";
import { axe } from "vitest-axe";
import { type MatrixRTCSession } from "matrix-js-sdk/lib/matrixrtc";
@@ -28,6 +28,22 @@ global.IntersectionObserver = class MockIntersectionObserver {
public disconnect(): void {}
} as unknown as typeof IntersectionObserver;
// Mock ResizeObserver as it is needed by the useMeasure hook used in the GridTile, but is not implemented in JSDOM.
// We just need to mock it with empty methods as we don't need to test its functionality here.
beforeAll(() => {
window.ResizeObserver = class ResizeObserver {
public observe(): void {
// do nothing
}
public unobserve(): void {
// do nothing
}
public disconnect(): void {
// do nothing
}
};
});
test("GridTile is accessible", async () => {
const vm = createRemoteMedia(
mockRtcMembership("@alice:example.org", "AAAA"),

View File

@@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
import { test, expect, vi } from "vitest";
import { test, expect, vi, beforeAll } from "vitest";
import { isInaccessible, render, screen } from "@testing-library/react";
import { axe } from "vitest-axe";
import userEvent from "@testing-library/user-event";
@@ -27,6 +27,22 @@ global.IntersectionObserver = class MockIntersectionObserver {
public unobserve(): void {}
} as unknown as typeof IntersectionObserver;
// Mock ResizeObserver as it is needed by the useMeasure hook used in the SpotlightTile, but is not implemented in JSDOM.
// We just need to mock it with empty methods as we don't need to test its functionality here.
beforeAll(() => {
window.ResizeObserver = class ResizeObserver {
public observe(): void {
// do nothing
}
public unobserve(): void {
// do nothing
}
public disconnect(): void {
// do nothing
}
};
});
test("SpotlightTile is accessible", async () => {
const vm1 = createRemoteMedia(
mockRtcMembership("@alice:example.org", "AAAA"),