diff --git a/.eslintrc.js b/.eslintrc.js index 7c2ebb96df..d133a3c005 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -165,10 +165,31 @@ module.exports = { }, { files: ["test/**/*.{ts,tsx}", "cypress/**/*.ts"], + extends: ["plugin:matrix-org/jest"], rules: { // We don't need super strict typing in test utilities "@typescript-eslint/explicit-function-return-type": "off", "@typescript-eslint/explicit-member-accessibility": "off", + + // Jest/Cypress specific + + // Disabled tests are a reality for now but as soon as all of the xits are + // eliminated, we should enforce this. + "jest/no-disabled-tests": "off", + // TODO: There are many tests with invalid expects that should be fixed, + // https://github.com/vector-im/element-web/issues/24709 + "jest/valid-expect": "off", + // TODO: There are many cases to refactor away, + // https://github.com/vector-im/element-web/issues/24710 + "jest/no-conditional-expect": "off", + // Also treat "oldBackendOnly" as a test function. + // Used in some crypto tests. + "jest/no-standalone-expect": [ + "error", + { + additionalTestBlockFunctions: ["beforeAll", "beforeEach", "oldBackendOnly"], + }, + ], }, }, { @@ -176,6 +197,11 @@ module.exports = { parserOptions: { project: ["./cypress/tsconfig.json"], }, + rules: { + // Cypress "promises" work differently - disable some related rules + "jest/valid-expect-in-promise": "off", + "jest/no-done-callback": "off", + }, }, ], settings: { diff --git a/cypress/e2e/sliding-sync/sliding-sync.ts b/cypress/e2e/sliding-sync/sliding-sync.ts index c6d2c298fe..2cae1a1218 100644 --- a/cypress/e2e/sliding-sync/sliding-sync.ts +++ b/cypress/e2e/sliding-sync/sliding-sync.ts @@ -356,7 +356,7 @@ describe("Sliding Sync", () => { }); // Regression test for https://github.com/vector-im/element-web/issues/21462 - it("should not cancel replies when permalinks are clicked ", () => { + it("should not cancel replies when permalinks are clicked", () => { cy.get("@roomId").then((roomId) => { // we require a first message as you cannot click the permalink text with the avatar in the way return cy diff --git a/cypress/e2e/spotlight/spotlight.spec.ts b/cypress/e2e/spotlight/spotlight.spec.ts index d9ead17bb3..d8453b9d99 100644 --- a/cypress/e2e/spotlight/spotlight.spec.ts +++ b/cypress/e2e/spotlight/spotlight.spec.ts @@ -24,7 +24,7 @@ import Timeoutable = Cypress.Timeoutable; import Withinable = Cypress.Withinable; import Shadow = Cypress.Shadow; -export enum Filter { +enum Filter { People = "people", PublicRooms = "public_rooms", } @@ -297,27 +297,28 @@ describe("Spotlight", () => { // TODO: We currently can’t test finding rooms on other homeservers/other protocols // We obviously don’t have federation or bridges in cypress tests - /* - const room3Name = "Matrix HQ"; - const room3Id = "#matrix:matrix.org"; - - it("should find unknown public rooms on other homeservers", () => { - cy.openSpotlightDialog().within(() => { - cy.spotlightFilter(Filter.PublicRooms); - cy.spotlightSearch().clear().type(room3Name); - cy.get("[aria-haspopup=true][role=button]").click(); - }).then(() => { - cy.contains(".mx_GenericDropdownMenu_Option--header", "matrix.org") - .next("[role=menuitemradio]") - .click(); - cy.wait(3_600_000); - }).then(() => cy.spotlightDialog().within(() => { - cy.spotlightResults().should("have.length", 1); - cy.spotlightResults().eq(0).should("contain", room3Name); - cy.spotlightResults().eq(0).should("contain", room3Id); - })); + it.skip("should find unknown public rooms on other homeservers", () => { + cy.openSpotlightDialog() + .within(() => { + cy.spotlightFilter(Filter.PublicRooms); + cy.spotlightSearch().clear().type(room3Name); + cy.get("[aria-haspopup=true][role=button]").click(); + }) + .then(() => { + cy.contains(".mx_GenericDropdownMenu_Option--header", "matrix.org") + .next("[role=menuitemradio]") + .click(); + cy.wait(3_600_000); + }) + .then(() => + cy.spotlightDialog().within(() => { + cy.spotlightResults().should("have.length", 1); + cy.spotlightResults().eq(0).should("contain", room3Name); + cy.spotlightResults().eq(0).should("contain", room3Id); + }), + ); }); - */ + it("should find known people", () => { cy.openSpotlightDialog() .within(() => { diff --git a/package.json b/package.json index fb4cd87dc4..f9923fe6e2 100644 --- a/package.json +++ b/package.json @@ -194,6 +194,7 @@ "eslint-config-prettier": "^8.5.0", "eslint-plugin-deprecate": "^0.7.0", "eslint-plugin-import": "^2.25.4", + "eslint-plugin-jest": "^27.2.1", "eslint-plugin-jsx-a11y": "^6.5.1", "eslint-plugin-matrix-org": "1.0.0", "eslint-plugin-react": "^7.28.0", diff --git a/test/ContentMessages-test.ts b/test/ContentMessages-test.ts index 323cb1834b..b24feca1da 100644 --- a/test/ContentMessages-test.ts +++ b/test/ContentMessages-test.ts @@ -327,6 +327,6 @@ describe("uploadFile", () => { const prom = uploadFile(client, "!roomId:server", file); mocked(client.uploadContent).mock.calls[0][1]!.abortController!.abort(); deferred.resolve({ content_uri: "mxc://foo/bar" }); - await expect(prom).rejects.toThrowError(UploadCanceledError); + await expect(prom).rejects.toThrow(UploadCanceledError); }); }); diff --git a/test/DecryptionFailureTracker-test.js b/test/DecryptionFailureTracker-test.js index 14f3a67b61..63b0489ee4 100644 --- a/test/DecryptionFailureTracker-test.js +++ b/test/DecryptionFailureTracker-test.js @@ -38,7 +38,7 @@ function createFailedDecryptionEvent() { } describe("DecryptionFailureTracker", function () { - it("tracks a failed decryption for a visible event", function (done) { + it("tracks a failed decryption for a visible event", function () { const failedDecryptionEvent = createFailedDecryptionEvent(); let count = 0; @@ -59,11 +59,9 @@ describe("DecryptionFailureTracker", function () { tracker.trackFailures(); expect(count).not.toBe(0, "should track a failure for an event that failed decryption"); - - done(); }); - it("tracks a failed decryption with expected raw error for a visible event", function (done) { + it("tracks a failed decryption with expected raw error for a visible event", function () { const failedDecryptionEvent = createFailedDecryptionEvent(); let count = 0; @@ -89,11 +87,9 @@ describe("DecryptionFailureTracker", function () { expect(count).not.toBe(0, "should track a failure for an event that failed decryption"); expect(reportedRawCode).toBe("INBOUND_SESSION_MISMATCH_ROOM_ID", "Should add the rawCode to the event context"); - - done(); }); - it("tracks a failed decryption for an event that becomes visible later", function (done) { + it("tracks a failed decryption for an event that becomes visible later", function () { const failedDecryptionEvent = createFailedDecryptionEvent(); let count = 0; @@ -114,11 +110,9 @@ describe("DecryptionFailureTracker", function () { tracker.trackFailures(); expect(count).not.toBe(0, "should track a failure for an event that failed decryption"); - - done(); }); - it("does not track a failed decryption for an event that never becomes visible", function (done) { + it("does not track a failed decryption for an event that never becomes visible", function () { const failedDecryptionEvent = createFailedDecryptionEvent(); let count = 0; @@ -137,11 +131,9 @@ describe("DecryptionFailureTracker", function () { tracker.trackFailures(); expect(count).toBe(0, "should not track a failure for an event that never became visible"); - - done(); }); - it("does not track a failed decryption where the event is subsequently successfully decrypted", (done) => { + it("does not track a failed decryption where the event is subsequently successfully decrypted", () => { const decryptedEvent = createFailedDecryptionEvent(); const tracker = new DecryptionFailureTracker( (total) => { @@ -164,13 +156,12 @@ describe("DecryptionFailureTracker", function () { // Immediately track the newest failures tracker.trackFailures(); - done(); }); it( "does not track a failed decryption where the event is subsequently successfully decrypted " + "and later becomes visible", - (done) => { + () => { const decryptedEvent = createFailedDecryptionEvent(); const tracker = new DecryptionFailureTracker( (total) => { @@ -193,11 +184,10 @@ describe("DecryptionFailureTracker", function () { // Immediately track the newest failures tracker.trackFailures(); - done(); }, ); - it("only tracks a single failure per event, despite multiple failed decryptions for multiple events", (done) => { + it("only tracks a single failure per event, despite multiple failed decryptions for multiple events", () => { const decryptedEvent = createFailedDecryptionEvent(); const decryptedEvent2 = createFailedDecryptionEvent(); @@ -231,11 +221,9 @@ describe("DecryptionFailureTracker", function () { tracker.trackFailures(); expect(count).toBe(2, count + " failures tracked, should only track a single failure per event"); - - done(); }); - it("should not track a failure for an event that was tracked previously", (done) => { + it("should not track a failure for an event that was tracked previously", () => { const decryptedEvent = createFailedDecryptionEvent(); let count = 0; @@ -261,11 +249,9 @@ describe("DecryptionFailureTracker", function () { tracker.trackFailures(); expect(count).toBe(1, "should only track a single failure per event"); - - done(); }); - xit("should not track a failure for an event that was tracked in a previous session", (done) => { + it.skip("should not track a failure for an event that was tracked in a previous session", () => { // This test uses localStorage, clear it beforehand localStorage.clear(); @@ -304,8 +290,6 @@ describe("DecryptionFailureTracker", function () { secondTracker.trackFailures(); expect(count).toBe(1, count + " failures tracked, should only track a single failure per event"); - - done(); }); it("should count different error codes separately for multiple failures with different error codes", () => { diff --git a/test/Notifier-test.ts b/test/Notifier-test.ts index e156658ddc..033360d04c 100644 --- a/test/Notifier-test.ts +++ b/test/Notifier-test.ts @@ -302,7 +302,7 @@ describe("Notifier", () => { ); }); - it("should display the expected notification for a broadcast chunk with sequence = 1", () => { + it("should display the expected notification for a broadcast chunk with sequence = 2", () => { const audioEvent = mkAudioEvent({ sequence: 2 }); Notifier.displayPopupNotification(audioEvent, testRoom); expect(MockPlatform.displayNotification).not.toHaveBeenCalled(); diff --git a/test/PosthogAnalytics-test.ts b/test/PosthogAnalytics-test.ts index 5188bd9a1f..e0b47e028e 100644 --- a/test/PosthogAnalytics-test.ts +++ b/test/PosthogAnalytics-test.ts @@ -35,7 +35,7 @@ const getFakePosthog = (): PostHog => register: jest.fn(), } as unknown as PostHog); -export interface ITestEvent extends IPosthogEvent { +interface ITestEvent extends IPosthogEvent { eventName: "JestTestEvents"; foo?: string; } diff --git a/test/RoomNotifs-test.ts b/test/RoomNotifs-test.ts index 04ee9e693b..e80e943e3c 100644 --- a/test/RoomNotifs-test.ts +++ b/test/RoomNotifs-test.ts @@ -218,7 +218,7 @@ describe("RoomNotifs test", () => { expect(getUnreadNotificationCount(room, NotificationCountType.Highlight, THREAD_ID)).toBe(0); }); - it("counts notifications type", () => { + it("counts thread notifications type", () => { room.setThreadUnreadNotificationCount(THREAD_ID, NotificationCountType.Total, 2); room.setThreadUnreadNotificationCount(THREAD_ID, NotificationCountType.Highlight, 1); diff --git a/test/ScalarAuthClient-test.ts b/test/ScalarAuthClient-test.ts index 9dad8e2459..aa4213c14a 100644 --- a/test/ScalarAuthClient-test.ts +++ b/test/ScalarAuthClient-test.ts @@ -58,7 +58,7 @@ describe("ScalarAuthClient", function () { await sac.connect(); - expect(sac.exchangeForScalarToken).toBeCalledWith(tokenObject); + expect(sac.exchangeForScalarToken).toHaveBeenCalledWith(tokenObject); expect(sac.hasCredentials).toBeTruthy(); // @ts-ignore private property expect(sac.scalarToken).toEqual("wokentoken"); diff --git a/test/SlidingSyncManager-test.ts b/test/SlidingSyncManager-test.ts index 1918366383..3b49e7ee2a 100644 --- a/test/SlidingSyncManager-test.ts +++ b/test/SlidingSyncManager-test.ts @@ -46,7 +46,7 @@ describe("SlidingSyncManager", () => { mocked(slidingSync.getRoomSubscriptions).mockReturnValue(subs); mocked(slidingSync.modifyRoomSubscriptions).mockResolvedValue("yep"); await manager.setRoomVisible(roomId, true); - expect(slidingSync.modifyRoomSubscriptions).toBeCalledWith(new Set([roomId])); + expect(slidingSync.modifyRoomSubscriptions).toHaveBeenCalledWith(new Set([roomId])); }); it("adds a custom subscription for a lazy-loadable room", async () => { const roomId = "!lazy:id"; @@ -72,9 +72,9 @@ describe("SlidingSyncManager", () => { mocked(slidingSync.getRoomSubscriptions).mockReturnValue(subs); mocked(slidingSync.modifyRoomSubscriptions).mockResolvedValue("yep"); await manager.setRoomVisible(roomId, true); - expect(slidingSync.modifyRoomSubscriptions).toBeCalledWith(new Set([roomId])); + expect(slidingSync.modifyRoomSubscriptions).toHaveBeenCalledWith(new Set([roomId])); // we aren't prescriptive about what the sub name is. - expect(slidingSync.useCustomSubscription).toBeCalledWith(roomId, expect.anything()); + expect(slidingSync.useCustomSubscription).toHaveBeenCalledWith(roomId, expect.anything()); }); }); @@ -86,7 +86,7 @@ describe("SlidingSyncManager", () => { await manager.ensureListRegistered(listKey, { sort: ["by_recency"], }); - expect(slidingSync.setList).toBeCalledWith( + expect(slidingSync.setList).toHaveBeenCalledWith( listKey, expect.objectContaining({ sort: ["by_recency"], @@ -103,7 +103,7 @@ describe("SlidingSyncManager", () => { await manager.ensureListRegistered(listKey, { sort: ["by_recency"], }); - expect(slidingSync.setList).toBeCalledWith( + expect(slidingSync.setList).toHaveBeenCalledWith( listKey, expect.objectContaining({ sort: ["by_recency"], @@ -121,8 +121,8 @@ describe("SlidingSyncManager", () => { await manager.ensureListRegistered(listKey, { ranges: [[0, 52]], }); - expect(slidingSync.setList).not.toBeCalled(); - expect(slidingSync.setListRanges).toBeCalledWith(listKey, [[0, 52]]); + expect(slidingSync.setList).not.toHaveBeenCalled(); + expect(slidingSync.setListRanges).toHaveBeenCalledWith(listKey, [[0, 52]]); }); it("no-ops for idential changes", async () => { @@ -136,8 +136,8 @@ describe("SlidingSyncManager", () => { ranges: [[0, 42]], sort: ["by_recency"], }); - expect(slidingSync.setList).not.toBeCalled(); - expect(slidingSync.setListRanges).not.toBeCalled(); + expect(slidingSync.setList).not.toHaveBeenCalled(); + expect(slidingSync.setListRanges).not.toHaveBeenCalled(); }); }); @@ -163,12 +163,12 @@ describe("SlidingSyncManager", () => { [50, 59], [60, 69], ]; - expect(slidingSync.getListData).toBeCalledTimes(wantWindows.length); - expect(slidingSync.setList).toBeCalledTimes(1); - expect(slidingSync.setListRanges).toBeCalledTimes(wantWindows.length - 1); + expect(slidingSync.getListData).toHaveBeenCalledTimes(wantWindows.length); + expect(slidingSync.setList).toHaveBeenCalledTimes(1); + expect(slidingSync.setListRanges).toHaveBeenCalledTimes(wantWindows.length - 1); wantWindows.forEach((range, i) => { if (i === 0) { - expect(slidingSync.setList).toBeCalledWith( + expect(slidingSync.setList).toHaveBeenCalledWith( SlidingSyncManager.ListSearch, expect.objectContaining({ ranges: [[0, batchSize - 1], range], @@ -176,7 +176,7 @@ describe("SlidingSyncManager", () => { ); return; } - expect(slidingSync.setListRanges).toBeCalledWith(SlidingSyncManager.ListSearch, [ + expect(slidingSync.setListRanges).toHaveBeenCalledWith(SlidingSyncManager.ListSearch, [ [0, batchSize - 1], range, ]); @@ -193,9 +193,9 @@ describe("SlidingSyncManager", () => { }; }); await manager.startSpidering(batchSize, gapMs); - expect(slidingSync.getListData).toBeCalledTimes(1); - expect(slidingSync.setList).toBeCalledTimes(1); - expect(slidingSync.setList).toBeCalledWith( + expect(slidingSync.getListData).toHaveBeenCalledTimes(1); + expect(slidingSync.setList).toHaveBeenCalledTimes(1); + expect(slidingSync.setList).toHaveBeenCalledWith( SlidingSyncManager.ListSearch, expect.objectContaining({ ranges: [ @@ -216,9 +216,9 @@ describe("SlidingSyncManager", () => { }; }); await manager.startSpidering(batchSize, gapMs); - expect(slidingSync.getListData).toBeCalledTimes(1); - expect(slidingSync.setList).toBeCalledTimes(1); - expect(slidingSync.setList).toBeCalledWith( + expect(slidingSync.getListData).toHaveBeenCalledTimes(1); + expect(slidingSync.setList).toHaveBeenCalledTimes(1); + expect(slidingSync.setList).toHaveBeenCalledWith( SlidingSyncManager.ListSearch, expect.objectContaining({ ranges: [ diff --git a/test/Terms-test.tsx b/test/Terms-test.tsx index 7d02c3fe66..c04ddd03dd 100644 --- a/test/Terms-test.tsx +++ b/test/Terms-test.tsx @@ -68,7 +68,7 @@ describe("Terms", function () { const interactionCallback = jest.fn().mockResolvedValue([]); await startTermsFlow([IM_SERVICE_ONE], interactionCallback); - expect(interactionCallback).toBeCalledWith( + expect(interactionCallback).toHaveBeenCalledWith( [ { service: IM_SERVICE_ONE, @@ -100,7 +100,7 @@ describe("Terms", function () { await startTermsFlow([IM_SERVICE_ONE], interactionCallback); expect(interactionCallback).not.toHaveBeenCalled(); - expect(mockClient.agreeToTerms).toBeCalledWith(SERVICE_TYPES.IM, "https://imone.test", "a token token", [ + expect(mockClient.agreeToTerms).toHaveBeenCalledWith(SERVICE_TYPES.IM, "https://imone.test", "a token token", [ "http://example.com/one", ]); }); @@ -124,7 +124,7 @@ describe("Terms", function () { const interactionCallback = jest.fn().mockResolvedValue(["http://example.com/one", "http://example.com/two"]); await startTermsFlow([IM_SERVICE_ONE], interactionCallback); - expect(interactionCallback).toBeCalledWith( + expect(interactionCallback).toHaveBeenCalledWith( [ { service: IM_SERVICE_ONE, @@ -135,7 +135,7 @@ describe("Terms", function () { ], ["http://example.com/one"], ); - expect(mockClient.agreeToTerms).toBeCalledWith(SERVICE_TYPES.IM, "https://imone.test", "a token token", [ + expect(mockClient.agreeToTerms).toHaveBeenCalledWith(SERVICE_TYPES.IM, "https://imone.test", "a token token", [ "http://example.com/one", "http://example.com/two", ]); @@ -170,7 +170,7 @@ describe("Terms", function () { const interactionCallback = jest.fn().mockResolvedValue(["http://example.com/one", "http://example.com/two"]); await startTermsFlow([IM_SERVICE_ONE, IM_SERVICE_TWO], interactionCallback); - expect(interactionCallback).toBeCalledWith( + expect(interactionCallback).toHaveBeenCalledWith( [ { service: IM_SERVICE_TWO, @@ -181,10 +181,10 @@ describe("Terms", function () { ], ["http://example.com/one"], ); - expect(mockClient.agreeToTerms).toBeCalledWith(SERVICE_TYPES.IM, "https://imone.test", "a token token", [ + expect(mockClient.agreeToTerms).toHaveBeenCalledWith(SERVICE_TYPES.IM, "https://imone.test", "a token token", [ "http://example.com/one", ]); - expect(mockClient.agreeToTerms).toBeCalledWith(SERVICE_TYPES.IM, "https://imtwo.test", "a token token", [ + expect(mockClient.agreeToTerms).toHaveBeenCalledWith(SERVICE_TYPES.IM, "https://imtwo.test", "a token token", [ "http://example.com/two", ]); }); diff --git a/test/TextForEvent-test.ts b/test/TextForEvent-test.ts index 97a093efee..161d3e2650 100644 --- a/test/TextForEvent-test.ts +++ b/test/TextForEvent-test.ts @@ -471,7 +471,7 @@ describe("TextForEvent", () => { expect(textForEvent(callEvent)).toEqual("Video call started in Test room."); }); - it("returns correct message for call event when supported", () => { + it("returns correct message for call event when not supported", () => { mocked(mockClient).supportsVoip.mockReturnValue(false); expect(textForEvent(callEvent)).toEqual( diff --git a/test/accessibility/KeyboardShortcutUtils-test.ts b/test/accessibility/KeyboardShortcutUtils-test.ts index cca7b55085..2a78f7c1b8 100644 --- a/test/accessibility/KeyboardShortcutUtils-test.ts +++ b/test/accessibility/KeyboardShortcutUtils-test.ts @@ -59,7 +59,7 @@ describe("KeyboardShortcutUtils", () => { }); describe("correctly filters shortcuts", () => { - it("when on web and not on macOS ", async () => { + it("when on web and not on macOS", async () => { mockKeyboardShortcuts({ KEYBOARD_SHORTCUTS: { Keybind1: {}, diff --git a/test/components/structures/MessagePanel-test.tsx b/test/components/structures/MessagePanel-test.tsx index e02e96b616..b565cef3bc 100644 --- a/test/components/structures/MessagePanel-test.tsx +++ b/test/components/structures/MessagePanel-test.tsx @@ -46,7 +46,6 @@ const roomId = "!roomId:server_name"; describe("MessagePanel", function () { let clock: FakeTimers.InstalledClock; - const realSetTimeout = window.setTimeout; const events = mkEvents(); const userId = "@me:here"; const client = getMockClientWithEventEmitter({ @@ -404,7 +403,7 @@ describe("MessagePanel", function () { expect(isReadMarkerVisible(rm)).toBeFalsy(); }); - it("shows a ghost read-marker when the read-marker moves", function (done) { + it("shows a ghost read-marker when the read-marker moves", function () { // fake the clock so that we can test the velocity animation. clock = FakeTimers.install(); @@ -446,19 +445,9 @@ describe("MessagePanel", function () { // the second should be the real thing expect(readMarkers[1].previousSibling).toEqual(tiles[6]); - // advance the clock, and then let the browser run an animation frame, - // to let the animation start + // advance the clock, and then let the browser run an animation frame to let the animation start clock.tick(1500); - - realSetTimeout(() => { - // then advance it again to let it complete - clock.tick(1000); - realSetTimeout(() => { - // the ghost should now have finished - expect(hr.style.opacity).toEqual("0"); - done(); - }, 100); - }, 100); + expect(hr.style.opacity).toEqual("0"); }); it("should collapse creation events", function () { diff --git a/test/components/structures/ThreadView-test.tsx b/test/components/structures/ThreadView-test.tsx index 5b1526843b..94cfc66096 100644 --- a/test/components/structures/ThreadView-test.tsx +++ b/test/components/structures/ThreadView-test.tsx @@ -147,7 +147,7 @@ describe("ThreadView", () => { ); }); - it("sends a message with the correct fallback", async () => { + it("sends a thread message with the correct fallback", async () => { const { container } = await getComponent(); const { rootEvent: rootEvent2 } = mkThread({ diff --git a/test/components/views/auth/RegistrationToken-test.tsx b/test/components/views/auth/RegistrationToken-test.tsx index fef05dd180..bd10615f7d 100644 --- a/test/components/views/auth/RegistrationToken-test.tsx +++ b/test/components/views/auth/RegistrationToken-test.tsx @@ -84,7 +84,7 @@ describe("InteractiveAuthComponent", function () { await flushPromises(); expect(makeRequest).toHaveBeenCalledTimes(1); - expect(makeRequest).toBeCalledWith( + expect(makeRequest).toHaveBeenCalledWith( expect.objectContaining({ session: "sess", type: "m.login.registration_token", @@ -92,8 +92,8 @@ describe("InteractiveAuthComponent", function () { }), ); - expect(onAuthFinished).toBeCalledTimes(1); - expect(onAuthFinished).toBeCalledWith( + expect(onAuthFinished).toHaveBeenCalledTimes(1); + expect(onAuthFinished).toHaveBeenCalledWith( true, { a: 1 }, { clientSecret: "t35tcl1Ent5ECr3T", emailSid: undefined }, diff --git a/test/components/views/dialogs/InteractiveAuthDialog-test.tsx b/test/components/views/dialogs/InteractiveAuthDialog-test.tsx index 475a173913..518d13e8e8 100644 --- a/test/components/views/dialogs/InteractiveAuthDialog-test.tsx +++ b/test/components/views/dialogs/InteractiveAuthDialog-test.tsx @@ -79,7 +79,7 @@ describe("InteractiveAuthDialog", function () { await flushPromises(); expect(makeRequest).toHaveBeenCalledTimes(1); - expect(makeRequest).toBeCalledWith( + expect(makeRequest).toHaveBeenCalledWith( expect.objectContaining({ session: "sess", type: "m.login.password", @@ -91,7 +91,7 @@ describe("InteractiveAuthDialog", function () { }), ); - expect(onFinished).toBeCalledTimes(1); - expect(onFinished).toBeCalledWith(true, { a: 1 }); + expect(onFinished).toHaveBeenCalledTimes(1); + expect(onFinished).toHaveBeenCalledWith(true, { a: 1 }); }); }); diff --git a/test/components/views/dialogs/MessageEditHistoryDialog-test.tsx b/test/components/views/dialogs/MessageEditHistoryDialog-test.tsx index cadb92e488..28f1aa4765 100644 --- a/test/components/views/dialogs/MessageEditHistoryDialog-test.tsx +++ b/test/components/views/dialogs/MessageEditHistoryDialog-test.tsx @@ -69,7 +69,7 @@ describe("", () => { expect(container).toMatchSnapshot(); }); - it("should support events with ", async () => { + it("should support events with", async () => { mockEdits( { msg: "My Great Massage", ts: undefined }, { msg: "My Great Massage?", ts: undefined }, diff --git a/test/components/views/dialogs/__snapshots__/MessageEditHistoryDialog-test.tsx.snap b/test/components/views/dialogs/__snapshots__/MessageEditHistoryDialog-test.tsx.snap index 0eb2683003..3fe3435143 100644 --- a/test/components/views/dialogs/__snapshots__/MessageEditHistoryDialog-test.tsx.snap +++ b/test/components/views/dialogs/__snapshots__/MessageEditHistoryDialog-test.tsx.snap @@ -112,7 +112,7 @@ exports[` should match the snapshot 1`] = ` `; -exports[` should support events with 1`] = ` +exports[` should support events with 1`] = `
", () => { `https://matrix.to/#/!room:domain.org/${pollEnd3.getId()!}`, ); }); - - it("navigates back to poll list from detail view on header click", async () => { - await setupRoomWithPollEvents([pollStart1, pollStart2, pollStart3], [], [pollEnd3], mockClient, room); - - const { getByText, queryByText, getByTestId, container } = getComponent(); - await flushPromises(); - - fireEvent.click(getByText("Question?")); - - // detail view - expect(getByText("Question?")).toBeInTheDocument(); - - // header not shown - expect(queryByText("Polls history")).not.toBeInTheDocument(); - - expect(getByText("Active polls")).toMatchSnapshot(); - fireEvent.click(getByText("Active polls")); - - // main list header displayed again - expect(getByText("Polls history")).toBeInTheDocument(); - // active filter still active - expect(getByTestId("filter-tab-PollHistoryDialog_filter-ACTIVE").firstElementChild).toBeChecked(); - // list displayed - expect(container.getElementsByClassName("mx_PollHistoryList_list").length).toBeTruthy(); - }); }); }); diff --git a/test/components/views/dialogs/polls/__snapshots__/PollHistoryDialog-test.tsx.snap b/test/components/views/dialogs/polls/__snapshots__/PollHistoryDialog-test.tsx.snap index 9c08631c2a..a9c8d7f3e1 100644 --- a/test/components/views/dialogs/polls/__snapshots__/PollHistoryDialog-test.tsx.snap +++ b/test/components/views/dialogs/polls/__snapshots__/PollHistoryDialog-test.tsx.snap @@ -29,19 +29,6 @@ exports[` Poll detail navigates back to poll list from deta
`; -exports[` Poll detail navigates back to poll list from detail view on header click 2`] = ` -
-
- Active polls -
-`; - exports[` renders a list of active polls when there are polls in the room 1`] = `
", () => { expect(modalSpy).toHaveBeenCalled(); }); - it("does nothing on click when a beacon has no location", () => { - makeRoomWithStateEvents([aliceBeaconInfo], { roomId, mockClient }); - const component = getComponent({ mxEvent: aliceBeaconInfo }); - - fireEvent.click(component.container.querySelector(".mx_MBeaconBody_map")!); - - expect(modalSpy).not.toHaveBeenCalled(); - }); - it("updates latest location", () => { const room = makeRoomWithStateEvents([aliceBeaconInfo], { roomId, mockClient }); getComponent({ mxEvent: aliceBeaconInfo }); diff --git a/test/components/views/messages/MPollBody-test.tsx b/test/components/views/messages/MPollBody-test.tsx index 6cb3187603..bc77d90edd 100644 --- a/test/components/views/messages/MPollBody-test.tsx +++ b/test/components/views/messages/MPollBody-test.tsx @@ -958,7 +958,7 @@ function endedVotesCount(renderResult: RenderResult, value: string): string { return votesCount(renderResult, value); } -export function newPollStart(answers?: PollAnswer[], question?: string, disclosed = true): PollStartEventContent { +function newPollStart(answers?: PollAnswer[], question?: string, disclosed = true): PollStartEventContent { if (!answers) { answers = [ { id: "pizza", [M_TEXT.name]: "Pizza" }, @@ -1033,7 +1033,7 @@ function expectedResponseEventCall(answer: string) { return [roomId, eventType, content]; } -export function newPollEndEvent(sender = "@me:example.com", ts = 0): MatrixEvent { +function newPollEndEvent(sender = "@me:example.com", ts = 0): MatrixEvent { return makePollEndEvent("$mypoll", "#myroom:example.com", sender, ts); } diff --git a/test/components/views/messages/MessageActionBar-test.tsx b/test/components/views/messages/MessageActionBar-test.tsx index d7e2ea509a..da475a58de 100644 --- a/test/components/views/messages/MessageActionBar-test.tsx +++ b/test/components/views/messages/MessageActionBar-test.tsx @@ -195,7 +195,7 @@ describe("", () => { // because beforeRedaction event is fired... before redaction // event is unchanged at point when this component updates // TODO file bug - xit("updates component on before redaction event", () => { + it.skip("updates component on before redaction event", () => { const event = new MatrixEvent({ type: EventType.RoomMessage, sender: userId, diff --git a/test/components/views/right_panel/UserInfo-test.tsx b/test/components/views/right_panel/UserInfo-test.tsx index 1047db4478..1f95c72950 100644 --- a/test/components/views/right_panel/UserInfo-test.tsx +++ b/test/components/views/right_panel/UserInfo-test.tsx @@ -420,7 +420,7 @@ describe("", () => { expect(screen.getByRole("button", { name: /share link to user/i })).toBeInTheDocument(); }); - it("does not show ignore or direct message buttons when member userId matches client userId ", () => { + it("does not show ignore or direct message buttons when member userId matches client userId", () => { mockClient.getUserId.mockReturnValueOnce(member.userId); renderComponent(); @@ -428,7 +428,7 @@ describe("", () => { expect(screen.queryByRole("button", { name: /message/i })).not.toBeInTheDocument(); }); - it("shows ignore, direct message and mention buttons when member userId does not match client userId ", () => { + it("shows ignore, direct message and mention buttons when member userId does not match client userId", () => { // call to client.getUserId returns undefined, which will not match member.userId renderComponent(); diff --git a/test/components/views/rooms/MemberList-test.tsx b/test/components/views/rooms/MemberList-test.tsx index 602f05e130..efbff422e7 100644 --- a/test/components/views/rooms/MemberList-test.tsx +++ b/test/components/views/rooms/MemberList-test.tsx @@ -137,13 +137,11 @@ describe("MemberList", () => { ) as unknown as Component; }); - afterEach((done) => { + afterEach(() => { if (parentDiv) { ReactDOM.unmountComponentAtNode(parentDiv); parentDiv.remove(); } - - done(); }); function expectOrderedByPresenceAndPowerLevel(memberTiles: MemberTile[], isPresenceEnabled: boolean) { diff --git a/test/components/views/rooms/wysiwyg_composer/EditWysiwygComposer-test.tsx b/test/components/views/rooms/wysiwyg_composer/EditWysiwygComposer-test.tsx index 7b7b87e8be..0098859ea2 100644 --- a/test/components/views/rooms/wysiwyg_composer/EditWysiwygComposer-test.tsx +++ b/test/components/views/rooms/wysiwyg_composer/EditWysiwygComposer-test.tsx @@ -177,12 +177,12 @@ describe("EditWysiwygComposer", () => { screen.getByText("Cancel").click(); // Then - expect(spyDispatcher).toBeCalledWith({ + expect(spyDispatcher).toHaveBeenCalledWith({ action: Action.EditEvent, event: null, timelineRenderingType: defaultRoomContext.timelineRenderingType, }); - expect(spyDispatcher).toBeCalledWith({ + expect(spyDispatcher).toHaveBeenCalledWith({ action: Action.FocusSendMessageComposer, context: defaultRoomContext.timelineRenderingType, }); @@ -215,10 +215,10 @@ describe("EditWysiwygComposer", () => { "msgtype": "m.text", }; await waitFor(() => - expect(mockClient.sendMessage).toBeCalledWith(mockEvent.getRoomId(), null, expectedContent), + expect(mockClient.sendMessage).toHaveBeenCalledWith(mockEvent.getRoomId(), null, expectedContent), ); - expect(spyDispatcher).toBeCalledWith({ action: "message_sent" }); + expect(spyDispatcher).toHaveBeenCalledWith({ action: "message_sent" }); }); }); diff --git a/test/components/views/rooms/wysiwyg_composer/components/LinkModal-test.tsx b/test/components/views/rooms/wysiwyg_composer/components/LinkModal-test.tsx index a0d8176339..f7ae116720 100644 --- a/test/components/views/rooms/wysiwyg_composer/components/LinkModal-test.tsx +++ b/test/components/views/rooms/wysiwyg_composer/components/LinkModal-test.tsx @@ -84,7 +84,7 @@ describe("LinkModal", () => { // Then await waitFor(() => { expect(selectionSpy).toHaveBeenCalledWith(defaultValue); - expect(onFinished).toBeCalledTimes(1); + expect(onFinished).toHaveBeenCalledTimes(1); }); // Then @@ -127,7 +127,7 @@ describe("LinkModal", () => { // Then await waitFor(() => { expect(selectionSpy).toHaveBeenCalledWith(defaultValue); - expect(onFinished).toBeCalledTimes(1); + expect(onFinished).toHaveBeenCalledTimes(1); }); // Then @@ -142,7 +142,7 @@ describe("LinkModal", () => { // Then expect(formattingFunctions.removeLinks).toHaveBeenCalledTimes(1); - expect(onFinished).toBeCalledTimes(1); + expect(onFinished).toHaveBeenCalledTimes(1); }); it("Should display the link in editing", async () => { diff --git a/test/components/views/rooms/wysiwyg_composer/components/PlainTextComposer-test.tsx b/test/components/views/rooms/wysiwyg_composer/components/PlainTextComposer-test.tsx index 5ab567098b..e3b1b2fce1 100644 --- a/test/components/views/rooms/wysiwyg_composer/components/PlainTextComposer-test.tsx +++ b/test/components/views/rooms/wysiwyg_composer/components/PlainTextComposer-test.tsx @@ -74,7 +74,7 @@ describe("PlainTextComposer", () => { await userEvent.type(screen.getByRole("textbox"), content); // Then - expect(onChange).toBeCalledWith(content); + expect(onChange).toHaveBeenCalledWith(content); }); it("Should call onSend when Enter is pressed when ctrlEnterToSend is false", async () => { @@ -84,7 +84,7 @@ describe("PlainTextComposer", () => { await userEvent.type(screen.getByRole("textbox"), "{enter}"); // Then it sends a message - expect(onSend).toBeCalledTimes(1); + expect(onSend).toHaveBeenCalledTimes(1); }); it("Should not call onSend when Enter is pressed when ctrlEnterToSend is true", async () => { @@ -95,7 +95,7 @@ describe("PlainTextComposer", () => { await userEvent.type(screen.getByRole("textbox"), "{enter}"); // Then it does not send a message - expect(onSend).toBeCalledTimes(0); + expect(onSend).toHaveBeenCalledTimes(0); }); it("Should only call onSend when ctrl+enter is pressed when ctrlEnterToSend is true on windows", async () => { @@ -109,15 +109,15 @@ describe("PlainTextComposer", () => { // Then it does NOT send a message on enter await userEvent.type(textBox, "{enter}"); - expect(onSend).toBeCalledTimes(0); + expect(onSend).toHaveBeenCalledTimes(0); // Then it does NOT send a message on windows+enter await userEvent.type(textBox, "{meta>}{enter}{meta/}"); - expect(onSend).toBeCalledTimes(0); + expect(onSend).toHaveBeenCalledTimes(0); // Then it does send a message on ctrl+enter await userEvent.type(textBox, "{control>}{enter}{control/}"); - expect(onSend).toBeCalledTimes(1); + expect(onSend).toHaveBeenCalledTimes(1); }); it("Should only call onSend when cmd+enter is pressed when ctrlEnterToSend is true on mac", async () => { @@ -132,15 +132,15 @@ describe("PlainTextComposer", () => { // Then it does NOT send a message on enter await userEvent.type(textBox, "{enter}"); - expect(onSend).toBeCalledTimes(0); + expect(onSend).toHaveBeenCalledTimes(0); // Then it does NOT send a message on ctrl+enter await userEvent.type(textBox, "{control>}{enter}{control/}"); - expect(onSend).toBeCalledTimes(0); + expect(onSend).toHaveBeenCalledTimes(0); // Then it does send a message on cmd+enter await userEvent.type(textBox, "{meta>}{enter}{meta/}"); - expect(onSend).toBeCalledTimes(1); + expect(onSend).toHaveBeenCalledTimes(1); }); it("Should insert a newline character when shift enter is pressed when ctrlEnterToSend is false", async () => { @@ -155,7 +155,7 @@ describe("PlainTextComposer", () => { await userEvent.type(textBox, inputWithShiftEnter); // Then it does not send a message, but inserts a newline character - expect(onSend).toBeCalledTimes(0); + expect(onSend).toHaveBeenCalledTimes(0); expect(textBox.innerHTML).toBe(expectedInnerHtml); }); @@ -172,7 +172,7 @@ describe("PlainTextComposer", () => { await userEvent.type(textBox, keyboardInput); // Then it does not send a message, but inserts a newline character - expect(onSend).toBeCalledTimes(0); + expect(onSend).toHaveBeenCalledTimes(0); expect(textBox.innerHTML).toBe(expectedInnerHtml); }); @@ -188,7 +188,7 @@ describe("PlainTextComposer", () => { await userEvent.type(textBox, "{enter}hello"); // Then it does not send a message, but inserts a newline character - expect(onSend).toBeCalledTimes(0); + expect(onSend).toHaveBeenCalledTimes(0); expect(textBox).not.toContainHTML(enterThenTypeHtml); }); @@ -204,7 +204,7 @@ describe("PlainTextComposer", () => { await userEvent.type(textBox, "{enter}"); // Then it does not send a message, but inserts a newline character - expect(onSend).toBeCalledTimes(0); + expect(onSend).toHaveBeenCalledTimes(0); expect(textBox).not.toContainHTML(defaultEnterHtml); }); diff --git a/test/components/views/rooms/wysiwyg_composer/components/WysiwygComposer-test.tsx b/test/components/views/rooms/wysiwyg_composer/components/WysiwygComposer-test.tsx index 5a41488be4..aa5c0bd739 100644 --- a/test/components/views/rooms/wysiwyg_composer/components/WysiwygComposer-test.tsx +++ b/test/components/views/rooms/wysiwyg_composer/components/WysiwygComposer-test.tsx @@ -88,10 +88,10 @@ describe("WysiwygComposer", () => { }); // Then - await waitFor(() => expect(onChange).toBeCalledWith("foo bar")); + await waitFor(() => expect(onChange).toHaveBeenCalledWith("foo bar")); }); - it("Should call onSend when Enter is pressed ", async () => { + it("Should call onSend when Enter is pressed", async () => { //When fireEvent( screen.getByRole("textbox"), @@ -101,18 +101,18 @@ describe("WysiwygComposer", () => { ); // Then it sends a message - await waitFor(() => expect(onSend).toBeCalledTimes(1)); + await waitFor(() => expect(onSend).toHaveBeenCalledTimes(1)); }); - it("Should not call onSend when Shift+Enter is pressed ", async () => { + it("Should not call onSend when Shift+Enter is pressed", async () => { //When await userEvent.type(screen.getByRole("textbox"), "{shift>}{enter}"); // Then it sends a message - await waitFor(() => expect(onSend).toBeCalledTimes(0)); + await waitFor(() => expect(onSend).toHaveBeenCalledTimes(0)); }); - it("Should not call onSend when ctrl+Enter is pressed ", async () => { + it("Should not call onSend when ctrl+Enter is pressed", async () => { //When // Using userEvent.type or .keyboard wasn't working as expected in the case of ctrl+enter fireEvent( @@ -124,23 +124,23 @@ describe("WysiwygComposer", () => { ); // Then it sends a message - await waitFor(() => expect(onSend).toBeCalledTimes(0)); + await waitFor(() => expect(onSend).toHaveBeenCalledTimes(0)); }); - it("Should not call onSend when alt+Enter is pressed ", async () => { + it("Should not call onSend when alt+Enter is pressed", async () => { //When await userEvent.type(screen.getByRole("textbox"), "{alt>}{enter}"); // Then it sends a message - await waitFor(() => expect(onSend).toBeCalledTimes(0)); + await waitFor(() => expect(onSend).toHaveBeenCalledTimes(0)); }); - it("Should not call onSend when meta+Enter is pressed ", async () => { + it("Should not call onSend when meta+Enter is pressed", async () => { //When await userEvent.type(screen.getByRole("textbox"), "{meta>}{enter}"); // Then it sends a message - await waitFor(() => expect(onSend).toBeCalledTimes(0)); + await waitFor(() => expect(onSend).toHaveBeenCalledTimes(0)); }); }); @@ -172,7 +172,7 @@ describe("WysiwygComposer", () => { ); // Then it does not send a message - await waitFor(() => expect(onSend).toBeCalledTimes(0)); + await waitFor(() => expect(onSend).toHaveBeenCalledTimes(0)); fireEvent( textbox, @@ -201,7 +201,7 @@ describe("WysiwygComposer", () => { ); // Then it sends a message - await waitFor(() => expect(onSend).toBeCalledTimes(1)); + await waitFor(() => expect(onSend).toHaveBeenCalledTimes(1)); }); }); @@ -269,7 +269,7 @@ describe("WysiwygComposer", () => { }); // Then - expect(spyDispatcher).toBeCalledTimes(0); + expect(spyDispatcher).toHaveBeenCalledTimes(0); }); it("Should moving when the composer is empty", async () => { @@ -281,7 +281,7 @@ describe("WysiwygComposer", () => { }); // Then - expect(spyDispatcher).toBeCalledWith({ + expect(spyDispatcher).toHaveBeenCalledWith({ action: Action.EditEvent, event: mockEvent, timelineRenderingType: defaultRoomContext.timelineRenderingType, @@ -316,7 +316,7 @@ describe("WysiwygComposer", () => { }); // Then - expect(spyDispatcher).toBeCalledTimes(0); + expect(spyDispatcher).toHaveBeenCalledTimes(0); }); it("Should not moving when the content has changed", async () => { @@ -340,7 +340,7 @@ describe("WysiwygComposer", () => { }); // Then - expect(spyDispatcher).toBeCalledTimes(0); + expect(spyDispatcher).toHaveBeenCalledTimes(0); }); it("Should moving up", async () => { @@ -366,7 +366,7 @@ describe("WysiwygComposer", () => { // Then await waitFor(() => - expect(spyDispatcher).toBeCalledWith({ + expect(spyDispatcher).toHaveBeenCalledWith({ action: Action.EditEvent, event: mockEvent, timelineRenderingType: defaultRoomContext.timelineRenderingType, @@ -401,7 +401,7 @@ describe("WysiwygComposer", () => { }); // Then - expect(spyDispatcher).toBeCalledWith({ + expect(spyDispatcher).toHaveBeenCalledWith({ action: Action.EditEvent, event: mockEvent, timelineRenderingType: defaultRoomContext.timelineRenderingType, @@ -427,7 +427,7 @@ describe("WysiwygComposer", () => { }); // Then - expect(spyDispatcher).toBeCalledTimes(0); + expect(spyDispatcher).toHaveBeenCalledTimes(0); }); it("Should not moving when the content has changed", async () => { @@ -451,7 +451,7 @@ describe("WysiwygComposer", () => { }); // Then - expect(spyDispatcher).toBeCalledTimes(0); + expect(spyDispatcher).toHaveBeenCalledTimes(0); }); it("Should moving down", async () => { @@ -479,7 +479,7 @@ describe("WysiwygComposer", () => { // Then await waitFor(() => - expect(spyDispatcher).toBeCalledWith({ + expect(spyDispatcher).toHaveBeenCalledWith({ action: Action.EditEvent, event: mockEvent, timelineRenderingType: defaultRoomContext.timelineRenderingType, @@ -516,7 +516,7 @@ describe("WysiwygComposer", () => { }); // Then - expect(spyDispatcher).toBeCalledWith({ + expect(spyDispatcher).toHaveBeenCalledWith({ action: Action.EditEvent, event: mockEvent, timelineRenderingType: defaultRoomContext.timelineRenderingType, @@ -549,7 +549,7 @@ describe("WysiwygComposer", () => { // Then await waitFor(() => - expect(spyDispatcher).toBeCalledWith({ + expect(spyDispatcher).toHaveBeenCalledWith({ action: Action.EditEvent, event: null, timelineRenderingType: defaultRoomContext.timelineRenderingType, diff --git a/test/components/views/rooms/wysiwyg_composer/utils/message-test.ts b/test/components/views/rooms/wysiwyg_composer/utils/message-test.ts index 733d5c117e..49442127d0 100644 --- a/test/components/views/rooms/wysiwyg_composer/utils/message-test.ts +++ b/test/components/views/rooms/wysiwyg_composer/utils/message-test.ts @@ -66,8 +66,8 @@ describe("message", () => { await sendMessage("", true, { roomContext: defaultRoomContext, mxClient: mockClient, permalinkCreator }); // Then - expect(mockClient.sendMessage).toBeCalledTimes(0); - expect(spyDispatcher).toBeCalledTimes(0); + expect(mockClient.sendMessage).toHaveBeenCalledTimes(0); + expect(spyDispatcher).toHaveBeenCalledTimes(0); }); it("Should not send message when there is no roomId", async () => { @@ -82,8 +82,8 @@ describe("message", () => { }); // Then - expect(mockClient.sendMessage).toBeCalledTimes(0); - expect(spyDispatcher).toBeCalledTimes(0); + expect(mockClient.sendMessage).toHaveBeenCalledTimes(0); + expect(spyDispatcher).toHaveBeenCalledTimes(0); }); describe("calls client.sendMessage with", () => { @@ -108,7 +108,7 @@ describe("message", () => { }); // Then - expect(mockClient.sendMessage).toBeCalledWith(expect.anything(), null, expect.anything()); + expect(mockClient.sendMessage).toHaveBeenCalledWith(expect.anything(), null, expect.anything()); }); it("a null argument if SendMessageParams has relation but rel_type does not match THREAD_RELATION_TYPE.name", async () => { // When @@ -123,7 +123,7 @@ describe("message", () => { }); // Then - expect(mockClient.sendMessage).toBeCalledWith(expect.anything(), null, expect.anything()); + expect(mockClient.sendMessage).toHaveBeenCalledWith(expect.anything(), null, expect.anything()); }); it("the event_id if SendMessageParams has relation and rel_type matches THREAD_RELATION_TYPE.name", async () => { @@ -139,7 +139,7 @@ describe("message", () => { }); // Then - expect(mockClient.sendMessage).toBeCalledWith(expect.anything(), "valid_id", expect.anything()); + expect(mockClient.sendMessage).toHaveBeenCalledWith(expect.anything(), "valid_id", expect.anything()); }); }); @@ -158,8 +158,8 @@ describe("message", () => { formatted_body: "hello world", msgtype: "m.text", }; - expect(mockClient.sendMessage).toBeCalledWith("myfakeroom", null, expectedContent); - expect(spyDispatcher).toBeCalledWith({ action: "message_sent" }); + expect(mockClient.sendMessage).toHaveBeenCalledWith("myfakeroom", null, expectedContent); + expect(spyDispatcher).toHaveBeenCalledWith({ action: "message_sent" }); }); it("Should send reply to html message", async () => { @@ -180,7 +180,7 @@ describe("message", () => { }); // Then - expect(spyDispatcher).toBeCalledWith({ + expect(spyDispatcher).toHaveBeenCalledWith({ action: "reply_to_event", event: null, context: defaultRoomContext.timelineRenderingType, @@ -200,7 +200,7 @@ describe("message", () => { }, }, }; - expect(mockClient.sendMessage).toBeCalledWith("myfakeroom", null, expectedContent); + expect(mockClient.sendMessage).toHaveBeenCalledWith("myfakeroom", null, expectedContent); }); it("Should scroll to bottom after sending a html message", async () => { @@ -213,7 +213,7 @@ describe("message", () => { }); // Then - expect(spyDispatcher).toBeCalledWith({ + expect(spyDispatcher).toHaveBeenCalledWith({ action: "scroll_to_bottom", timelineRenderingType: defaultRoomContext.timelineRenderingType, }); @@ -224,7 +224,7 @@ describe("message", () => { await sendMessage("🎉", false, { roomContext: defaultRoomContext, mxClient: mockClient, permalinkCreator }); // Then - expect(spyDispatcher).toBeCalledWith({ action: "effects.confetti" }); + expect(spyDispatcher).toHaveBeenCalledWith({ action: "effects.confetti" }); }); }); @@ -256,10 +256,10 @@ describe("message", () => { await editMessage("", { roomContext: defaultRoomContext, mxClient: mockClient, editorStateTransfer }); // Then - expect(mockClient.sendMessage).toBeCalledTimes(0); - expect(mockClient.cancelPendingEvent).toBeCalledTimes(1); - expect(mockCreateRedactEventDialog).toBeCalledTimes(1); - expect(spyDispatcher).toBeCalledTimes(0); + expect(mockClient.sendMessage).toHaveBeenCalledTimes(0); + expect(mockClient.cancelPendingEvent).toHaveBeenCalledTimes(1); + expect(mockCreateRedactEventDialog).toHaveBeenCalledTimes(1); + expect(spyDispatcher).toHaveBeenCalledTimes(0); }); it("Should do nothing if the content is unmodified", async () => { @@ -271,7 +271,7 @@ describe("message", () => { }); // Then - expect(mockClient.sendMessage).toBeCalledTimes(0); + expect(mockClient.sendMessage).toHaveBeenCalledTimes(0); }); it("Should send a message when the content is modified", async () => { @@ -301,8 +301,8 @@ describe("message", () => { msgtype, format, }; - expect(mockClient.sendMessage).toBeCalledWith(mockEvent.getRoomId(), null, expectedContent); - expect(spyDispatcher).toBeCalledWith({ action: "message_sent" }); + expect(mockClient.sendMessage).toHaveBeenCalledWith(mockEvent.getRoomId(), null, expectedContent); + expect(spyDispatcher).toHaveBeenCalledWith({ action: "message_sent" }); }); }); }); diff --git a/test/components/views/settings/devices/DeviceDetailHeading-test.tsx b/test/components/views/settings/devices/DeviceDetailHeading-test.tsx index 2224e6054b..3e4018066f 100644 --- a/test/components/views/settings/devices/DeviceDetailHeading-test.tsx +++ b/test/components/views/settings/devices/DeviceDetailHeading-test.tsx @@ -47,7 +47,7 @@ describe("", () => { expect({ container }).toMatchSnapshot(); }); - it("renders device id as fallback when device has no display name ", () => { + it("renders device id as fallback when device has no display name", () => { const { getByText } = render( getComponent({ device: { ...device, display_name: undefined }, diff --git a/test/components/views/settings/tabs/user/SessionManagerTab-test.tsx b/test/components/views/settings/tabs/user/SessionManagerTab-test.tsx index 22ba02e542..8358922527 100644 --- a/test/components/views/settings/tabs/user/SessionManagerTab-test.tsx +++ b/test/components/views/settings/tabs/user/SessionManagerTab-test.tsx @@ -207,17 +207,6 @@ describe("", () => { expect(container.getElementsByClassName("mx_Spinner").length).toBeTruthy(); }); - it("removes spinner when device fetch fails", async () => { - mockClient.getDevices.mockRejectedValue({ httpStatus: 404 }); - const { container } = render(getComponent()); - expect(mockClient.getDevices).toHaveBeenCalled(); - - await act(async () => { - await flushPromises(); - }); - expect(container.getElementsByClassName("mx_Spinner").length).toBeFalsy(); - }); - it("removes spinner when device fetch fails", async () => { // eat the expected error log jest.spyOn(logger, "error").mockImplementation(() => {}); @@ -760,7 +749,7 @@ describe("", () => { expect(mockClient.getDevices).toHaveBeenCalled(); }); - it("deletes a device when interactive auth is not required", async () => { + it("does not delete a device when interactive auth is not required", async () => { const { getByTestId } = render(getComponent()); await act(async () => { diff --git a/test/editor/deserialize-test.ts b/test/editor/deserialize-test.ts index bcc7de9a79..908b83a651 100644 --- a/test/editor/deserialize-test.ts +++ b/test/editor/deserialize-test.ts @@ -215,7 +215,7 @@ describe("editor/deserialize", function () { expect(parts[4]).toStrictEqual({ type: "plain", text: "```" }); }); // failing likely because of https://github.com/vector-im/element-web/issues/10316 - xit("code block with no trailing text and no newlines", function () { + it.skip("code block with no trailing text and no newlines", function () { const html = "
0xDEADBEEF
"; const parts = normalize(parseEvent(htmlMessage(html), createPartCreator())); expect(parts.length).toBe(5); @@ -412,7 +412,7 @@ describe("editor/deserialize", function () { text: "> no formatting here", }); }); - it("it strips plaintext replies", () => { + it("strips plaintext replies", () => { const body = "> Sender: foo\n\nMessage"; const parts = normalize(parseEvent(textMessageReply(body), createPartCreator(), { shouldEscape: false })); expect(parts.length).toBe(1); diff --git a/test/events/RelationsHelper-test.ts b/test/events/RelationsHelper-test.ts index 10859a349c..9eb45a4651 100644 --- a/test/events/RelationsHelper-test.ts +++ b/test/events/RelationsHelper-test.ts @@ -95,7 +95,7 @@ describe("RelationsHelper", () => { expect(() => { new RelationsHelper(event, RelationType.Reference, EventType.RoomMessage, client); - }).toThrowError("unable to create RelationsHelper: missing event ID"); + }).toThrow("unable to create RelationsHelper: missing event ID"); }); }); @@ -105,7 +105,7 @@ describe("RelationsHelper", () => { expect(() => { new RelationsHelper(event, RelationType.Reference, EventType.RoomMessage, client); - }).toThrowError("unable to create RelationsHelper: missing room ID"); + }).toThrow("unable to create RelationsHelper: missing room ID"); }); }); diff --git a/test/i18n-test/languageHandler-test.tsx b/test/i18n-test/languageHandler-test.tsx index 8c8b540231..66c88fe567 100644 --- a/test/i18n-test/languageHandler-test.tsx +++ b/test/i18n-test/languageHandler-test.tsx @@ -93,20 +93,17 @@ describe("languageHandler", function () { }); describe("when translations exist in language", () => { - beforeEach(function (done) { + beforeEach(function () { stubClient(); - setLanguage("en").then(done); + setLanguage("en"); setMissingEntryGenerator((key) => key.split("|", 2)[1]); }); - it("translates a string to german", function (done) { - setLanguage("de") - .then(function () { - const translated = _t(basicString); - expect(translated).toBe("Räume"); - }) - .then(done); + it("translates a string to german", async () => { + await setLanguage("de"); + const translated = _t(basicString); + expect(translated).toBe("Räume"); }); it.each(testCasesEn)("%s", (_d, translationString, variables, tags, result) => { diff --git a/test/stores/AutoRageshakeStore-test.ts b/test/stores/AutoRageshakeStore-test.ts index ff57bda59c..d7efeaee17 100644 --- a/test/stores/AutoRageshakeStore-test.ts +++ b/test/stores/AutoRageshakeStore-test.ts @@ -74,7 +74,8 @@ describe("AutoRageshakeStore", () => { }); it("should send a rageshake", () => { - expect(mocked(client).sendToDevice.mock.calls).toMatchInlineSnapshot(` + expect(mocked(client).sendToDevice.mock.calls).toMatchInlineSnapshot( + ` [ [ "im.vector.auto_rs_request", @@ -82,7 +83,7 @@ describe("AutoRageshakeStore", () => { "@userId:matrix.org": { "undefined": { "device_id": undefined, - "event_id": "${utdEvent.getId()}", + "event_id": "utd_event_id", "recipient_rageshake": undefined, "room_id": "!room:example.com", "sender_key": undefined, @@ -93,7 +94,8 @@ describe("AutoRageshakeStore", () => { }, ], ] - `); + `.replace("utd_event_id", utdEvent.getId()!), + ); }); }); }); diff --git a/test/stores/SpaceStore-test.ts b/test/stores/SpaceStore-test.ts index 907d000a48..2e086fd636 100644 --- a/test/stores/SpaceStore-test.ts +++ b/test/stores/SpaceStore-test.ts @@ -1179,34 +1179,34 @@ describe("SpaceStore", () => { const fn = jest.fn(); store.traverseSpace("!b:server", fn); - expect(fn).toBeCalledTimes(3); - expect(fn).toBeCalledWith("!a:server"); - expect(fn).toBeCalledWith("!b:server"); - expect(fn).toBeCalledWith("!c:server"); + expect(fn).toHaveBeenCalledTimes(3); + expect(fn).toHaveBeenCalledWith("!a:server"); + expect(fn).toHaveBeenCalledWith("!b:server"); + expect(fn).toHaveBeenCalledWith("!c:server"); }); it("including rooms", () => { const fn = jest.fn(); store.traverseSpace("!b:server", fn, true); - expect(fn).toBeCalledTimes(8); // twice for shared-child - expect(fn).toBeCalledWith("!a:server"); - expect(fn).toBeCalledWith("!a-child:server"); - expect(fn).toBeCalledWith("!b:server"); - expect(fn).toBeCalledWith("!b-child:server"); - expect(fn).toBeCalledWith("!c:server"); - expect(fn).toBeCalledWith("!c-child:server"); - expect(fn).toBeCalledWith("!shared-child:server"); + expect(fn).toHaveBeenCalledTimes(8); // twice for shared-child + expect(fn).toHaveBeenCalledWith("!a:server"); + expect(fn).toHaveBeenCalledWith("!a-child:server"); + expect(fn).toHaveBeenCalledWith("!b:server"); + expect(fn).toHaveBeenCalledWith("!b-child:server"); + expect(fn).toHaveBeenCalledWith("!c:server"); + expect(fn).toHaveBeenCalledWith("!c-child:server"); + expect(fn).toHaveBeenCalledWith("!shared-child:server"); }); it("excluding rooms", () => { const fn = jest.fn(); store.traverseSpace("!b:server", fn, false); - expect(fn).toBeCalledTimes(3); - expect(fn).toBeCalledWith("!a:server"); - expect(fn).toBeCalledWith("!b:server"); - expect(fn).toBeCalledWith("!c:server"); + expect(fn).toHaveBeenCalledTimes(3); + expect(fn).toHaveBeenCalledWith("!a:server"); + expect(fn).toHaveBeenCalledWith("!b:server"); + expect(fn).toHaveBeenCalledWith("!c:server"); }); }); diff --git a/test/stores/room-list/SlidingRoomListStore-test.ts b/test/stores/room-list/SlidingRoomListStore-test.ts index 6d23e16698..8d02ace27d 100644 --- a/test/stores/room-list/SlidingRoomListStore-test.ts +++ b/test/stores/room-list/SlidingRoomListStore-test.ts @@ -163,13 +163,13 @@ describe("SlidingRoomListStore", () => { it("setTagSorting alters the 'sort' option in the list", async () => { const tagId: TagID = "foo"; await store.setTagSorting(tagId, SortAlgorithm.Alphabetic); - expect(context._SlidingSyncManager!.ensureListRegistered).toBeCalledWith(tagId, { + expect(context._SlidingSyncManager!.ensureListRegistered).toHaveBeenCalledWith(tagId, { sort: SlidingSyncSortToFilter[SortAlgorithm.Alphabetic], }); expect(store.getTagSorting(tagId)).toEqual(SortAlgorithm.Alphabetic); await store.setTagSorting(tagId, SortAlgorithm.Recent); - expect(context._SlidingSyncManager!.ensureListRegistered).toBeCalledWith(tagId, { + expect(context._SlidingSyncManager!.ensureListRegistered).toHaveBeenCalledWith(tagId, { sort: SlidingSyncSortToFilter[SortAlgorithm.Recent], }); expect(store.getTagSorting(tagId)).toEqual(SortAlgorithm.Recent); diff --git a/test/stores/widgets/StopGapWidgetDriver-test.ts b/test/stores/widgets/StopGapWidgetDriver-test.ts index 855ba17acd..8d1e067d30 100644 --- a/test/stores/widgets/StopGapWidgetDriver-test.ts +++ b/test/stores/widgets/StopGapWidgetDriver-test.ts @@ -151,7 +151,7 @@ describe("StopGapWidgetDriver", () => { state: OpenIDRequestState.Allowed, token: await client.getOpenIdToken(), }; - expect(listener).toBeCalledWith(openIdUpdate); + expect(listener).toHaveBeenCalledWith(openIdUpdate); }); describe("sendToDevice", () => { @@ -276,7 +276,7 @@ describe("StopGapWidgetDriver", () => { prevBatch: undefined, }); - expect(client.relations).toBeCalledWith("!this-room-id", "$event", null, null, {}); + expect(client.relations).toHaveBeenCalledWith("!this-room-id", "$event", null, null, {}); }); it("reads related events from a selected room", async () => { @@ -292,7 +292,7 @@ describe("StopGapWidgetDriver", () => { prevBatch: undefined, }); - expect(client.relations).toBeCalledWith("!room-id", "$event", null, null, {}); + expect(client.relations).toHaveBeenCalledWith("!room-id", "$event", null, null, {}); }); it("reads related events with custom parameters", async () => { @@ -318,7 +318,7 @@ describe("StopGapWidgetDriver", () => { prevBatch: undefined, }); - expect(client.relations).toBeCalledWith("!room-id", "$event", "m.reference", "m.room.message", { + expect(client.relations).toHaveBeenCalledWith("!room-id", "$event", "m.reference", "m.room.message", { limit: 25, from: "from-token", to: "to-token", diff --git a/test/theme-test.ts b/test/theme-test.ts index d1dc5f68cc..44a860f7ac 100644 --- a/test/theme-test.ts +++ b/test/theme-test.ts @@ -63,7 +63,7 @@ describe("theme", () => { // Then expect(spyQuerySelectorAll).toHaveBeenCalledWith("[data-mx-theme]"); - expect(spyQuerySelectorAll).toBeCalledTimes(1); + expect(spyQuerySelectorAll).toHaveBeenCalledTimes(1); expect(lightTheme.disabled).toBe(false); expect(darkTheme.disabled).toBe(true); }); diff --git a/test/utils/connection-test.ts b/test/utils/connection-test.ts index 70b8a11941..c9fdb2e771 100644 --- a/test/utils/connection-test.ts +++ b/test/utils/connection-test.ts @@ -35,7 +35,7 @@ describe("createReconnectedListener", () => { ].forEach(([from, to]) => { it(`should invoke the callback on a transition from ${from} to ${to}`, () => { reconnectedListener(to, from); - expect(onReconnect).toBeCalled(); + expect(onReconnect).toHaveBeenCalled(); }); }); @@ -46,7 +46,7 @@ describe("createReconnectedListener", () => { ].forEach(([from, to]) => { it(`should not invoke the callback on a transition from ${from} to ${to}`, () => { reconnectedListener(to, from); - expect(onReconnect).not.toBeCalled(); + expect(onReconnect).not.toHaveBeenCalled(); }); }); }); diff --git a/test/utils/device/parseUserAgent-test.ts b/test/utils/device/parseUserAgent-test.ts index 2aabdc479d..65e31a68a0 100644 --- a/test/utils/device/parseUserAgent-test.ts +++ b/test/utils/device/parseUserAgent-test.ts @@ -130,8 +130,8 @@ describe("parseUserAgent()", () => { const testPlatform = (platform: string, userAgents: string[], results: ExtendedDeviceInformation[]): void => { const testCases: TestCase[] = userAgents.map((userAgent, index) => [userAgent, results[index]]); - describe(platform, () => { - it.each(testCases)("Parses user agent correctly - %s", (userAgent, expectedResult) => { + describe(`on platform ${platform}`, () => { + it.each(testCases)("should parse the user agent correctly - %s", (userAgent, expectedResult) => { expect(parseUserAgent(userAgent)).toEqual(expectedResult); }); }); diff --git a/test/utils/export-test.tsx b/test/utils/export-test.tsx index 9e93be5f93..d018b83cff 100644 --- a/test/utils/export-test.tsx +++ b/test/utils/export-test.tsx @@ -290,7 +290,7 @@ describe("export", function () { ], ]; it.each(invalidExportOptions)("%s", (_d, options) => { - expect(() => new PlainTextExporter(mockRoom, ExportType.Beginning, options, setProgressText)).toThrowError( + expect(() => new PlainTextExporter(mockRoom, ExportType.Beginning, options, setProgressText)).toThrow( "Invalid export options", ); }); diff --git a/test/utils/exportUtils/HTMLExport-test.ts b/test/utils/exportUtils/HTMLExport-test.ts index bbdfa9e647..04f4f19e3c 100644 --- a/test/utils/exportUtils/HTMLExport-test.ts +++ b/test/utils/exportUtils/HTMLExport-test.ts @@ -329,31 +329,28 @@ describe("HTMLExport", () => { // test link to the first page //@ts-ignore private access - exporter.wrapHTML("", 0, 3).then((res) => { - expect(res).not.toContain("Previous group of messages"); - expect(res).toContain( - '', - ); - }); + let result = await exporter.wrapHTML("", 0, 3); + expect(result).not.toContain("Previous group of messages"); + expect(result).toContain( + '', + ); // test link for a middle page //@ts-ignore private access - exporter.wrapHTML("", 1, 3).then((res) => { - expect(res).toContain( - '', - ); - expect(res).toContain( - '', - ); - }); + result = await exporter.wrapHTML("", 1, 3); + expect(result).toContain( + '', + ); + expect(result).toContain( + '', + ); // test link for last page //@ts-ignore private access - exporter.wrapHTML("", 2, 3).then((res) => { - expect(res).toContain( - '', - ); - expect(res).not.toContain("Next group of messages"); - }); + result = await exporter.wrapHTML("", 2, 3); + expect(result).toContain( + '', + ); + expect(result).not.toContain("Next group of messages"); }); }); diff --git a/test/utils/local-room-test.ts b/test/utils/local-room-test.ts index 89cb279da1..8a319cf411 100644 --- a/test/utils/local-room-test.ts +++ b/test/utils/local-room-test.ts @@ -120,16 +120,14 @@ describe("local-room", () => { mocked(isRoomReady).mockReturnValue(false); }); - it("should invoke the callbacks, set the room state to created and return the actual room id", (done) => { + it("should invoke the callbacks, set the room state to created and return the actual room id", async () => { const prom = localRoomModule.waitForRoomReadyAndApplyAfterCreateCallbacks(client, localRoom); jest.advanceTimersByTime(5000); - prom.then((roomId: string) => { - expect(localRoom.state).toBe(LocalRoomState.CREATED); - expect(localRoomCallbackRoomId).toBe(room1.roomId); - expect(roomId).toBe(room1.roomId); - expect(jest.getTimerCount()).toBe(0); - done(); - }); + const roomId = await prom; + expect(localRoom.state).toBe(LocalRoomState.CREATED); + expect(localRoomCallbackRoomId).toBe(room1.roomId); + expect(roomId).toBe(room1.roomId); + expect(jest.getTimerCount()).toBe(0); }); }); @@ -138,17 +136,15 @@ describe("local-room", () => { mocked(isRoomReady).mockReturnValue(false); }); - it("should invoke the callbacks, set the room state to created and return the actual room id", (done) => { + it("should invoke the callbacks, set the room state to created and return the actual room id", async () => { const prom = localRoomModule.waitForRoomReadyAndApplyAfterCreateCallbacks(client, localRoom); mocked(isRoomReady).mockReturnValue(true); jest.advanceTimersByTime(500); - prom.then((roomId: string) => { - expect(localRoom.state).toBe(LocalRoomState.CREATED); - expect(localRoomCallbackRoomId).toBe(room1.roomId); - expect(roomId).toBe(room1.roomId); - expect(jest.getTimerCount()).toBe(0); - done(); - }); + const roomId = await prom; + expect(localRoom.state).toBe(LocalRoomState.CREATED); + expect(localRoomCallbackRoomId).toBe(room1.roomId); + expect(roomId).toBe(room1.roomId); + expect(jest.getTimerCount()).toBe(0); }); }); }); diff --git a/test/utils/localRoom/isRoomReady-test.ts b/test/utils/localRoom/isRoomReady-test.ts index c458672d51..e317301e76 100644 --- a/test/utils/localRoom/isRoomReady-test.ts +++ b/test/utils/localRoom/isRoomReady-test.ts @@ -51,7 +51,7 @@ describe("isRoomReady", () => { mocked(client.getRoom).mockReturnValue(null); }); - it("it should return false", () => { + it("should return false", () => { expect(isRoomReady(client, localRoom)).toBe(false); }); @@ -63,7 +63,7 @@ describe("isRoomReady", () => { }); }); - it("it should return false", () => { + it("should return false", () => { expect(isRoomReady(client, localRoom)).toBe(false); }); @@ -75,7 +75,7 @@ describe("isRoomReady", () => { ]); }); - it("it should return false", () => { + it("should return false", () => { expect(isRoomReady(client, localRoom)).toBe(false); }); @@ -92,7 +92,7 @@ describe("isRoomReady", () => { ]); }); - it("it should return true", () => { + it("should return true", () => { expect(isRoomReady(client, localRoom)).toBe(true); }); @@ -101,7 +101,7 @@ describe("isRoomReady", () => { localRoom.encrypted = true; }); - it("it should return false", () => { + it("should return false", () => { expect(isRoomReady(client, localRoom)).toBe(false); }); @@ -118,7 +118,7 @@ describe("isRoomReady", () => { ]); }); - it("it should return true", () => { + it("should return true", () => { expect(isRoomReady(client, localRoom)).toBe(true); }); }); diff --git a/test/utils/membership-test.ts b/test/utils/membership-test.ts index 9f62ec3a93..abe020db7b 100644 --- a/test/utils/membership-test.ts +++ b/test/utils/membership-test.ts @@ -29,31 +29,32 @@ describe("waitForMember", () => { client = new EventEmitter(); }); - it("resolves with false if the timeout is reached", (done) => { - waitForMember(client, "", "", { timeout: 0 }).then((r) => { - expect(r).toBe(false); - done(); - }); + afterEach(() => { + jest.useRealTimers(); }); - it("resolves with false if the timeout is reached, even if other RoomState.newMember events fire", (done) => { + it("resolves with false if the timeout is reached", async () => { + const result = await waitForMember(client, "", "", { timeout: 0 }); + expect(result).toBe(false); + }); + + it("resolves with false if the timeout is reached, even if other RoomState.newMember events fire", async () => { + jest.useFakeTimers(); const roomId = "!roomId:domain"; const userId = "@clientId:domain"; - waitForMember(client, roomId, userId, { timeout }).then((r) => { - expect(r).toBe(false); - done(); - }); + const resultProm = waitForMember(client, roomId, userId, { timeout }); + jest.advanceTimersByTime(50); + expect(await resultProm).toBe(false); client.emit("RoomState.newMember", undefined, undefined, { roomId, userId: "@anotherClient:domain" }); + jest.useRealTimers(); }); - it("resolves with true if RoomState.newMember fires", (done) => { + it("resolves with true if RoomState.newMember fires", async () => { const roomId = "!roomId:domain"; const userId = "@clientId:domain"; - waitForMember(client, roomId, userId, { timeout }).then((r) => { - expect(r).toBe(true); - expect((client).listeners(RoomStateEvent.NewMember).length).toBe(0); - done(); - }); + expect((client).listeners(RoomStateEvent.NewMember).length).toBe(0); + const resultProm = waitForMember(client, roomId, userId, { timeout }); client.emit("RoomState.newMember", undefined, undefined, { roomId, userId }); + expect(await resultProm).toBe(true); }); }); diff --git a/test/utils/notifications-test.ts b/test/utils/notifications-test.ts index 077c0990f1..36c8e418c9 100644 --- a/test/utils/notifications-test.ts +++ b/test/utils/notifications-test.ts @@ -128,7 +128,7 @@ describe("notifications", () => { it("sends a request even if everything has been read", () => { clearRoomNotification(room, client); - expect(sendReadReceiptSpy).not.toBeCalled(); + expect(sendReadReceiptSpy).not.toHaveBeenCalled(); }); it("marks the room as read even if the receipt failed", async () => { @@ -163,7 +163,7 @@ describe("notifications", () => { it("does not send any requests if everything has been read", () => { clearAllNotifications(client); - expect(sendReadReceiptSpy).not.toBeCalled(); + expect(sendReadReceiptSpy).not.toHaveBeenCalled(); }); it("sends unthreaded receipt requests", () => { @@ -178,7 +178,7 @@ describe("notifications", () => { clearAllNotifications(client); - expect(sendReadReceiptSpy).toBeCalledWith(message, ReceiptType.Read, true); + expect(sendReadReceiptSpy).toHaveBeenCalledWith(message, ReceiptType.Read, true); }); it("sends private read receipts", () => { @@ -195,7 +195,7 @@ describe("notifications", () => { clearAllNotifications(client); - expect(sendReadReceiptSpy).toBeCalledWith(message, ReceiptType.ReadPrivate, true); + expect(sendReadReceiptSpy).toHaveBeenCalledWith(message, ReceiptType.ReadPrivate, true); }); }); }); diff --git a/test/voice-broadcast/models/VoiceBroadcastRecording-test.ts b/test/voice-broadcast/models/VoiceBroadcastRecording-test.ts index 312ee7f785..c5194b7df9 100644 --- a/test/voice-broadcast/models/VoiceBroadcastRecording-test.ts +++ b/test/voice-broadcast/models/VoiceBroadcastRecording-test.ts @@ -269,7 +269,7 @@ describe("VoiceBroadcastRecording", () => { it("should raise an error when creating a broadcast", () => { expect(() => { setUpVoiceBroadcastRecording(); - }).toThrowError("Cannot create broadcast for info event without Id."); + }).toThrow("Cannot create broadcast for info event without Id."); }); }); @@ -285,7 +285,7 @@ describe("VoiceBroadcastRecording", () => { it("should raise an error when creating a broadcast", () => { expect(() => { setUpVoiceBroadcastRecording(); - }).toThrowError(`Cannot create broadcast for unknown room (info event ${infoEvent.getId()})`); + }).toThrow(`Cannot create broadcast for unknown room (info event ${infoEvent.getId()})`); }); }); diff --git a/test/voice-broadcast/stores/VoiceBroadcastRecordingsStore-test.ts b/test/voice-broadcast/stores/VoiceBroadcastRecordingsStore-test.ts index ff7a50aef3..f8a9cc9448 100644 --- a/test/voice-broadcast/stores/VoiceBroadcastRecordingsStore-test.ts +++ b/test/voice-broadcast/stores/VoiceBroadcastRecordingsStore-test.ts @@ -74,7 +74,7 @@ describe("VoiceBroadcastRecordingsStore", () => { infoEvent.event.event_id = undefined; expect(() => { recordings.setCurrent(recording); - }).toThrowError("Got broadcast info event without Id"); + }).toThrow("Got broadcast info event without Id"); }); describe("when setting a current Voice Broadcast recording", () => { diff --git a/test/voice-broadcast/utils/setUpVoiceBroadcastPreRecording-test.ts b/test/voice-broadcast/utils/setUpVoiceBroadcastPreRecording-test.ts index 68b5c0ef94..f3f9c94485 100644 --- a/test/voice-broadcast/utils/setUpVoiceBroadcastPreRecording-test.ts +++ b/test/voice-broadcast/utils/setUpVoiceBroadcastPreRecording-test.ts @@ -67,11 +67,7 @@ describe("setUpVoiceBroadcastPreRecording", () => { beforeEach(() => { client = stubClient(); - - const clientUserId = client.getUserId(); - if (!clientUserId) fail("empty userId"); - userId = clientUserId; - + userId = client.getSafeUserId(); room = new Room(roomId, client, userId); infoEvent = mkVoiceBroadcastInfoStateEvent( roomId, diff --git a/yarn.lock b/yarn.lock index 2d727e7f3b..8ef3f680e9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2528,6 +2528,14 @@ "@typescript-eslint/types" "5.53.0" "@typescript-eslint/visitor-keys" "5.53.0" +"@typescript-eslint/scope-manager@5.54.0": + version "5.54.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.54.0.tgz#74b28ac9a3fc8166f04e806c957adb8c1fd00536" + integrity sha512-VTPYNZ7vaWtYna9M4oD42zENOBrb+ZYyCNdFs949GcN8Miwn37b8b7eMj+EZaq7VK9fx0Jd+JhmkhjFhvnovhg== + dependencies: + "@typescript-eslint/types" "5.54.0" + "@typescript-eslint/visitor-keys" "5.54.0" + "@typescript-eslint/type-utils@5.53.0": version "5.53.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.53.0.tgz#41665449935ba9b4e6a1ba6e2a3f4b2c31d6cf97" @@ -2543,6 +2551,11 @@ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.53.0.tgz#f79eca62b97e518ee124086a21a24f3be267026f" integrity sha512-5kcDL9ZUIP756K6+QOAfPkigJmCPHcLN7Zjdz76lQWWDdzfOhZDTj1irs6gPBKiXx5/6O3L0+AvupAut3z7D2A== +"@typescript-eslint/types@5.54.0": + version "5.54.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.54.0.tgz#7d519df01f50739254d89378e0dcac504cab2740" + integrity sha512-nExy+fDCBEgqblasfeE3aQ3NuafBUxZxgxXcYfzYRZFHdVvk5q60KhCSkG0noHgHRo/xQ/BOzURLZAafFpTkmQ== + "@typescript-eslint/typescript-estree@5.53.0": version "5.53.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.53.0.tgz#bc651dc28cf18ab248ecd18a4c886c744aebd690" @@ -2556,6 +2569,19 @@ semver "^7.3.7" tsutils "^3.21.0" +"@typescript-eslint/typescript-estree@5.54.0": + version "5.54.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.54.0.tgz#f6f3440cabee8a43a0b25fa498213ebb61fdfe99" + integrity sha512-X2rJG97Wj/VRo5YxJ8Qx26Zqf0RRKsVHd4sav8NElhbZzhpBI8jU54i6hfo9eheumj4oO4dcRN1B/zIVEqR/MQ== + dependencies: + "@typescript-eslint/types" "5.54.0" + "@typescript-eslint/visitor-keys" "5.54.0" + debug "^4.3.4" + globby "^11.1.0" + is-glob "^4.0.3" + semver "^7.3.7" + tsutils "^3.21.0" + "@typescript-eslint/utils@5.53.0": version "5.53.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.53.0.tgz#e55eaad9d6fffa120575ffaa530c7e802f13bce8" @@ -2570,6 +2596,20 @@ eslint-utils "^3.0.0" semver "^7.3.7" +"@typescript-eslint/utils@^5.10.0": + version "5.54.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.54.0.tgz#3db758aae078be7b54b8ea8ea4537ff6cd3fbc21" + integrity sha512-cuwm8D/Z/7AuyAeJ+T0r4WZmlnlxQ8wt7C7fLpFlKMR+dY6QO79Cq1WpJhvZbMA4ZeZGHiRWnht7ZJ8qkdAunw== + dependencies: + "@types/json-schema" "^7.0.9" + "@types/semver" "^7.3.12" + "@typescript-eslint/scope-manager" "5.54.0" + "@typescript-eslint/types" "5.54.0" + "@typescript-eslint/typescript-estree" "5.54.0" + eslint-scope "^5.1.1" + eslint-utils "^3.0.0" + semver "^7.3.7" + "@typescript-eslint/visitor-keys@5.53.0": version "5.53.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.53.0.tgz#8a5126623937cdd909c30d8fa72f79fa56cc1a9f" @@ -2578,6 +2618,14 @@ "@typescript-eslint/types" "5.53.0" eslint-visitor-keys "^3.3.0" +"@typescript-eslint/visitor-keys@5.54.0": + version "5.54.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.54.0.tgz#846878afbf0cd67c19cfa8d75947383d4490db8f" + integrity sha512-xu4wT7aRCakGINTLGeyGqDn+78BwFlggwBjnHa1ar/KaGagnmwLYmlrXIrgAaQ3AE1Vd6nLfKASm7LrFHNbKGA== + dependencies: + "@typescript-eslint/types" "5.54.0" + eslint-visitor-keys "^3.3.0" + "@wojtekmaj/enzyme-adapter-react-17@^0.8.0": version "0.8.0" resolved "https://registry.yarnpkg.com/@wojtekmaj/enzyme-adapter-react-17/-/enzyme-adapter-react-17-0.8.0.tgz#138f404f82f502d152242c049e87d9621dcda4bd" @@ -4264,6 +4312,13 @@ eslint-plugin-import@^2.25.4: resolve "^1.22.0" tsconfig-paths "^3.14.1" +eslint-plugin-jest@^27.2.1: + version "27.2.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-27.2.1.tgz#b85b4adf41c682ea29f1f01c8b11ccc39b5c672c" + integrity sha512-l067Uxx7ZT8cO9NJuf+eJHvt6bqJyz2Z29wykyEdz/OtmcELQl2MQGQLX8J94O1cSJWAwUSEvCjwjA7KEK3Hmg== + dependencies: + "@typescript-eslint/utils" "^5.10.0" + eslint-plugin-jsx-a11y@^6.5.1: version "6.6.1" resolved "https://registry.yarnpkg.com/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.6.1.tgz#93736fc91b83fdc38cc8d115deedfc3091aef1ff"