Class: Roster::RosterItemTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/gems/xmpp4r-0.4/test/roster/tc_iqqueryroster.rb

Instance Method Summary collapse

Instance Method Details

#test_createObject



123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/gems/xmpp4r-0.4/test/roster/tc_iqqueryroster.rb', line 123

def test_create
  ri = Roster::RosterItem.new
  assert_equal(JID.new, ri.jid)
  assert_equal(nil, ri.iname)
  assert_equal(nil, ri.subscription)
  assert_equal(nil, ri.ask)

  ri = Roster::RosterItem.new(JID.new('a@b/c'), 'xyz', :both, nil)
  assert_equal(JID.new('a@b/c'), ri.jid)
  assert_equal('xyz', ri.iname)
  assert_equal(:both, ri.subscription)
  assert_equal(nil, ri.ask)
end

#test_dupgroupsObject



167
168
169
170
171
172
# File 'lib/gems/xmpp4r-0.4/test/roster/tc_iqqueryroster.rb', line 167

def test_dupgroups
  ri = Roster::RosterItem.new
  mygroups = ['a', 'a', 'b']
  ri.groups = mygroups
  assert_equal(mygroups.uniq, ri.groups)
end

#test_groupdeletionObject



157
158
159
160
161
162
163
164
165
# File 'lib/gems/xmpp4r-0.4/test/roster/tc_iqqueryroster.rb', line 157

def test_groupdeletion
  ri = Roster::RosterItem.new
  g1 = ['a', 'b', 'c']
  ri.groups = g1
  assert_equal(g1, ri.groups.sort)
  g2 = ['c', 'd', 'e']
  ri.groups = g2
  assert_equal(g2, ri.groups.sort)
end

#test_modifyObject



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/gems/xmpp4r-0.4/test/roster/tc_iqqueryroster.rb', line 137

def test_modify
  ri = Roster::RosterItem.new(JID.new('a@b/c'), 'xyz', :both, :subscribe)

  assert_equal(JID.new('a@b/c'), ri.jid)
  ri.jid = nil
  assert_equal(JID.new, ri.jid)

  assert_equal('xyz', ri.iname)
  ri.iname = nil
  assert_equal(nil, ri.iname)

  assert_equal(:both, ri.subscription)
  ri.subscription = nil
  assert_equal(nil, ri.subscription)

  assert_equal(:subscribe, ri.ask)
  ri.ask = nil
  assert_equal(nil, ri.ask)
end