Skip to content

Commit

Permalink
task(tests): introduce prebuilt mocks and mocking helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
bnjbvr committed Nov 7, 2024
1 parent 5d83808 commit 379f5e7
Show file tree
Hide file tree
Showing 6 changed files with 673 additions and 570 deletions.
8 changes: 7 additions & 1 deletion crates/matrix-sdk-common/src/deserialized_responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ impl SyncTimelineEvent {
/// Get the event id of this `SyncTimelineEvent` if the event has any valid
/// id.
pub fn event_id(&self) -> Option<OwnedEventId> {
self.kind.raw().get_field::<OwnedEventId>("event_id").ok().flatten()
self.kind.event_id()
}

/// Returns a reference to the (potentially decrypted) Matrix event inside
Expand Down Expand Up @@ -529,6 +529,12 @@ impl TimelineEventKind {
}
}

/// Get the event id of this `TimelineEventKind` if the event has any valid
/// id.
pub fn event_id(&self) -> Option<OwnedEventId> {
self.raw().get_field::<OwnedEventId>("event_id").ok().flatten()
}

/// If the event was a decrypted event that was successfully decrypted, get
/// its encryption info. Otherwise, `None`.
pub fn encryption_info(&self) -> Option<&EncryptionInfo> {
Expand Down
3 changes: 3 additions & 0 deletions crates/matrix-sdk/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ use url::Url;

pub mod events;

#[cfg(not(target_arch = "wasm32"))]
pub mod mocks;

use crate::{
config::RequestConfig,
matrix_auth::{MatrixSession, MatrixSessionTokens},
Expand Down
Loading

0 comments on commit 379f5e7

Please sign in to comment.