mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 03:06:14 +02:00
parent
d85e57d800
commit
c807bb9fcd
2 changed files with 36 additions and 3 deletions
|
@ -1,8 +1,30 @@
|
|||
require 'test_helper'
|
||||
|
||||
class InvoiceItemTest < ActiveSupport::TestCase
|
||||
def test_calculates_sum_without_vat
|
||||
def test_calculates_subtotal
|
||||
invoice_item = InvoiceItem.new(price: 5, quantity: 2)
|
||||
assert_equal 10, invoice_item.item_sum_without_vat
|
||||
assert_equal 10, invoice_item.subtotal
|
||||
end
|
||||
end
|
||||
|
||||
def test_returns_vat_rate
|
||||
vat_rate = 20
|
||||
invoice = Invoice.new(vat_rate: vat_rate)
|
||||
|
||||
invoice_item = InvoiceItem.new(invoice: invoice)
|
||||
|
||||
assert_equal vat_rate, invoice_item.vat_rate
|
||||
end
|
||||
|
||||
def test_calculates_vat_amount
|
||||
invoice = Invoice.new(vat_rate: 20)
|
||||
invoice_item = InvoiceItem.new(price: 5, quantity: 2, invoice: invoice)
|
||||
assert_equal 2, invoice_item.vat_amount
|
||||
end
|
||||
|
||||
def test_calculates_total
|
||||
invoice = Invoice.new(vat_rate: 20)
|
||||
invoice_item = InvoiceItem.new(price: 5, quantity: 2, invoice: invoice)
|
||||
assert_equal 12, invoice_item.total
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue