From 301b86a2258eaf9634d5628c1ce4d4de9378f7d7 Mon Sep 17 00:00:00 2001 From: Dariusz Niemczyk Date: Fri, 1 Oct 2021 14:00:54 +0200 Subject: [PATCH] Fix tests --- .../views/rooms/SendMessageComposer-test.tsx | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/test/components/views/rooms/SendMessageComposer-test.tsx b/test/components/views/rooms/SendMessageComposer-test.tsx index 2d5e14beab8a..a8fd08d67892 100644 --- a/test/components/views/rooms/SendMessageComposer-test.tsx +++ b/test/components/views/rooms/SendMessageComposer-test.tsx @@ -24,6 +24,7 @@ import { sleep } from "matrix-js-sdk/src/utils"; import SendMessageComposer, { createMessageContent, isQuickReaction, + SendMessageComposer as SendMessageComposerClass } from "../../../../src/components/views/rooms/SendMessageComposer"; import MatrixClientContext from "../../../../src/contexts/MatrixClientContext"; import RoomContext, { TimelineRenderingType } from "../../../../src/contexts/RoomContext"; @@ -142,7 +143,7 @@ describe('', () => { describe("functions correctly mounted", () => { const mockClient = MatrixClientPeg.matrixClient = createTestClient(); - const mockRoom = mkStubRoom() as any; + const mockRoom = mkStubRoom('myfakeroom') as any; const mockEvent = mkEvent({ type: "m.room.message", room: 'myfakeroom', @@ -200,7 +201,7 @@ describe('', () => { wrapper.update(); }); - const key = wrapper.find(SendMessageComposer).instance().editorStateKey; + const key = wrapper.find(SendMessageComposerClass).instance().editorStateKey; expect(wrapper.text()).toBe("Test Text"); expect(localStorage.getItem(key)).toBeNull(); @@ -244,7 +245,7 @@ describe('', () => { wrapper.update(); }); - const key = wrapper.find(SendMessageComposer).instance().editorStateKey; + const key = wrapper.find(SendMessageComposerClass).instance().editorStateKey; expect(wrapper.text()).toBe("Hello World"); expect(localStorage.getItem(key)).toBeNull(); @@ -288,6 +289,32 @@ describe('', () => { replyEventId: mockEvent.getId(), }); }); + + it('correctly sets the editorStateKey for threads', () => { + const mockThread ={ + getThread: () => { + return { + id: 'myFakeThreadId', + }; + }, + } as any; + const wrapper = mount( + + + + + ); + + const instance = wrapper.find(SendMessageComposerClass).instance(); + const key = instance.editorStateKey; + + expect(key).toEqual('mx_cider_state_myfakeroom_myFakeThreadId'); + }); }); describe("isQuickReaction", () => {