Skip to content

Commit

Permalink
add test for single eml file with attachment
Browse files Browse the repository at this point in the history
  • Loading branch information
jomapp committed Nov 18, 2024
1 parent 248a066 commit 05fbc61
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/node-mimimi/src/importer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ mod tests {
}

#[tokio::test]
async fn can_import_single_eml_file() {
async fn can_import_single_eml_file_without_attachment() {
let mut importer = init_file_importer(vec!["./test/sample.eml".to_string()]).await;

let import_res = importer.continue_import().await.map_err(|_| ());
Expand All @@ -601,4 +601,18 @@ mod tests {
import_res
);
}

#[tokio::test]
async fn can_import_single_eml_file_with_attachment() {
let mut importer = init_file_importer(vec!["./test/attachment_sample.eml".to_string()]).await;

let import_res = importer.continue_import().await.map_err(|_| ());
assert_eq!(
Ok(ImportStatus {
state: ImportState::Finished,
imported_mails: 1,
}),
import_res
);
}
}
22 changes: 22 additions & 0 deletions packages/node-mimimi/test/attachment_sample.eml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
From: Art Vandelay <art@vandelay.com> (Vandelay Industries)
To: "Colleagues": "James Smythe" <james@vandelay.com>; Friends:
jane@example.com, =?UTF-8?Q?John_Sm=C3=AEth?= <john@example.com>;
Date: Sat, 20 Nov 2021 14:22:01 -0800
Subject: Why not both importing AND exporting? =?utf-8?b?4pi6?=
Content-Type: multipart/mixed; boundary="festivus";

--festivus
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: base64

PGh0bWw+PHA+SSB3YXMgdGhpbmtpbmcgYWJvdXQgcXVpdHRpbmcgdGhlICZsZHF1bztle
HBvcnRpbmcmcmRxdW87IHRvIGZvY3VzIGp1c3Qgb24gdGhlICZsZHF1bztpbXBvcnRpbm
cmcmRxdW87LDwvcD48cD5idXQgdGhlbiBJIHRob3VnaHQsIHdoeSBub3QgZG8gYm90aD8
gJiN4MjYzQTs8L3A+PC9odG1sPg==
--festivus
Content-Type: image/gif; name="TestFile.gif";
Content-Transfer-Encoding: Base64
Content-Disposition: attachment
R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
--festivus--

0 comments on commit 05fbc61

Please sign in to comment.