Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 489cb63

Browse files
author
Dariusz Niemczyk
committed
Fix tests
1 parent d397cff commit 489cb63

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

test/components/views/rooms/SendMessageComposer-test.tsx

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { sleep } from "matrix-js-sdk/src/utils";
2424
import SendMessageComposer, {
2525
createMessageContent,
2626
isQuickReaction,
27+
SendMessageComposer as SendMessageComposerClass
2728
} from "../../../../src/components/views/rooms/SendMessageComposer";
2829
import MatrixClientContext from "../../../../src/contexts/MatrixClientContext";
2930
import 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

Comments
 (0)