mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-05 13:35:21 +02:00
Remove trend tests where current is nil
I think if we've gotten this far with a nil value for current, there's a data integrity problem. If we allow this, we'll have to be very defensive in our code. Best to raise and fix early.
This commit is contained in:
parent
3c4bdb6bef
commit
996a2e1c75
1 changed files with 5 additions and 24 deletions
|
@ -9,38 +9,19 @@ class TimeSeries::TrendTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
test "up" do
|
||||
trend = TimeSeries::Trend.new(current: 100, previous: 50)
|
||||
assert_equal "up", trend.direction
|
||||
assert_equal "up", TimeSeries::Trend.new(current: 100, previous: 50).direction
|
||||
end
|
||||
|
||||
test "down" do
|
||||
trend = TimeSeries::Trend.new(current: 50, previous: 100)
|
||||
assert_equal "down", trend.direction
|
||||
assert_equal "down", TimeSeries::Trend.new(current: 50, previous: 100).direction
|
||||
end
|
||||
|
||||
test "flat" do
|
||||
trend1 = TimeSeries::Trend.new(current: 100, previous: 100)
|
||||
trend3 = TimeSeries::Trend.new(current: 100, previous: nil)
|
||||
trend2 = TimeSeries::Trend.new(current: nil, previous: nil)
|
||||
assert_equal "flat", trend1.direction
|
||||
assert_equal "flat", trend2.direction
|
||||
assert_equal "flat", trend3.direction
|
||||
assert_equal "flat", TimeSeries::Trend.new(current: 100, previous: 100).direction
|
||||
assert_equal "flat", TimeSeries::Trend.new(current: 100, previous: nil).direction
|
||||
end
|
||||
|
||||
test "infinitely up" do
|
||||
trend = TimeSeries::Trend.new(current: 100, previous: 0)
|
||||
assert_equal "up", trend.direction
|
||||
end
|
||||
|
||||
test "infinitely down" do
|
||||
trend1 = TimeSeries::Trend.new(current: nil, previous: 100)
|
||||
trend2 = TimeSeries::Trend.new(current: 0, previous: 100)
|
||||
assert_equal "down", trend1.direction
|
||||
assert_equal "down", trend2.direction
|
||||
end
|
||||
|
||||
test "empty" do
|
||||
trend = TimeSeries::Trend.new
|
||||
assert_equal "flat", trend.direction
|
||||
assert_equal "up", TimeSeries::Trend.new(current: 100, previous: 0).direction
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue