@@ -13,10 +13,14 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
16+ import { MsgType } from "matrix-js-sdk/src/matrix" ;
1617
1718import { mkEvent } from "../../../../../test-utils" ;
1819import { 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
2125describe ( "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