From 9a5afb11f6438f94b4f20a6db015a40220f9ff56 Mon Sep 17 00:00:00 2001 From: Angel Mendez Cano Date: Fri, 2 Feb 2024 19:00:38 -0600 Subject: [PATCH] feat: update tests using vitest - replace jest references with vitest --- test/Toast-test.tsx | 7 ++++--- test/UrlParams-test.ts | 6 +++--- test/__snapshots__/Toast-test.tsx.snap | 2 +- test/environment.ts | 18 ------------------ test/mocks/olmMock.ts | 4 +++- test/mocks/workerMock.ts | 4 +++- test/room/checkForParallelCalls-test.ts | 8 ++++---- test/utils.ts | 5 +++-- 8 files changed, 21 insertions(+), 33 deletions(-) delete mode 100644 test/environment.ts diff --git a/test/Toast-test.tsx b/test/Toast-test.tsx index 88cfbf4b..6b573523 100644 --- a/test/Toast-test.tsx +++ b/test/Toast-test.tsx @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +import { vi } from "vitest"; import { screen, render } from "@testing-library/react"; import { Toast } from "../src/Toast"; import userEvent from "@testing-library/user-event"; @@ -35,7 +36,7 @@ test("Toast renders", () => { }); test("Toast dismisses when clicked", async () => { - const onDismiss = jest.fn(); + const onDismiss = vi.fn(); render( Hello world! @@ -47,13 +48,13 @@ test("Toast dismisses when clicked", async () => { test("Toast dismisses itself after the specified timeout", async () => { withFakeTimers(() => { - const onDismiss = jest.fn(); + const onDismiss = vi.fn(); render( Hello world! , ); - jest.advanceTimersByTime(2000); + vi.advanceTimersByTime(2000); expect(onDismiss).toHaveBeenCalled(); }); }); diff --git a/test/UrlParams-test.ts b/test/UrlParams-test.ts index e0eb7c29..eb03d976 100644 --- a/test/UrlParams-test.ts +++ b/test/UrlParams-test.ts @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { mocked } from "jest-mock"; +import { vi } from "vitest"; import { getRoomIdentifierFromUrl } from "../src/UrlParams"; import { Config } from "../src/config/Config"; @@ -24,11 +24,11 @@ const ROOM_ID = "!d45f138fsd"; const ORIGIN = "https://call.element.io"; const HOMESERVER = "call.ems.host"; -jest.mock("../src/config/Config"); +vi.mock("../src/config/Config"); describe("UrlParams", () => { beforeAll(() => { - mocked(Config.defaultServerName).mockReturnValue("call.ems.host"); + vi.mocked(Config.defaultServerName).mockReturnValue("call.ems.host"); }); describe("handles URL with /room/", () => { diff --git a/test/__snapshots__/Toast-test.tsx.snap b/test/__snapshots__/Toast-test.tsx.snap index 64822136..7edfdcf7 100644 --- a/test/__snapshots__/Toast-test.tsx.snap +++ b/test/__snapshots__/Toast-test.tsx.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`Toast renders 1`] = `