1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-08 15:05:22 +02:00

Plaid type mapping tests

This commit is contained in:
Zach Gollwitzer 2025-05-23 12:16:30 -04:00
parent ef2ba0e54e
commit c1f6ea4759

View file

@ -0,0 +1,35 @@
require "test_helper"
class PlaidAccount::TypeMappableTest < ActiveSupport::TestCase
setup do
class MockProcessor
include PlaidAccount::TypeMappable
end
@mock_processor = MockProcessor.new
end
test "maps types to accountables" do
assert_instance_of Depository, @mock_processor.map_accountable("depository")
assert_instance_of Investment, @mock_processor.map_accountable("investment")
assert_instance_of CreditCard, @mock_processor.map_accountable("credit")
assert_instance_of Loan, @mock_processor.map_accountable("loan")
assert_instance_of OtherAsset, @mock_processor.map_accountable("other")
end
test "maps subtypes" do
assert_equal "checking", @mock_processor.map_subtype("depository", "checking")
assert_equal "roth_ira", @mock_processor.map_subtype("investment", "roth")
end
test "raises on invalid types" do
assert_raises PlaidAccount::TypeMappable::UnknownAccountTypeError do
@mock_processor.map_accountable("unknown")
end
end
test "handles nil subtypes" do
assert_equal "other", @mock_processor.map_subtype("depository", nil)
assert_equal "other", @mock_processor.map_subtype("depository", "unknown")
end
end