Sha256: 62991a8749fadcdc16c31761068eb46a9e8f763dd80af2cc048026ba8650d039

Contents?: true

Size: 1.56 KB

Versions: 30

Compression:

Stored size: 1.56 KB

Contents

#!/usr/bin/ruby

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

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

require 'xmpp4r/xhtml'
include Jabber

class XHTML::HTMLTest < Test::Unit::TestCase
  def test_set
    contents1 = REXML::Element.new('p')
    contents1.text = 'Hello'
    html = XHTML::HTML.new(contents1)
    assert_kind_of(XHTML::Body, html.first_element('body'))
    assert_equal("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'><p>Hello</p></body></html>", html.to_s)

    contents2 = REXML::Element.new('a')
    contents2.attributes['href'] = 'about:blank'
    contents2.text = 'nothing'
    html.contents = ["Look at ", contents2]
    assert_equal("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>Look at <a href='about:blank'>nothing</a></body></html>", html.to_s)
  end

  def test_parse
    html = XHTML::HTML.new('There is a fine <a href="http://home.gna.org/xmpp4r/">library</a>')
    assert_equal("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>There is a fine <a href='http://home.gna.org/xmpp4r/'>library</a></body></html>", html.to_s)
  end

  def test_text
    a1 = REXML::Element.new('a')
    a1.attributes['href'] = 'http://www.jabber.org/'
    a1.text = 'Jabber'
    a2 = REXML::Element.new('a')
    a2.attributes['href'] = 'http://home.gna.org/xmpp4r/'
    a2.text = 'XMPP4R'
    html = XHTML::HTML.new(["Look at ", a1, " & ", a2])
    assert_equal("Look at Jabber & XMPP4R", html.to_text)
  end
end

Version data entries

30 entries across 30 versions & 12 rubygems

Version Path
brontes3d-xmpp4r-0.4 test/xhtml/tc_html.rb
bryanl-xmpp4r-0.3.2 test/xhtml/tc_html.rb
edavey-xmpp4r-0.4.1 test/xhtml/tc_html.rb
edavey-xmpp4r-0.4.2 test/xhtml/tc_html.rb
edavey-xmpp4r-0.4 test/xhtml/tc_html.rb
heipei-xmpp4r-0.3.2 test/xhtml/tc_html.rb
ln-xmpp4r-0.5 test/xhtml/tc_html.rb
mojodna-xmpp4r-0.4.0.2 test/xhtml/tc_html.rb
mojodna-xmpp4r-0.4.0.3 test/xhtml/tc_html.rb
seanohalpin-xmpp4r-0.4.1 test/xhtml/tc_html.rb
xmpp4r-0.5.6 test/xhtml/tc_html.rb
xmpp4r-0.5.5 test/xhtml/tc_html.rb
mad-p-xmpp4r-0.6.3 test/xhtml/tc_html.rb
mad-p-xmpp4r-0.6.2 test/xhtml/tc_html.rb
mad-p-xmpp4r-0.6.1 test/xhtml/tc_html.rb
mad-p-xmpp4r-0.6.0 test/xhtml/tc_html.rb
cerberus-0.8.0 lib/vendor/xmpp4r/test/xhtml/tc_html.rb
cerberus-0.7.9 lib/vendor/xmpp4r/test/xhtml/tc_html.rb
edavis10-cerberus-0.7.8 lib/vendor/xmpp4r/test/xhtml/tc_html.rb
cerberus-0.7.8 lib/vendor/xmpp4r/test/xhtml/tc_html.rb