From c1f6ea4759eb1be739e1161738d3192b3fe9a85b Mon Sep 17 00:00:00 2001 From: Zach Gollwitzer Date: Fri, 23 May 2025 12:16:30 -0400 Subject: [PATCH] Plaid type mapping tests --- .../plaid_account/type_mappable_test.rb | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/models/plaid_account/type_mappable_test.rb diff --git a/test/models/plaid_account/type_mappable_test.rb b/test/models/plaid_account/type_mappable_test.rb new file mode 100644 index 00000000..b3bc6708 --- /dev/null +++ b/test/models/plaid_account/type_mappable_test.rb @@ -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