From 3d3abd91f2abe4c26c89f5e3b758f0a0c40ea1fb Mon Sep 17 00:00:00 2001 From: PJ Date: Sat, 20 Jun 2026 18:40:57 -0400 Subject: [PATCH] test(epub): cover unzip_epub reading a file from disk --- src-tauri/src/epub.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src-tauri/src/epub.rs b/src-tauri/src/epub.rs index 3c158e7..3ea01ec 100644 --- a/src-tauri/src/epub.rs +++ b/src-tauri/src/epub.rs @@ -138,4 +138,27 @@ mod tests { // Fonts are embedded by build() and must come back as base64 binary. assert_eq!(find("OEBPS/fonts/Literata-VF.ttf").encoding, "base64"); } + + #[test] + fn unzip_epub_reads_a_file_from_disk() { + let zipped = build(&[ + text("mimetype", "application/epub+zip"), + text("OEBPS/chapter-1.xhtml", "

hi

"), + ]) + .expect("build"); + + let mut path = std::env::temp_dir(); + path.push("margin-unzip-test.epub"); + std::fs::write(&path, &zipped).expect("write"); + + let out = unzip_epub(path.to_string_lossy().to_string()).expect("unzip_epub"); + let _ = std::fs::remove_file(&path); + + let chapter = out + .iter() + .find(|f| f.path == "OEBPS/chapter-1.xhtml") + .expect("chapter present"); + assert_eq!(chapter.data, "

hi

"); + assert_eq!(chapter.encoding, "utf8"); + } }