package pdf import ( "bytes" "testing" "github.com/rjNemo/rentease/internal/config" "github.com/rjNemo/rentease/internal/service/booking" ) func TestBuildInvoice_ReturnsPDFBytes(t *testing.T) { client, err := NewPdfClient() if err != nil { t.Fatalf("unexpected error creating pdf client: %v", err) } file, err := client.BuildInvoice(booking.Invoice{ Host: *config.NewHost(), Name: "Jane Doe", PhoneNumber: "+590690441530", CustomersNumber: 2, Platform: "Booking.com", ID: "VFNI0240", From: "20/03/2026", To: "24/03/2026", Total: "250.00", AmountPaid: "100.00", BalanceDue: "150.00", Lines: []booking.InvoiceLine{{ Name: "T2", Quantity: 4, Price: "59.00", Total: "236.00", }}, Payments: []booking.PaymentLine{{ Date: "20/03/2026", Method: "Card", Amount: "100.00", }}, }) if err != nil { t.Fatalf("unexpected error building invoice PDF: %v", err) } if file.ContentType != "application/pdf" { t.Fatalf("expected PDF content type, got %q", file.ContentType) } if file.Name != "VFNI0240.pdf" { t.Fatalf("expected invoice file name, got %q", file.Name) } if !bytes.HasPrefix(file.Data, []byte("%PDF")) { t.Fatalf("expected PDF bytes, got %q", string(file.Data[:4])) } }