@@ -197,34 +197,19 @@ mod tests {
197197 }
198198
199199 #[ test]
200- fn reaction_event_filter_matches_reaction ( ) {
201- assert ! ( reaction_event_filter( ) . matches( & message_event( TimelineEventType :: Reaction ) ) ) ;
200+ fn test_reaction_event_filter_matches_reaction ( ) {
201+ assert ! ( reaction_event_filter( )
202+ . matches( & message_event( & MessageLikeEventType :: Reaction . to_string( ) ) ) ) ;
202203 }
203204
204205 #[ test]
205- fn reaction_event_filter_does_not_match_room_message ( ) {
206- assert ! ( !reaction_event_filter( ) . matches( & message_event_with_msgtype(
207- TimelineEventType :: RoomMessage ,
208- "m.text" . to_owned( )
209- ) ) ) ;
210- }
211-
212- #[ test]
213- fn reaction_event_filter_does_not_match_state_event ( ) {
214- assert ! ( !reaction_event_filter( ) . matches( & state_event(
215- // Use the `m.reaction` event type to make sure the event would pass
216- // the filter without state event checks, even though in practice
217- // that event type won't be used for a state event.
218- TimelineEventType :: Reaction ,
219- "" . to_owned( )
220- ) ) ) ;
206+ fn test_reaction_event_filter_does_not_match_room_message ( ) {
207+ assert ! ( !reaction_event_filter( ) . matches( & FilterInput :: message_with_msgtype( "m.text" ) ) ) ;
221208 }
222209
223210 #[ test]
224- fn reaction_event_filter_does_not_match_state_event_any_key ( ) {
225- assert ! (
226- !reaction_event_filter( ) . matches_state_event_with_any_state_key( & "m.reaction" . into( ) )
227- ) ;
211+ fn test_reaction_event_filter_does_not_match_state_event_any_key ( ) {
212+ assert ! ( !reaction_event_filter( ) . matches( & FilterInput :: state( "m.reaction" , "" ) ) ) ;
228213 }
229214
230215 // Tests against an `m.room.member` filter with `state_key = "@self:example.me"`
@@ -236,36 +221,37 @@ mod tests {
236221 }
237222
238223 #[ test]
239- fn self_member_event_filter_matches_self_member_event ( ) {
240- assert ! ( self_member_event_filter( )
241- . matches( & state_event( TimelineEventType :: RoomMember , "@self:example.me" . to_owned( ) ) ) ) ;
224+ fn test_self_member_event_filter_matches_self_member_event ( ) {
225+ assert ! ( self_member_event_filter( ) . matches( & FilterInput :: state(
226+ & TimelineEventType :: RoomMember . to_string( ) ,
227+ "@self:example.me"
228+ ) ) ) ;
242229 }
243230
244231 #[ test]
245- fn self_member_event_filter_does_not_match_somebody_elses_member_event ( ) {
246- assert ! ( !self_member_event_filter( ) . matches( & state_event (
247- TimelineEventType :: RoomMember ,
248- "@somebody_else.example.me" . to_owned ( )
232+ fn test_self_member_event_filter_does_not_match_somebody_elses_member_event ( ) {
233+ assert ! ( !self_member_event_filter( ) . matches( & FilterInput :: state (
234+ & TimelineEventType :: RoomMember . to_string ( ) ,
235+ "@somebody_else.example.me"
249236 ) ) ) ;
250237 }
251238
252239 #[ test]
253240 fn self_member_event_filter_does_not_match_unrelated_state_event_with_same_state_key ( ) {
254- assert ! ( !self_member_event_filter( ) . matches( & state_event(
255- TimelineEventType :: from( "io.element.test_state_event" ) ,
256- "@self.example.me" . to_owned( )
257- ) ) ) ;
241+ assert ! ( !self_member_event_filter( )
242+ . matches( & FilterInput :: state( "io.element.test_state_event" , "@self.example.me" ) ) ) ;
258243 }
259244
260245 #[ test]
261- fn self_member_event_filter_does_not_match_reaction_event ( ) {
262- assert ! ( !self_member_event_filter( ) . matches( & message_event( TimelineEventType :: Reaction ) ) ) ;
246+ fn test_self_member_event_filter_does_not_match_reaction_event ( ) {
247+ assert ! ( !self_member_event_filter( )
248+ . matches( & message_event( & MessageLikeEventType :: Reaction . to_string( ) ) ) ) ;
263249 }
264250
265251 #[ test]
266- fn self_member_event_filter_only_matches_specific_state_key ( ) {
252+ fn test_self_member_event_filter_only_matches_specific_state_key ( ) {
267253 assert ! ( !self_member_event_filter( )
268- . matches_state_event_with_any_state_key ( & StateEventType :: RoomMember ) ) ;
254+ . matches ( & FilterInput :: state ( & StateEventType :: RoomMember . to_string ( ) , "" ) ) ) ;
269255 }
270256
271257 // Tests against an `m.room.member` filter with any `state_key`.
@@ -274,26 +260,29 @@ mod tests {
274260 }
275261
276262 #[ test]
277- fn member_event_filter_matches_some_member_event ( ) {
278- assert ! ( member_event_filter( )
279- . matches( & state_event( TimelineEventType :: RoomMember , "@foo.bar.baz" . to_owned( ) ) ) ) ;
263+ fn test_member_event_filter_matches_some_member_event ( ) {
264+ assert ! ( member_event_filter( ) . matches( & FilterInput :: state(
265+ & TimelineEventType :: RoomMember . to_string( ) ,
266+ "@foo.bar.baz"
267+ ) ) ) ;
280268 }
281269
282270 #[ test]
283- fn member_event_filter_does_not_match_room_name_event ( ) {
271+ fn test_member_event_filter_does_not_match_room_name_event ( ) {
284272 assert ! ( !member_event_filter( )
285- . matches( & state_event ( TimelineEventType :: RoomName , "" . to_owned ( ) ) ) ) ;
273+ . matches( & FilterInput :: state ( & TimelineEventType :: RoomName . to_string ( ) , "" ) ) ) ;
286274 }
287275
288276 #[ test]
289- fn member_event_filter_does_not_match_reaction_event ( ) {
290- assert ! ( !member_event_filter( ) . matches( & message_event( TimelineEventType :: Reaction ) ) ) ;
277+ fn test_member_event_filter_does_not_match_reaction_event ( ) {
278+ assert ! ( !member_event_filter( )
279+ . matches( & message_event( & MessageLikeEventType :: Reaction . to_string( ) ) ) ) ;
291280 }
292281
293282 #[ test]
294- fn member_event_filter_matches_any_state_key ( ) {
283+ fn test_member_event_filter_matches_any_state_key ( ) {
295284 assert ! ( member_event_filter( )
296- . matches_state_event_with_any_state_key ( & StateEventType :: RoomMember ) ) ;
285+ . matches ( & FilterInput :: state ( & StateEventType :: RoomMember . to_string ( ) , "" ) ) ) ;
297286 }
298287
299288 // Tests against an `m.room.topic` filter with `state_key = ""`
@@ -305,9 +294,9 @@ mod tests {
305294 }
306295
307296 #[ test]
308- fn topic_event_filter_does_not_match_any_state_key ( ) {
309- assert ! ( ! topic_event_filter( )
310- . matches_state_event_with_any_state_key ( & StateEventType :: RoomTopic ) ) ;
297+ fn test_topic_event_filter_does_match ( ) {
298+ assert ! ( topic_event_filter( )
299+ . matches ( & FilterInput :: state ( & StateEventType :: RoomTopic . to_string ( ) , "" ) ) ) ;
311300 }
312301
313302 // Tests against an `m.room.message` filter with `msgtype = m.custom`
@@ -321,33 +310,27 @@ mod tests {
321310 }
322311
323312 #[ test]
324- fn room_message_event_type_matches_room_message_text_event_filter ( ) {
325- assert ! ( room_message_text_event_filter( )
326- . matches_message_like_event_type( & MessageLikeEventType :: RoomMessage ) ) ;
327- }
328-
329- #[ test]
330- fn reaction_event_type_does_not_match_room_message_text_event_filter ( ) {
313+ fn test_reaction_event_type_does_not_match_room_message_text_event_filter ( ) {
331314 assert ! ( !room_message_text_event_filter( )
332- . matches_message_like_event_type ( & MessageLikeEventType :: Reaction ) ) ;
315+ . matches ( & FilterInput :: message_like ( & MessageLikeEventType :: Reaction . to_string ( ) ) ) ) ;
333316 }
334317
335318 #[ test]
336- fn room_message_event_type_matches_room_message_custom_event_filter ( ) {
337- assert ! ( room_message_custom_event_filter( )
338- . matches_message_like_event_type ( & MessageLikeEventType :: RoomMessage ) ) ;
319+ fn test_room_message_event_without_msgtype_does_not_match_custom_msgtype_filter ( ) {
320+ assert ! ( ! room_message_custom_event_filter( )
321+ . matches ( & FilterInput :: message_like ( & MessageLikeEventType :: RoomMessage . to_string ( ) ) ) ) ;
339322 }
340323
341324 #[ test]
342- fn reaction_event_type_does_not_match_room_message_custom_event_filter ( ) {
325+ fn test_reaction_event_type_does_not_match_room_message_custom_event_filter ( ) {
343326 assert ! ( !room_message_custom_event_filter( )
344- . matches_message_like_event_type ( & MessageLikeEventType :: Reaction ) ) ;
327+ . matches ( & FilterInput :: message_like ( & MessageLikeEventType :: Reaction . to_string ( ) ) ) ) ;
345328 }
346329
347330 #[ test]
348- fn room_message_event_type_matches_room_message_event_filter ( ) {
331+ fn test_room_message_event_type_matches_room_message_event_filter ( ) {
349332 assert ! ( room_message_filter( )
350- . matches_message_like_event_type ( & MessageLikeEventType :: RoomMessage ) ) ;
333+ . matches ( & FilterInput :: message_like ( & MessageLikeEventType :: RoomMessage . to_string ( ) ) ) ) ;
351334 }
352335
353336 #[ test]
0 commit comments