~singpolyma/sgx-jmp

c3da8bdb25cdaded490a0ed1870c4f51ce5edcf3 — Stephen Paul Weber 1 year, 1 month ago 976b77e
Fix typo, add test
2 files changed, 23 insertions(+), 2 deletions(-)

M lib/low_balance.rb
M test/test_low_balance.rb
M lib/low_balance.rb => lib/low_balance.rb +1 -1
@@ 70,7 70,7 @@ class LowBalance
			}.catch { |e|
				@message.body =
					"Automatic top-up transaction for " \
					"$#{customer.auto_top_up_amount} failed: #{e.message}"
					"$#{@customer.auto_top_up_amount} failed: #{e.message}"
			}.then { @customer.stanza_to(@message) }
		end
	end

M test/test_low_balance.rb => test/test_low_balance.rb +22 -1
@@ 65,7 65,7 @@ class LowBalanceTest < Minitest::Test
		LowBalance::AutoTopUp::Transaction = Minitest::Mock.new

		def setup
			@customer = customer(auto_top_up_amount: 100)
			@customer = Minitest::Mock.new(customer(auto_top_up_amount: 100))
			@auto_top_up = LowBalance::AutoTopUp.new(@customer)
		end



@@ 81,5 81,26 @@ class LowBalanceTest < Minitest::Test
			assert_mock tx
		end
		em :test_notify!

		def test_decline_notify!
			@customer.expect(
				:stanza_to,
				nil,
				[Matching.new { |m|
					assert_equal(
						"Automatic top-up transaction for $100 failed: test",
						m.body
					)
				}]
			)
			LowBalance::AutoTopUp::Transaction.expect(
				:sale,
				EMPromise.reject(RuntimeError.new("test")),
				[@customer, { amount: 100 }]
			)
			@auto_top_up.notify!.sync
			assert_mock @customer
		end
		em :test_decline_notify!
	end
end