Class: IqVcardTest

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

Instance Method Summary collapse

Instance Method Details

#test_createObject



11
12
13
14
# File 'lib/vendor/xmpp4r/test/vcard/tc_iqvcard.rb', line 11

def test_create
  v = Vcard::IqVcard.new
  assert_equal([], v.fields)
end

#test_create_with_fieldsObject



16
17
18
19
20
21
22
# File 'lib/vendor/xmpp4r/test/vcard/tc_iqvcard.rb', line 16

def test_create_with_fields
  v = Vcard::IqVcard.new({'FN' => 'B C', 'NICKNAME' => 'D'})
  assert_equal(['FN', 'NICKNAME'], v.fields.sort)
  assert_equal('B C', v['FN'])
  assert_equal('D', v['NICKNAME'])
  assert_equal(nil, v['x'])
end

#test_deepObject



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/vendor/xmpp4r/test/vcard/tc_iqvcard.rb', line 39

def test_deep
  v = Vcard::IqVcard.new({
    'FN' => 'John D. Random',
    'PHOTO/TYPE' => 'image/png',
    'PHOTO/BINVAL' => '===='})

    assert_equal(['FN', 'PHOTO/BINVAL', 'PHOTO/TYPE'], v.fields.sort)
    assert_equal('John D. Random', v['FN'])
    assert_equal('image/png', v['PHOTO/TYPE'])
    assert_equal('====', v['PHOTO/BINVAL'])
    assert_equal(nil, v['PHOTO'])
    assert_equal(nil, v['NICKNAME'])
end

#test_fieldsObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/vendor/xmpp4r/test/vcard/tc_iqvcard.rb', line 24

def test_fields
  v = Vcard::IqVcard.new
  f = ['a', 'b', 'c', 'd', 'e']
  f.each { |s|
    v[s.downcase] = s.upcase
  }

  assert_equal(f, v.fields.sort)

  f.each { |s|
    assert_equal(s.upcase, v[s.downcase])
    assert_equal(nil, v[s.upcase])
  }
end

#test_photo_binvalObject



53
54
55
56
# File 'lib/vendor/xmpp4r/test/vcard/tc_iqvcard.rb', line 53

def test_photo_binval
  v = Vcard::IqVcard.new({'PHOTO/BINVAL'=>"SGVsbG8gd29ybGQ=\n"})
  assert_equal('Hello world', v.photo_binval)
end

#test_photo_binval_nilObject



58
59
60
61
# File 'lib/vendor/xmpp4r/test/vcard/tc_iqvcard.rb', line 58

def test_photo_binval_nil
  v = Vcard::IqVcard.new({})
  assert_nil(v.photo_binval)
end