@@ -240,6 +240,7 @@ fn display_path(path: &Path) -> String {
240240mod tests {
241241 use super :: * ;
242242 use std:: path:: PathBuf ;
243+ use std:: sync:: Arc ;
243244
244245 #[ test]
245246 fn display_path_uses_relative_path_when_possible ( ) {
@@ -256,4 +257,49 @@ mod tests {
256257 let path = PathBuf :: from ( "/tmp/example.pdf" ) ;
257258 assert_eq ! ( display_path( & path) , "example.pdf" ) ;
258259 }
260+
261+ #[ test]
262+ fn format_error_for_stderr_rewrites_overwrite_token_when_tty ( ) {
263+ let message = "Re-run with --overwrite" ;
264+ let rendered = format_error_for_stderr ( message) ;
265+ if stderr_is_tty ( ) {
266+ assert ! ( rendered. contains( "\x1b [1;33m--overwrite\x1b [0m" ) ) ;
267+ } else {
268+ assert_eq ! ( rendered, message) ;
269+ }
270+ }
271+
272+ #[ test]
273+ fn print_helpers_execute_without_panic ( ) {
274+ let summary = PdfSummary {
275+ pdf : "/tmp/paper.pdf" . to_string ( ) ,
276+ output_dir : "/tmp/out/paper" . to_string ( ) ,
277+ markdown_path : "/tmp/out/paper/index.md" . to_string ( ) ,
278+ downloaded_figures : 2 ,
279+ remote_figure_links : 3 ,
280+ image_blocks : 3 ,
281+ usage : None ,
282+ log_path : "/tmp/out/paper/log.jsonl" . to_string ( ) ,
283+ } ;
284+ print_single_summary_stdout ( & summary) ;
285+ print_batch_summary_stdout ( 2 , 1 , 4 ) ;
286+ }
287+
288+ #[ test]
289+ fn progress_callback_returns_none_without_multi_progress ( ) {
290+ assert ! ( progress_callback( Path :: new( "paper.pdf" ) , None ) . is_none( ) ) ;
291+ }
292+
293+ #[ test]
294+ fn progress_callback_handles_all_events ( ) {
295+ let multi = Arc :: new ( MultiProgress :: with_draw_target ( ProgressDrawTarget :: hidden ( ) ) ) ;
296+ let callback = progress_callback ( Path :: new ( "paper.pdf" ) , Some ( multi) ) . unwrap ( ) ;
297+ callback ( ProgressEvent :: OcrStarted ) ;
298+ callback ( ProgressEvent :: OcrFinished ) ;
299+ callback ( ProgressEvent :: MarkdownWriteStarted { bytes : 16 } ) ;
300+ callback ( ProgressEvent :: MarkdownWriteFinished ) ;
301+ callback ( ProgressEvent :: FigureScanStarted { total : 2 } ) ;
302+ callback ( ProgressEvent :: FigureDownloadFinished ) ;
303+ callback ( ProgressEvent :: FigureDownloadFinished ) ;
304+ }
259305}
0 commit comments