story-kit: merge 320_story_whatsapp_business_api_integration_for_bot_commands
This commit is contained in:
@@ -59,26 +59,20 @@ mod tests {
|
||||
use super::*;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Verify that the WhatsApp stub satisfies the ChatTransport trait and
|
||||
/// can be used as `Arc<dyn ChatTransport>`.
|
||||
#[tokio::test]
|
||||
async fn whatsapp_transport_satisfies_trait() {
|
||||
let transport: Arc<dyn ChatTransport> =
|
||||
Arc::new(crate::whatsapp::WhatsAppTransport::new());
|
||||
/// Verify that WhatsAppTransport satisfies the ChatTransport trait and
|
||||
/// can be used as `Arc<dyn ChatTransport>` (compile-time check).
|
||||
/// Functional tests are in `whatsapp::tests` using mockito.
|
||||
#[test]
|
||||
fn whatsapp_transport_satisfies_trait() {
|
||||
fn assert_transport<T: ChatTransport>() {}
|
||||
assert_transport::<crate::whatsapp::WhatsAppTransport>();
|
||||
|
||||
let msg_id = transport
|
||||
.send_message("room-1", "hello", "<p>hello</p>")
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(!msg_id.is_empty());
|
||||
|
||||
transport
|
||||
.edit_message("room-1", &msg_id, "edited", "<p>edited</p>")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
transport.send_typing("room-1", true).await.unwrap();
|
||||
transport.send_typing("room-1", false).await.unwrap();
|
||||
// Verify it can be wrapped in Arc<dyn ChatTransport>.
|
||||
let _: Arc<dyn ChatTransport> =
|
||||
Arc::new(crate::whatsapp::WhatsAppTransport::new(
|
||||
"test-phone".to_string(),
|
||||
"test-token".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
/// MatrixTransport cannot be tested without a live homeserver, but we
|
||||
|
||||
Reference in New Issue
Block a user