make loading eml reusable

This commit is contained in:
B. Petersen
2020-11-14 23:46:30 +01:00
parent 7fa794cd72
commit 889f4673ad

View File

@@ -2718,25 +2718,27 @@ mod tests {
assert_eq!(last_msg.from_id, DC_CONTACT_ID_INFO);
}
#[async_std::test]
async fn test_html_only_mail() {
let t = TestContext::new_alice().await;
t.ctx
async fn load_imf_email(context: &Context, imf_raw: &[u8]) -> Message {
context
.set_config(Config::ShowEmails, Some("2"))
.await
.unwrap();
dc_receive_imf(
dc_receive_imf(&context, imf_raw, "INBOX", 0, false)
.await
.unwrap();
let chats = Chatlist::try_load(&context, 0, None, None).await.unwrap();
let msg_id = chats.get_msg_id(0).unwrap();
Message::load_from_db(&context, msg_id).await.unwrap()
}
#[async_std::test]
async fn test_html_only_mail() {
let t = TestContext::new_alice().await;
let msg = load_imf_email(
&t.ctx,
include_bytes!("../test-data/message/wrong-html.eml"),
"INBOX",
0,
false,
)
.await
.unwrap();
let chats = Chatlist::try_load(&t.ctx, 0, None, None).await.unwrap();
let msg_id = chats.get_msg_id(0).unwrap();
let msg = Message::load_from_db(&t.ctx, msg_id).await.unwrap();
.await;
assert_eq!(msg.text.unwrap(), " Guten Abend, \n\n Lots of text \n\n text with Umlaut ä... \n\n MfG [...]");
}
}