use pdfmake_rust::{
    Alignment, Document, DocumentNode, PageBreakMode, PdfMake, Style, TextNode,
};

#[test]
fn test_dynamic_footer_with_page_numbers() {
    let doc = Document::builder()
        .content(DocumentNode::text("Page 1 content"))
        .content(DocumentNode::Text(
            TextNode::new("Page 2 content").page_break(PageBreakMode::Before),
        ))
        .footer_fn(|current_page, total_pages, _page_size| {
            DocumentNode::Text(
                TextNode::new(format!("Page {} of {}", current_page, total_pages))
                    .inline_style(Style::new().alignment(Alignment::Center)),
            )
        })
        .build();

    let pdf = PdfMake::new().render(&doc).unwrap();
    assert!(!pdf.is_empty());
}

#[test]
fn test_static_header_backward_compatible() {
    let doc = Document::builder()
        .content(DocumentNode::text("Content"))
        .header(DocumentNode::text("Static Header"))
        .footer(DocumentNode::text("Static Footer"))
        .build();

    let pdf = PdfMake::new().render(&doc).unwrap();
    assert!(!pdf.is_empty());
}

#[test]
fn test_different_headers_per_page() {
    let doc = Document::builder()
        .content(DocumentNode::text("Page 1"))
        .content(DocumentNode::Text(
            TextNode::new("Page 2").page_break(PageBreakMode::Before),
        ))
        .header_fn(|current_page, _total_pages, _page_size| {
            if current_page == 1 {
                DocumentNode::text("First Page Header")
            } else {
                DocumentNode::text("Other Pages Header")
            }
        })
        .build();

    let pdf = PdfMake::new().render(&doc).unwrap();
    assert!(!pdf.is_empty());
}
