Sha256: 38129413755a91d08a33d6c6353d473333a38832f9ddd2ed6dd16e96a565466d

Contents?: true

Size: 1.77 KB

Versions: 4

Compression:

Stored size: 1.77 KB

Contents

#!/usr/bin/env ruby

$:.unshift File::dirname(__FILE__) + '/../../lib'

require 'test/unit'
require File::dirname(__FILE__) + '/../lib/clienttester'

require 'xmpp4r'
require 'xmpp4r/pubsub/children/node_config'
require 'xmpp4r/dataforms'
include Jabber

# Jabber.debug = true

class PubSub::NodeConfigTest < Test::Unit::TestCase
  include ClientTester

  def test_create()
    config = PubSub::NodeConfig.new()
    assert_nil(config.form)
    assert_nil(config.node)
    assert_equal({}, config.options)
  end

  def test_create_with_options
    options = {'pubsub#access_model'=>'open'}

    config = PubSub::NodeConfig.new(nil, options)
    assert_kind_of(Jabber::Dataforms::XData, config.form)
    assert_equal(options, config.options)
    assert_equal(:submit, config.form.type)
    assert_equal('http://jabber.org/protocol/pubsub#node_config', config.form.field('FORM_TYPE').values.first)
  end

  def test_create_with_options_and_node
    node = 'mynode'
    options = {'pubsub#access_model'=>'open'}

    config = PubSub::NodeConfig.new(node, options)
    assert_equal(node, config.node)
    assert_kind_of(Jabber::Dataforms::XData, config.form)
    assert_equal(options, config.options)
    assert_equal(:submit, config.form.type)
    assert_equal('http://jabber.org/protocol/pubsub#node_config', config.form.field('FORM_TYPE').values.first)
  end

  def test_set_options
    options = {'pubsub#access_model'=>'open'}
    config = PubSub::NodeConfig.new()
    config.options = options
    assert_kind_of(Jabber::Dataforms::XData, config.form)
    assert_equal(options, config.options)
  end

  def test_create_with_array_in_options
    options = {'pubsub#collection'=>['parent1','parent2']}
    config = PubSub::OwnerNodeConfig.new(nil, options)

    assert_equal(options, config.options)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gmcmillan-xmpp4r-0.6.2 test/pubsub/tc_nodeconfig.rb
gmcmillan-xmpp4r-0.6.1 test/pubsub/tc_nodeconfig.rb
gmcmillan-xmpp4r-0.6 test/pubsub/tc_nodeconfig.rb
gmcmillan-xmpp4r-0.5 test/pubsub/tc_nodeconfig.rb