@@ -24,6 +24,7 @@ import { sleep } from "matrix-js-sdk/src/utils";
2424import SendMessageComposer , {
2525 createMessageContent ,
2626 isQuickReaction ,
27+ SendMessageComposer as SendMessageComposerClass
2728} from "../../../../src/components/views/rooms/SendMessageComposer" ;
2829import MatrixClientContext from "../../../../src/contexts/MatrixClientContext" ;
2930import RoomContext , { TimelineRenderingType } from "../../../../src/contexts/RoomContext" ;
@@ -142,7 +143,7 @@ describe('<SendMessageComposer/>', () => {
142143
143144 describe ( "functions correctly mounted" , ( ) => {
144145 const mockClient = MatrixClientPeg . matrixClient = createTestClient ( ) ;
145- const mockRoom = mkStubRoom ( ) as any ;
146+ const mockRoom = mkStubRoom ( 'myfakeroom' ) as any ;
146147 const mockEvent = mkEvent ( {
147148 type : "m.room.message" ,
148149 room : 'myfakeroom' ,
@@ -200,7 +201,7 @@ describe('<SendMessageComposer/>', () => {
200201 wrapper . update ( ) ;
201202 } ) ;
202203
203- const key = wrapper . find ( SendMessageComposer ) . instance ( ) . editorStateKey ;
204+ const key = wrapper . find ( SendMessageComposerClass ) . instance ( ) . editorStateKey ;
204205
205206 expect ( wrapper . text ( ) ) . toBe ( "Test Text" ) ;
206207 expect ( localStorage . getItem ( key ) ) . toBeNull ( ) ;
@@ -244,7 +245,7 @@ describe('<SendMessageComposer/>', () => {
244245 wrapper . update ( ) ;
245246 } ) ;
246247
247- const key = wrapper . find ( SendMessageComposer ) . instance ( ) . editorStateKey ;
248+ const key = wrapper . find ( SendMessageComposerClass ) . instance ( ) . editorStateKey ;
248249
249250 expect ( wrapper . text ( ) ) . toBe ( "Hello World" ) ;
250251 expect ( localStorage . getItem ( key ) ) . toBeNull ( ) ;
@@ -288,6 +289,32 @@ describe('<SendMessageComposer/>', () => {
288289 replyEventId : mockEvent . getId ( ) ,
289290 } ) ;
290291 } ) ;
292+
293+ it ( 'correctly sets the editorStateKey for threads' , ( ) => {
294+ const mockThread = {
295+ getThread : ( ) => {
296+ return {
297+ id : 'myFakeThreadId' ,
298+ } ;
299+ } ,
300+ } as any ;
301+ const wrapper = mount ( < MatrixClientContext . Provider value = { mockClient } >
302+ < RoomContext . Provider value = { roomContext } >
303+
304+ < SendMessageComposer
305+ room = { mockRoom as any }
306+ placeholder = ""
307+ permalinkCreator = { new SpecPermalinkConstructor ( ) as any }
308+ replyToEvent = { mockThread }
309+ />
310+ </ RoomContext . Provider >
311+ </ MatrixClientContext . Provider > ) ;
312+
313+ const instance = wrapper . find ( SendMessageComposerClass ) . instance ( ) ;
314+ const key = instance . editorStateKey ;
315+
316+ expect ( key ) . toEqual ( 'mx_cider_state_myfakeroom_myFakeThreadId' ) ;
317+ } ) ;
291318 } ) ;
292319
293320 describe ( "isQuickReaction" , ( ) => {
0 commit comments