Sha256: 04dd2de0a0a540702b99d299dbb0a5196da67dd35c93fed774b663358b6dfe70

Contents?: true

Size: 1.11 KB

Versions: 15

Compression:

Stored size: 1.11 KB

Contents

require 'test_helper'

class PageNumbersTest < Minitest::Test
  include InvoicePrinterHelpers

  # If there is only one page, we skip numbering
  def test_do_not_number_1_page
    item = InvoicePrinter::Document::Item.new(default_document_item_params)
    params = default_document_params.merge(
      items: [item]
    )
    invoice = InvoicePrinter::Document.new(params)
    rendered_pdf = InvoicePrinter.render(document: invoice)
    pdf_analysis = PDF::Inspector::Text.analyze(rendered_pdf)

    assert_equal false, pdf_analysis.strings.include?('1/1')
  end

  def test_number_2_and_more_pages
    item = InvoicePrinter::Document::Item.new(default_document_item_params)
    items = [item] * 50
    params = default_document_params.merge(
      items: items
    )
    invoice = InvoicePrinter::Document.new(params)
    rendered_pdf = InvoicePrinter.render(document: invoice)
    pdf_analysis = PDF::Inspector::Text.analyze(rendered_pdf)

    assert_equal true, pdf_analysis.strings.include?('1 / 3')
    assert_equal true, pdf_analysis.strings.include?('2 / 3')
    assert_equal true, pdf_analysis.strings.include?('3 / 3')
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
invoice_printer-2.0.0 test/page_numbers_test.rb
invoice_printer-2.0.0.beta3 test/page_numbers_test.rb
invoice_printer-2.0.0.beta2 test/page_numbers_test.rb
invoice_printer-2.0.0.beta1 test/page_numbers_test.rb
invoice_printer-2.0.0.alpha1 test/page_numbers_test.rb
invoice_printer-1.3.0 test/page_numbers_test.rb
invoice_printer-1.2.0 test/page_numbers_test.rb
invoice_printer-1.2.0.alpha1 test/page_numbers_test.rb
invoice_printer-1.1.0 test/page_numbers_test.rb
invoice_printer-1.1.0.rc1 test/page_numbers_test.rb
invoice_printer-1.0.0 test/page_numbers_test.rb
invoice_printer-1.0.0.rc1 test/page_numbers_test.rb
invoice_printer-0.0.9 test/page_numbers_test.rb
invoice_printer-0.0.8 test/page_numbers_test.rb
invoice_printer-0.0.7 test/page_numbers_test.rb