@@ -197,34 +197,19 @@ mod tests {
197
197
}
198
198
199
199
#[ 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( ) ) ) ) ;
202
203
}
203
204
204
205
#[ 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" ) ) ) ;
221
208
}
222
209
223
210
#[ 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" , "" ) ) ) ;
228
213
}
229
214
230
215
// Tests against an `m.room.member` filter with `state_key = "@self:example.me"`
@@ -236,36 +221,37 @@ mod tests {
236
221
}
237
222
238
223
#[ 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
+ ) ) ) ;
242
229
}
243
230
244
231
#[ 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"
249
236
) ) ) ;
250
237
}
251
238
252
239
#[ test]
253
240
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" ) ) ) ;
258
243
}
259
244
260
245
#[ 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( ) ) ) ) ;
263
249
}
264
250
265
251
#[ test]
266
- fn self_member_event_filter_only_matches_specific_state_key ( ) {
252
+ fn test_self_member_event_filter_only_matches_specific_state_key ( ) {
267
253
assert ! ( !self_member_event_filter( )
268
- . matches_state_event_with_any_state_key ( & StateEventType :: RoomMember ) ) ;
254
+ . matches ( & FilterInput :: state ( & StateEventType :: RoomMember . to_string ( ) , "" ) ) ) ;
269
255
}
270
256
271
257
// Tests against an `m.room.member` filter with any `state_key`.
@@ -274,26 +260,29 @@ mod tests {
274
260
}
275
261
276
262
#[ 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
+ ) ) ) ;
280
268
}
281
269
282
270
#[ test]
283
- fn member_event_filter_does_not_match_room_name_event ( ) {
271
+ fn test_member_event_filter_does_not_match_room_name_event ( ) {
284
272
assert ! ( !member_event_filter( )
285
- . matches( & state_event ( TimelineEventType :: RoomName , "" . to_owned ( ) ) ) ) ;
273
+ . matches( & FilterInput :: state ( & TimelineEventType :: RoomName . to_string ( ) , "" ) ) ) ;
286
274
}
287
275
288
276
#[ 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( ) ) ) ) ;
291
280
}
292
281
293
282
#[ test]
294
- fn member_event_filter_matches_any_state_key ( ) {
283
+ fn test_member_event_filter_matches_any_state_key ( ) {
295
284
assert ! ( member_event_filter( )
296
- . matches_state_event_with_any_state_key ( & StateEventType :: RoomMember ) ) ;
285
+ . matches ( & FilterInput :: state ( & StateEventType :: RoomMember . to_string ( ) , "" ) ) ) ;
297
286
}
298
287
299
288
// Tests against an `m.room.topic` filter with `state_key = ""`
@@ -305,9 +294,9 @@ mod tests {
305
294
}
306
295
307
296
#[ 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 ( ) , "" ) ) ) ;
311
300
}
312
301
313
302
// Tests against an `m.room.message` filter with `msgtype = m.custom`
@@ -321,33 +310,27 @@ mod tests {
321
310
}
322
311
323
312
#[ 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 ( ) {
331
314
assert ! ( !room_message_text_event_filter( )
332
- . matches_message_like_event_type ( & MessageLikeEventType :: Reaction ) ) ;
315
+ . matches ( & FilterInput :: message_like ( & MessageLikeEventType :: Reaction . to_string ( ) ) ) ) ;
333
316
}
334
317
335
318
#[ 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 ( ) ) ) ) ;
339
322
}
340
323
341
324
#[ 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 ( ) {
343
326
assert ! ( !room_message_custom_event_filter( )
344
- . matches_message_like_event_type ( & MessageLikeEventType :: Reaction ) ) ;
327
+ . matches ( & FilterInput :: message_like ( & MessageLikeEventType :: Reaction . to_string ( ) ) ) ) ;
345
328
}
346
329
347
330
#[ test]
348
- fn room_message_event_type_matches_room_message_event_filter ( ) {
331
+ fn test_room_message_event_type_matches_room_message_event_filter ( ) {
349
332
assert ! ( room_message_filter( )
350
- . matches_message_like_event_type ( & MessageLikeEventType :: RoomMessage ) ) ;
333
+ . matches ( & FilterInput :: message_like ( & MessageLikeEventType :: RoomMessage . to_string ( ) ) ) ) ;
351
334
}
352
335
353
336
#[ test]
0 commit comments