test: use setSystemTime for better test stability

This commit is contained in:
Valere
2025-11-26 15:31:47 +01:00
parent 3491a68362
commit acd5dde6d8
2 changed files with 11 additions and 4 deletions

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. Please see LICENSE in the repository root for full details.
*/ */
import { describe, expect, test } from "vitest"; import { beforeEach, describe, expect, test, vi } from "vitest";
import { render, configure } from "@testing-library/react"; import { render, configure } from "@testing-library/react";
import { RaisedHandIndicator } from "./RaisedHandIndicator"; import { RaisedHandIndicator } from "./RaisedHandIndicator";
@@ -15,6 +15,13 @@ configure({
}); });
describe("RaisedHandIndicator", () => { describe("RaisedHandIndicator", () => {
const fixedTime = new Date("2025-01-01T12:00:00.000Z");
beforeEach(() => {
vi.useFakeTimers();
vi.setSystemTime(fixedTime);
});
test("renders nothing when no hand has been raised", () => { test("renders nothing when no hand has been raised", () => {
const { container } = render(<RaisedHandIndicator />); const { container } = render(<RaisedHandIndicator />);
expect(container.firstChild).toBeNull(); expect(container.firstChild).toBeNull();

View File

@@ -15,7 +15,7 @@ exports[`RaisedHandIndicator > renders a smaller indicator when miniature is spe
</span> </span>
</div> </div>
<p> <p>
00:01 00:00
</p> </p>
</div> </div>
`; `;
@@ -35,7 +35,7 @@ exports[`RaisedHandIndicator > renders an indicator when a hand has been raised
</span> </span>
</div> </div>
<p> <p>
00:01 00:00
</p> </p>
</div> </div>
`; `;
@@ -55,7 +55,7 @@ exports[`RaisedHandIndicator > renders an indicator when a hand has been raised
</span> </span>
</div> </div>
<p> <p>
01:01 01:00
</p> </p>
</div> </div>
`; `;