Sha256: 49fc4da1fe076e37c3367437c3953afd794fc5d718007ea60f97ad29f646f586

Contents?: true

Size: 1.58 KB

Versions: 12

Compression:

Stored size: 1.58 KB

Contents

require 'test_helper'

module PolishInvoicer
  class PresenterTest < Minitest::Test
    require 'ostruct'

    def setup
      @invoice = OpenStruct.new
    end

    def test_format_dates
      @invoice.trade_date = Date.parse('2014-01-01')
      @invoice.create_date = Date.parse('2014-01-15')
      @invoice.payment_date = Date.parse('2014-01-30')
      data = Presenter.new(@invoice).data
      assert_equal '01.01.2014', data[:trade_date]
      assert_equal '15.01.2014', data[:create_date]
      assert_equal '30.01.2014', data[:payment_date]
    end

    def test_format_prices
      @invoice.net_value = 123.4567
      @invoice.vat_value = 23.9876
      @invoice.gross_value = 456.3378
      data = Presenter.new(@invoice).data
      assert_equal '123,46', data[:net_value]
      assert_equal '23,99', data[:vat_value]
      assert_equal '456,34', data[:gross_value]
    end

    def test_format_comments
      @invoice.comments = nil
      data = Presenter.new(@invoice).data
      assert_equal [], data[:comments]
      @invoice.comments = 'Test'
      data = Presenter.new(@invoice).data
      assert_equal ['Test'], data[:comments]
      @invoice.comments = %w(A B)
      data = Presenter.new(@invoice).data
      assert_equal %w(A B), data[:comments]
    end

    def test_vat
      @invoice.vat = 23
      data = Presenter.new(@invoice).data
      assert_equal '23%', data[:vat]
      @invoice.vat = 0
      data = Presenter.new(@invoice).data
      assert_equal '0%', data[:vat]
      @invoice.vat = -1
      data = Presenter.new(@invoice).data
      assert_equal 'zw.', data[:vat]
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
polish_invoicer-0.0.17 test/presenter_test.rb
polish_invoicer-0.0.16 test/presenter_test.rb
polish_invoicer-0.0.15 test/presenter_test.rb
polish_invoicer-0.0.14 test/presenter_test.rb
polish_invoicer-0.0.13 test/presenter_test.rb
polish_invoicer-0.0.12 test/presenter_test.rb
polish_invoicer-0.0.11 test/presenter_test.rb
polish_invoicer-0.0.10 test/presenter_test.rb
polish_invoicer-0.0.9 test/presenter_test.rb
polish_invoicer-0.0.8 test/presenter_test.rb
polish_invoicer-0.0.7 test/presenter_test.rb
polish_invoicer-0.0.6 test/presenter_test.rb