require 'test/unit'
require 'youtube_embed'

class YoutubeEmbedTest < Test::Unit::TestCase
  
  def test_default_params
    macro = YoutubeEmbed.new({'video_id' => "FOOBAR"}, nil, nil)
    expected_output = <<-EXPECTED
    <notextile>
      <object width="640" height="385">
        <param name="movie" value="http://www.youtube.com/v/FOOBAR?fs=1&amp;hl=en_US&amp;hd=1"></param>
        <param name="allowFullScreen" value="true"></param>
        <param name="allowscriptaccess" value="always"></param>
        <embed 
          src="http://www.youtube.com/v/FOOBAR?fs=1&amp;hl=en_US&amp;hd=1" 
          type="application/x-shockwave-flash" 
          allowscriptaccess="always" 
          allowfullscreen="true" width="640" height="385">
        </embed>
      </object>
    </notextile>
    EXPECTED
    assert_equal expected_output, macro.execute
  end
  
  def test_override_width_and_height
    macro = YoutubeEmbed.new({'video_id' => "FOOBAR", 'width' => '999', 'height' => '777'}, nil, nil)
    expected_output = <<-EXPECTED
    <notextile>
      <object width="999" height="777">
        <param name="movie" value="http://www.youtube.com/v/FOOBAR?fs=1&amp;hl=en_US&amp;hd=1"></param>
        <param name="allowFullScreen" value="true"></param>
        <param name="allowscriptaccess" value="always"></param>
        <embed 
          src="http://www.youtube.com/v/FOOBAR?fs=1&amp;hl=en_US&amp;hd=1" 
          type="application/x-shockwave-flash" 
          allowscriptaccess="always" 
          allowfullscreen="true" width="999" height="777">
        </embed>
      </object>
    </notextile>
    EXPECTED
    
    assert_equal expected_output, macro.execute
  end
end