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

Commit ffe55c4

Browse files
author
Alun Turner
committed
add createMessageContent tests
1 parent 4f36eb0 commit ffe55c4

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

test/components/views/rooms/wysiwyg_composer/utils/createMessageContent-test.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16+
import { MsgType } from "matrix-js-sdk/src/matrix";
1617

1718
import { mkEvent } from "../../../../../test-utils";
1819
import { RoomPermalinkCreator } from "../../../../../../src/utils/permalinks/Permalinks";
19-
import { createMessageContent } from "../../../../../../src/components/views/rooms/wysiwyg_composer/utils/createMessageContent";
20+
import {
21+
createMessageContent,
22+
EMOTE_PREFIX,
23+
} from "../../../../../../src/components/views/rooms/wysiwyg_composer/utils/createMessageContent";
2024

2125
describe("createMessageContent", () => {
2226
const permalinkCreator = {
@@ -130,4 +134,24 @@ describe("createMessageContent", () => {
130134
},
131135
});
132136
});
137+
138+
it("Should strip the /me prefix from a message", async () => {
139+
const textBody = "some body text";
140+
const content = await createMessageContent(EMOTE_PREFIX + textBody, true, { permalinkCreator });
141+
142+
expect(content).toMatchObject({ body: textBody, formatted_body: textBody });
143+
});
144+
145+
it("Should strip single / from message prefixed with //", async () => {
146+
const content = await createMessageContent("//twoSlashes", true, { permalinkCreator });
147+
148+
expect(content).toMatchObject({ body: "/twoSlashes", formatted_body: "/twoSlashes" });
149+
});
150+
151+
it("Should set the content type to MsgType.Emote when /me prefix is used", async () => {
152+
const textBody = "some body text";
153+
const content = await createMessageContent(EMOTE_PREFIX + textBody, true, { permalinkCreator });
154+
155+
expect(content).toMatchObject({ msgtype: MsgType.Emote });
156+
});
133157
});

0 commit comments

Comments
 (0)