1# frozen_string_literal: true
2
3require "test_helper"
4require "alt_top_up_form"
5require "add_bitcoin_address"
6
7class AddBitcoinAddressTest < Minitest::Test
8 def test_for
9 iq = Blather::Stanza::Iq::Command.new
10 cust = customer
11 AddBitcoinAddress.for(iq, AltTopUpForm.new(cust), cust)
12 end
13
14 def test_for_add_bitcoin
15 iq = Blather::Stanza::Iq::Command.new
16 iq.form.fields = [{ var: "add_btc_address", value: "true" }]
17 cust = customer
18 AddBitcoinAddress.for(iq, AltTopUpForm.new(cust), cust)
19 end
20
21 def test_write
22 cust = Minitest::Mock.new
23 cust.expect(:add_btc_address, EMPromise.resolve("newaddress"))
24 iq = Blather::Stanza::Iq::Command.new
25 AddBitcoinAddress.new(iq, cust).write.sync
26 assert_mock cust
27 end
28 em :test_write
29
30 class DoNotTest < Minitest::Test
31 AddBitcoinAddress::DoNot::BLATHER = Minitest::Mock.new
32
33 def test_write
34 AddBitcoinAddress::DoNot::BLATHER.expect(
35 :<<,
36 EMPromise.resolve(nil)
37 ) do |stanza|
38 assert_equal :completed, stanza.status
39 end
40 iq = Blather::Stanza::Iq::Command.new
41 AddBitcoinAddress::DoNot.new(iq).write.sync
42 assert_mock AddBitcoinAddress::DoNot::BLATHER
43 end
44 em :test_write
45 end
46end