From 78e25d4fd318c3e7b8b08de50d23c100abf49b72 Mon Sep 17 00:00:00 2001 From: Estelle Comment Date: Tue, 10 Oct 2023 13:35:54 +0200 Subject: [PATCH] Move tchap unit-tests into single folder, and run jest on that folder only --- jest.config.ts | 2 +- .../components/views/dialogs/TchapCreateRoomDialog-test.tsx | 6 +++--- .../views/settings/TchapJoinRuleSettings-test.tsx | 4 ++-- test/unit-tests/{ => tchap}/lib/createTchapRoom-test.ts | 4 ++-- test/unit-tests/{ => tchap}/util/TchapRoomUtils-test.ts | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) rename test/unit-tests/{ => tchap}/components/views/dialogs/TchapCreateRoomDialog-test.tsx (98%) rename test/unit-tests/{ => tchap}/components/views/settings/TchapJoinRuleSettings-test.tsx (96%) rename test/unit-tests/{ => tchap}/lib/createTchapRoom-test.ts (96%) rename test/unit-tests/{ => tchap}/util/TchapRoomUtils-test.ts (82%) diff --git a/jest.config.ts b/jest.config.ts index ec886829cc..043802b8db 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -35,7 +35,7 @@ const config: Config = { testEnvironmentOptions: { url: "http://localhost/", }, - testMatch: ["/test/unit-tests/**/*-test.[tj]s?(x)"], + testMatch: ["/test/unit-tests/tchap/**/*-test.[tj]s?(x)"], // :TCHAP: only tchap tests setupFiles: ["jest-canvas-mock"], setupFilesAfterEnv: ["/test/setupTests.ts", "/node_modules/matrix-react-sdk/test/setupTests.ts"], moduleNameMapper: { diff --git a/test/unit-tests/components/views/dialogs/TchapCreateRoomDialog-test.tsx b/test/unit-tests/tchap/components/views/dialogs/TchapCreateRoomDialog-test.tsx similarity index 98% rename from test/unit-tests/components/views/dialogs/TchapCreateRoomDialog-test.tsx rename to test/unit-tests/tchap/components/views/dialogs/TchapCreateRoomDialog-test.tsx index 363087dc29..a502763e39 100644 --- a/test/unit-tests/components/views/dialogs/TchapCreateRoomDialog-test.tsx +++ b/test/unit-tests/tchap/components/views/dialogs/TchapCreateRoomDialog-test.tsx @@ -6,9 +6,9 @@ import { act } from "react-dom/test-utils"; import { MatrixClientPeg } from "matrix-react-sdk/src/MatrixClientPeg"; import { EventEmitter } from "events"; -import { TchapRoomType } from "../../../../../src/tchap/@types/tchap"; -import TchapUtils from "../../../../../src/tchap/util/TchapUtils"; -import TchapCreateRoomDialog from "../../../../../src/tchap/components/views/dialogs/TchapCreateRoomDialog"; +import { TchapRoomType } from "../../../../../../src/tchap/@types/tchap"; +import TchapUtils from "../../../../../../src/tchap/util/TchapUtils"; +import TchapCreateRoomDialog from "../../../../../../src/tchap/components/views/dialogs/TchapCreateRoomDialog"; //mocking module with jest.mock should be done outside the test. Before any import of the mocked module. //I could not make a mock of TchapCreateRoomDialog, the real implementation was taken each time. Then I used jest spyOn diff --git a/test/unit-tests/components/views/settings/TchapJoinRuleSettings-test.tsx b/test/unit-tests/tchap/components/views/settings/TchapJoinRuleSettings-test.tsx similarity index 96% rename from test/unit-tests/components/views/settings/TchapJoinRuleSettings-test.tsx rename to test/unit-tests/tchap/components/views/settings/TchapJoinRuleSettings-test.tsx index f53acce9ab..1f5338606a 100644 --- a/test/unit-tests/components/views/settings/TchapJoinRuleSettings-test.tsx +++ b/test/unit-tests/tchap/components/views/settings/TchapJoinRuleSettings-test.tsx @@ -9,8 +9,8 @@ import { } from "matrix-react-sdk/test/test-utils/test-utils"; import { JoinRule, MatrixClient, Room } from "matrix-js-sdk/src/matrix"; -import TchapJoinRuleSettings from "../../../../../src/tchap/components/views/settings/TchapJoinRuleSettings"; -import { TchapRoomAccessRule, TchapRoomAccessRulesEventId } from "../../../../../src/tchap/@types/tchap"; +import TchapJoinRuleSettings from "../../../../../../src/tchap/components/views/settings/TchapJoinRuleSettings"; +import { TchapRoomAccessRule, TchapRoomAccessRulesEventId } from "../../../../../../src/tchap/@types/tchap"; function mkStubRoomWithInviteRule(roomId: string, name: string, client: MatrixClient, joinRule: JoinRule): Room { const stubRoom: Room = mkStubRoom(roomId, name, client); diff --git a/test/unit-tests/lib/createTchapRoom-test.ts b/test/unit-tests/tchap/lib/createTchapRoom-test.ts similarity index 96% rename from test/unit-tests/lib/createTchapRoom-test.ts rename to test/unit-tests/tchap/lib/createTchapRoom-test.ts index 3a7b736e24..d492398d5e 100644 --- a/test/unit-tests/lib/createTchapRoom-test.ts +++ b/test/unit-tests/tchap/lib/createTchapRoom-test.ts @@ -1,5 +1,5 @@ -import { TchapRoomType } from "../../../src/tchap/@types/tchap"; -import TchapCreateRoom from "../../../src/tchap/lib/createTchapRoom"; +import { TchapRoomType } from "../../../../src/tchap/@types/tchap"; +import TchapCreateRoom from "../../../../src/tchap/lib/createTchapRoom"; // todo(estellecomment) : these tests are redundant with TchapCreateRoomDialog-test. Either remove them or modify TchapCreateRoomDialog // to not edit state directly. diff --git a/test/unit-tests/util/TchapRoomUtils-test.ts b/test/unit-tests/tchap/util/TchapRoomUtils-test.ts similarity index 82% rename from test/unit-tests/util/TchapRoomUtils-test.ts rename to test/unit-tests/tchap/util/TchapRoomUtils-test.ts index 3747d11760..04253019df 100644 --- a/test/unit-tests/util/TchapRoomUtils-test.ts +++ b/test/unit-tests/tchap/util/TchapRoomUtils-test.ts @@ -1,5 +1,5 @@ -import { TchapRoomAccessRule, TchapRoomType } from "../../../src/tchap/@types/tchap"; -import TchapRoomUtils from "../../../src/tchap/util/TchapRoomUtils"; +import { TchapRoomAccessRule, TchapRoomType } from "../../../../src/tchap/@types/tchap"; +import TchapRoomUtils from "../../../../src/tchap/util/TchapRoomUtils"; describe("Provides utils method to get room type and state", () => { beforeEach(() => {});