#!/usr/bin/env ruby
# $Id: tc_ext_form.rb,v 1.1 2004/05/09 09:24:53 eto Exp $
# Copyright (C) 2003-2004 Kouichirou Eto, All rights reserved.
# This is free software with ABSOLUTELY NO WARRANTY.
# You can redistribute it and/or modify it under the terms of the GNU GPL2.

require 'test_common'

class TC_Form < Test::Unit::TestCase
  include TestSite

  def test_form
    page = @site.create_new
    str = <<"EOS"
{{form
|項目|{{input(name,default,must)}}|
|説明|
||{{submit( 投稿 )}}|
}}
EOS
    page.store(str)
    xml = page.load.w.res(@site)
    assert_equal("<body><div class='form'><form action='TestPage.html' method='POST'><input name='page' type='hidden' value='TestPage'/><table class='form'><tr><td class='midashi'>項目</td><td class='nakami'><input name='name' size='must' value='default'/></td></tr><tr><td class='msg' colspan='2'>説明</td></tr><tr><td class='midashi'></td><td class='nakami'><input class='submit' type='submit' value=' 投稿 '/></td></tr></table></form></div></body>", xml.to_s)

    # test_form
    assert_equal("<div class='form'><form action='dest.html' method='POST'><input name='page' type='hidden' value='TestPage' /><table class='form'><tr><td class='midashi'>k</td><td class='nakami'><span>v</span></td></tr></table></form></div>".chomp, @plugin.form('dest'){"|k|v|"}.to_xhtml)
    str =
"|mail|{{input(tomail,,must)}}|
|input your mail.|
||{{submit( GO )}}|"
    assert_equal("<div class='form'><form action='dest.html' method='POST'><input name='page' type='hidden' value='TestPage' /><table class='form'><tr><td class='midashi'>mail</td><td class='nakami'><input name='tomail' size='must' value='' /></td></tr><tr><td class='msg' colspan='2'>input your mail.</td></tr><tr><td class='midashi'></td><td class='nakami'><input class='submit' type='submit' value=' GO ' /></td></tr></table></form></div>", @plugin.form('dest'){str}.to_xhtml)

  end
end
