Class: Vcard::HelperTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
ClientTester
Defined in:
lib/vendor/xmpp4r/test/vcard/tc_helper.rb

Instance Method Summary collapse

Instance Method Details

#test_callbackObject



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
47
48
# File 'lib/vendor/xmpp4r/test/vcard/tc_helper.rb', line 20

def test_callback
  @server.on_exception{|*e| p e}
  class << @client
    remove_method(:jid)
    def jid
      JID.new('[email protected]/b')
    end
  end

  state { |iq|
    assert_kind_of(Iq, iq)
    assert_equal(JID.new('[email protected]'), iq.to)
    assert_equal(:get, iq.type)
    assert_nil(iq.queryns)
    assert_kind_of(Vcard::IqVcard, iq.vcard)
    children = 0
    iq.vcard.each_child { children += 1 }
    assert_equal(0, children)

    send("<iq type='result' from='#{iq.to}' to='#{iq.from}' id='#{iq.id}'><vCard xmlns='vcard-temp'><NICKNAME>Mr. B</NICKNAME><PHOTO><TYPE>image/png</TYPE><BINVAL>====</BINVAL></PHOTO></vCard></iq>")
  }

  res = Vcard::Helper::get(@client, '[email protected]')
  wait_state
  assert_kind_of(Vcard::IqVcard, res)
  assert_equal('Mr. B', res['NICKNAME'])
  assert_equal('image/png', res['PHOTO/TYPE'])
  assert_equal('====', res['PHOTO/BINVAL'])
end

#test_createObject



15
16
17
18
# File 'lib/vendor/xmpp4r/test/vcard/tc_helper.rb', line 15

def test_create
  h = Vcard::Helper.new(@client)
  assert_kind_of(Vcard::Helper, h)
end