Sha256: 875732105574fb5bee089d82c5602dcae7a19a893b7d77221e8e1df92aa59d18

Contents?: true

Size: 1.86 KB

Versions: 6

Compression:

Stored size: 1.86 KB

Contents

require 'test_helper'

class DatesBoxTest < Minitest::Test
  include InvoicePrinterHelpers

  def test_setting_issue_date_and_due_date
    params = default_document_params.merge(
      issue_date: '05/03/2016',
      due_date: '14/03/2016'
    )
    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?('Issue date:')
    assert_equal true, pdf_analysis.strings.include?('Due date:')
  end

  def test_setting_only_issue_date
    params = default_document_params.merge(
      issue_date: '05/03/2016',
      due_date: ''
    )
    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?('Issue date:')
    assert_equal false, pdf_analysis.strings.include?('Due date:')
  end

  def test_setting_only_due_date
    params = default_document_params.merge(
      issue_date: nil,
      due_date: '05/03/2016'
    )
    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?('Issue date:')
    assert_equal true, pdf_analysis.strings.include?('Due date:')
  end

  def test_setting_no_dates
    params = default_document_params.merge(
      issue_date: '',
      due_date: nil
    )
    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?('Issue date:')
    assert_equal false, pdf_analysis.strings.include?('Due date:')
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
invoice_printer-0.0.8 test/dates_box_test.rb
invoice_printer-0.0.7 test/dates_box_test.rb
invoice_printer-0.0.6 test/dates_box_test.rb
invoice_printer-0.0.5 test/dates_box_test.rb
invoice_printer-0.0.4 test/dates_box_test.rb
invoice_printer-0.0.3 test/dates_box_test.rb