1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-12-23 21:02:09 +03:00

Add test in MessageComposer

This commit is contained in:
Florian Duros
2022-10-10 17:36:18 +02:00
parent ec1140e274
commit 6c7158197c

View File

@@ -39,6 +39,15 @@ import { SendMessageComposer } from "../../../../src/components/views/rooms/Send
import { E2EStatus } from "../../../../src/utils/ShieldUtils";
import { addTextToComposer } from "../../../test-utils/composer";
import UIStore, { UI_EVENTS } from "../../../../src/stores/UIStore";
import { WysiwygComposer } from "../../../../src/components/views/rooms/wysiwyg_composer/WysiwygComposer";
// The wysiwyg fetch wasm bytes and a specific workaround is needed to make it works in a node (jest) environnement
// See https://github.com/matrix-org/matrix-wysiwyg/blob/main/platforms/web/test.setup.ts
jest.mock("@matrix-org/matrix-wysiwyg", () => ({
useWysiwyg: ({ onChange }) => {
return { ref: { current: null }, isWysiwygReady: true, wysiwyg: { clear: () => void 0 } };
},
}));
describe("MessageComposer", () => {
stubClient();
@@ -346,6 +355,14 @@ describe("MessageComposer", () => {
expect(wrapper.find(MessageComposerButtons).props().showStickersButton).toBe(false);
});
});
it('should render WysiwygComposer', () => {
const room = mkStubRoom("!roomId:server", "Room 1", cli);
SettingsStore.setValue("feature_wysiwyg_composer", null, SettingLevel.DEVICE, true);
const wrapper = wrapAndRender({ room });
expect(wrapper.find(WysiwygComposer)).toBeTruthy();
});
});
function wrapAndRender(