1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-19 13:19:39 +02:00
Maybe/test/models/import/field_test.rb
Zach Gollwitzer 45ae4a9737
CSV Transaction Imports (#708)
Introduces a basic CSV import module for bulk-importing account transactions.

Changes include:

- User can load a CSV
- User can configure the column mappings for a CSV
- Imported CSV shows invalid cells
- User can clean up their data directly in the UI
- User can see a preview of the import rows and confirm import
- Layout refactor + Import nav stepper
- System test stability improvements
2024-05-17 09:09:32 -04:00

28 lines
681 B
Ruby

require "test_helper"
class Import::FieldTest < ActiveSupport::TestCase
test "key is always a string" do
field1 = Import::Field.new label: "Test", key: "test"
field2 = Import::Field.new label: "Test2", key: :test2
assert_equal "test", field1.key
assert_equal "test2", field2.key
end
test "can set and override a validator for a field" do
field = Import::Field.new \
label: "Test",
key: "Test",
validator: ->(val) { val == 42 }
assert field.validate(42)
assert_not field.validate(41)
field.define_validator do |value|
value == 100
end
assert field.validate(100)
assert_not field.validate(42)
end
end