Add test in MessageComposer

t3chguy/dedup-icons-17oct
Florian Duros 2022-10-10 17:36:18 +02:00
parent ec1140e274
commit 6c7158197c
No known key found for this signature in database
GPG Key ID: 9700AA5870258A0B
1 changed files with 17 additions and 0 deletions

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(