This commit is contained in:
Florian Duros 2022-10-13 16:46:47 +02:00
parent a96aea29a9
commit ac8397aa0f
No known key found for this signature in database
GPG key ID: 9700AA5870258A0B
6 changed files with 20 additions and 18 deletions

View file

@ -44,8 +44,9 @@ import { WysiwygComposer } from "../../../../src/components/views/rooms/wysiwyg_
// 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 } };
useWysiwyg: () => {
return { ref: { current: null }, isWysiwygReady: true, wysiwyg: { clear: () => void 0 },
formattingStates: { bold: 'enabled', italic: 'enabled', underline: 'enabled', strikeThrough: 'enabled' } };
},
}));

View file

@ -16,7 +16,6 @@ limitations under the License.
import React from "react";
import { act, render, screen } from "@testing-library/react";
import "@testing-library/jest-dom";
import { IRoomState } from "../../../../../src/components/structures/RoomView";
import RoomContext, { TimelineRenderingType } from "../../../../../src/contexts/RoomContext";
@ -25,14 +24,12 @@ import { createTestClient, mkEvent, mkStubRoom } from "../../../../test-utils";
import MatrixClientContext from "../../../../../src/contexts/MatrixClientContext";
import { WysiwygComposer } from "../../../../../src/components/views/rooms/wysiwyg_composer/WysiwygComposer";
let callOnChange: (content: string) => void;
// 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 }) => {
callOnChange = onChange;
return { ref: { current: null }, isWysiwygReady: true, wysiwyg: { clear: () => void 0 } };
useWysiwyg: () => {
return { ref: { current: null }, content: '<b>html</b>', isWysiwygReady: true, wysiwyg: { clear: () => void 0 },
formattingStates: { bold: 'enabled', italic: 'enabled', underline: 'enabled', strikeThrough: 'enabled' } };
},
}));
@ -122,7 +119,7 @@ describe('WysiwygComposer', () => {
expect(content).toBe((html));
done();
});
act(() => callOnChange(html));
// act(() => callOnChange(html));
});
it('Should send message, call clear and focus the textbox', async () => {
@ -130,7 +127,6 @@ describe('WysiwygComposer', () => {
const html = '<b>html</b>';
await new Promise((resolve) => {
customRender(() => resolve(null));
act(() => callOnChange(html));
});
act(() => sendMessage());