2022-11-20 15:43:33 -05:00
|
|
|
require "test_helper"
|
|
|
|
|
|
|
|
class ExpenseTest < ActiveSupport::TestCase
|
2023-11-22 18:51:53 -05:00
|
|
|
def test_monthly_converts_period_for_monthly
|
2023-11-22 19:02:30 -05:00
|
|
|
expense = expenses(:monthly_expense)
|
2023-11-22 18:51:53 -05:00
|
|
|
|
|
|
|
assert_equal 120.00, expense.monthly
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_monthly_converts_period_for_annually
|
2023-11-22 19:02:30 -05:00
|
|
|
expense = expenses(:annual_expense)
|
2023-11-22 18:51:53 -05:00
|
|
|
|
|
|
|
assert_equal 10.00, expense.monthly
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_monthly_converts_period_for_weekly
|
2023-11-22 19:02:30 -05:00
|
|
|
expense = expenses(:weekly_expense)
|
2023-11-22 18:51:53 -05:00
|
|
|
|
|
|
|
assert_equal 520.00, expense.monthly
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_monthly_converts_period_for_quarterly
|
2023-11-22 19:02:30 -05:00
|
|
|
expense = expenses(:quarterly_expense)
|
2023-11-22 18:51:53 -05:00
|
|
|
|
|
|
|
assert_equal 40.00, expense.monthly
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_total_calculates_total_of_expenses
|
|
|
|
assert_equal 480.00, Expense.total
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_total_calculates_monthly_total
|
|
|
|
assert_equal 690.00, Expense.monthly_total
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_total_calculates_credit_card_monthly_total
|
|
|
|
assert_equal 130.00, Expense.credit_card_monthly_total
|
|
|
|
end
|
2022-11-20 15:43:33 -05:00
|
|
|
end
|