@@ -26,6 +26,7 @@ import { IUpload, VoiceMessageRecording } from "../../../../src/audio/VoiceMessa
26
26
import { RoomPermalinkCreator } from "../../../../src/utils/permalinks/Permalinks" ;
27
27
import { VoiceRecordingStore } from "../../../../src/stores/VoiceRecordingStore" ;
28
28
import { PlaybackClock } from "../../../../src/audio/PlaybackClock" ;
29
+ import { mkEvent } from "../../../test-utils" ;
29
30
30
31
jest . mock ( "../../../../src/utils/local-room" , ( ) => ( {
31
32
doMaybeLocalRoomAction : jest . fn ( ) ,
@@ -50,6 +51,7 @@ describe("<VoiceRecordComposerTile/>", () => {
50
51
51
52
beforeEach ( ( ) => {
52
53
mockClient = {
54
+ getUserId : jest . fn ( ) . mockReturnValue ( "@alice:example.com" ) ,
53
55
sendMessage : jest . fn ( ) ,
54
56
} as unknown as MatrixClient ;
55
57
MatrixClientPeg . get = ( ) => mockClient ;
@@ -127,6 +129,61 @@ describe("<VoiceRecordComposerTile/>", () => {
127
129
"org.matrix.msc1767.text" : "Voice message" ,
128
130
"org.matrix.msc3245.voice" : { } ,
129
131
"url" : "mxc://example.com/voice" ,
132
+ "org.matrix.msc3952.mentions" : { } ,
133
+ } ) ;
134
+ } ) ;
135
+
136
+ it ( "reply with voice recording" , async ( ) => {
137
+ const room = {
138
+ roomId,
139
+ } as unknown as Room ;
140
+
141
+ const replyToEvent = mkEvent ( {
142
+ type : "m.room.message" ,
143
+ user : "@bob:test" ,
144
+ room : roomId ,
145
+ content : { } ,
146
+ event : true ,
147
+ } ) ;
148
+
149
+ const props = {
150
+ room,
151
+ ref : voiceRecordComposerTile ,
152
+ permalinkCreator : new RoomPermalinkCreator ( room ) ,
153
+ replyToEvent,
154
+ } ;
155
+ render ( < VoiceRecordComposerTile { ...props } /> ) ;
156
+
157
+ await voiceRecordComposerTile . current ! . send ( ) ;
158
+ expect ( mockClient . sendMessage ) . toHaveBeenCalledWith ( roomId , {
159
+ "body" : "Voice message" ,
160
+ "file" : undefined ,
161
+ "info" : {
162
+ duration : 1337000 ,
163
+ mimetype : "audio/ogg" ,
164
+ size : undefined ,
165
+ } ,
166
+ "msgtype" : MsgType . Audio ,
167
+ "org.matrix.msc1767.audio" : {
168
+ duration : 1337000 ,
169
+ waveform : [ 1434 , 2560 , 3686 ] ,
170
+ } ,
171
+ "org.matrix.msc1767.file" : {
172
+ file : undefined ,
173
+ mimetype : "audio/ogg" ,
174
+ name : "Voice message.ogg" ,
175
+ size : undefined ,
176
+ url : "mxc://example.com/voice" ,
177
+ } ,
178
+ "org.matrix.msc1767.text" : "Voice message" ,
179
+ "org.matrix.msc3245.voice" : { } ,
180
+ "url" : "mxc://example.com/voice" ,
181
+ "m.relates_to" : {
182
+ "m.in_reply_to" : {
183
+ event_id : replyToEvent . getId ( ) ,
184
+ } ,
185
+ } ,
186
+ "org.matrix.msc3952.mentions" : { user_ids : [ "@bob:test" ] } ,
130
187
} ) ;
131
188
} ) ;
132
189
} ) ;
0 commit comments