Skip to content

Commit 57137cd

Browse files
committed
task(tests): introduce prebuilt mocks and mocking helpers
1 parent 5d83808 commit 57137cd

File tree

6 files changed

+673
-570
lines changed

6 files changed

+673
-570
lines changed

crates/matrix-sdk-common/src/deserialized_responses.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ impl SyncTimelineEvent {
343343
/// Get the event id of this `SyncTimelineEvent` if the event has any valid
344344
/// id.
345345
pub fn event_id(&self) -> Option<OwnedEventId> {
346-
self.kind.raw().get_field::<OwnedEventId>("event_id").ok().flatten()
346+
self.kind.event_id()
347347
}
348348

349349
/// Returns a reference to the (potentially decrypted) Matrix event inside
@@ -529,6 +529,12 @@ impl TimelineEventKind {
529529
}
530530
}
531531

532+
/// Get the event id of this `TimelineEventKind` if the event has any valid
533+
/// id.
534+
pub fn event_id(&self) -> Option<OwnedEventId> {
535+
self.raw().get_field::<OwnedEventId>("event_id").ok().flatten()
536+
}
537+
532538
/// If the event was a decrypted event that was successfully decrypted, get
533539
/// its encryption info. Otherwise, `None`.
534540
pub fn encryption_info(&self) -> Option<&EncryptionInfo> {

crates/matrix-sdk/src/test_utils.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ use url::Url;
1414

1515
pub mod events;
1616

17+
#[cfg(not(target_arch = "wasm32"))]
18+
pub mod mocks;
19+
1720
use crate::{
1821
config::RequestConfig,
1922
matrix_auth::{MatrixSession, MatrixSessionTokens},

0 commit comments

Comments
 (0)