~singpolyma/sgx-jmp

ref: 6ead87605043d167e477aa8d7959d6e4b7af7d03 sgx-jmp/test/test_add_bitcoin_address.rb -rw-r--r-- 1.1 KiB
6ead8760Christopher Vollick Remove BigDecimal.new 1 year, 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# frozen_string_literal: true

require "test_helper"
require "alt_top_up_form"
require "add_bitcoin_address"

class AddBitcoinAddressTest < Minitest::Test
	def test_for
		iq = Blather::Stanza::Iq::Command.new
		cust = customer
		AddBitcoinAddress.for(iq, AltTopUpForm.new(cust), cust)
	end

	def test_for_add_bitcoin
		iq = Blather::Stanza::Iq::Command.new
		iq.form.fields = [{ var: "add_btc_address", value: "true" }]
		cust = customer
		AddBitcoinAddress.for(iq, AltTopUpForm.new(cust), cust)
	end

	def test_write
		cust = Minitest::Mock.new
		cust.expect(:add_btc_address, EMPromise.resolve("newaddress"))
		iq = Blather::Stanza::Iq::Command.new
		AddBitcoinAddress.new(iq, cust).write.sync
		assert_mock cust
	end
	em :test_write

	class DoNotTest < Minitest::Test
		AddBitcoinAddress::DoNot::BLATHER = Minitest::Mock.new

		def test_write
			AddBitcoinAddress::DoNot::BLATHER.expect(
				:<<,
				EMPromise.resolve(nil)
			) do |stanza|
				assert_equal :completed, stanza.status
			end
			iq = Blather::Stanza::Iq::Command.new
			AddBitcoinAddress::DoNot.new(iq).write.sync
			assert_mock AddBitcoinAddress::DoNot::BLATHER
		end
		em :test_write
	end
end