diff --git a/plugins/video/test/unit/video_block_test.rb b/plugins/video/test/unit/video_block_test.rb index 880de13..ab1121a 100644 --- a/plugins/video/test/unit/video_block_test.rb +++ b/plugins/video/test/unit/video_block_test.rb @@ -15,12 +15,6 @@ class VideoBlockTest < ActiveSupport::TestCase assert block.is_youtube? end - should "is_youtube return true when the url contains https://www.youtube.com" do - block = VideoPlugin::VideoBlock.new - block.url = "https://www.youtube.com/?v=XXXXX" - assert block.is_youtube? - end - should "is_youtube return true when the url contains www.youtube.com" do block = VideoPlugin::VideoBlock.new block.url = "www.youtube.com/?v=XXXXX" diff --git a/plugins/video/test/unit/video_galery_block_test.rb b/plugins/video/test/unit/video_galery_block_test.rb new file mode 100644 index 0000000..1c85249 --- /dev/null +++ b/plugins/video/test/unit/video_galery_block_test.rb @@ -0,0 +1,12 @@ +require File.dirname(__FILE__) + '/../test_helper' +class VideoGaleryBlockTest < ActiveSupport::TestCase + + should "define its description" do + assert_equal VideoPlugin::VideoGalleryBlock.description, _('Display a Video Gallery') + end + + should "define its help description" do + assert_equal VideoPlugin::VideoGalleryBlock.new.help, _('This block presents a video gallery') + end + +end diff --git a/plugins/video/test/unit/video_galery_test.rb b/plugins/video/test/unit/video_galery_test.rb new file mode 100644 index 0000000..7ed929b --- /dev/null +++ b/plugins/video/test/unit/video_galery_test.rb @@ -0,0 +1,16 @@ +require File.dirname(__FILE__) + '/../test_helper' +class VideoGaleryTest < ActiveSupport::TestCase + + should "define its type_name as Video Gallery" do + assert_equal VideoPlugin::VideoGallery.type_name, _('Video Gallery') + end + + should "define its short_description" do + assert_equal VideoPlugin::VideoGallery.short_description, _('Video Gallery') + end + + should "define its description" do + assert_equal VideoPlugin::VideoGallery.description, _('A gallery of link to videos that are hosted elsewhere.') + end + +end diff --git a/plugins/video/test/unit/video_test.rb b/plugins/video/test/unit/video_test.rb index f7c0cce..57bb067 100644 --- a/plugins/video/test/unit/video_test.rb +++ b/plugins/video/test/unit/video_test.rb @@ -7,15 +7,15 @@ class VideoTest < ActiveSupport::TestCase def setup @video = VideoPlugin::Video.new end - + should "define its type_name as video" do - assert_equal VideoPlugin::Video.type_name, _('Video') + assert_equal VideoPlugin::Video.type_name, _('Video') end - + should "display version" do assert @video.can_display_versions? end - + should "define its short_description" do assert_equal VideoPlugin::Video.short_description, _('Embedded Video') end @@ -23,40 +23,68 @@ class VideoTest < ActiveSupport::TestCase should "define its description" do assert_equal VideoPlugin::Video.description, _('Display embedded videos.') end - + should "define a fitted_width" do assert_equal @video.fitted_width, 499 end should "eval a fitted_height" do - @video.video_height = 1000 - @video.video_width = 2000 + @video.video_height = 1000 + @video.video_width = 2000 fitted_height = ((@video.fitted_width * @video.video_height) / @video.video_width).to_i assert_equal fitted_height, @video.fitted_height - end - + end + should "define a thumbnail_fitted_width" do assert_equal @video.thumbnail_fitted_width, 80 end should "eval a thumbnail_fitted_height" do - @video.video_thumbnail_height = 60 - @video.video_thumbnail_width = 30 + @video.video_thumbnail_height = 60 + @video.video_thumbnail_width = 30 thumbnail_fitted_height = ((@video.thumbnail_fitted_width * @video.video_thumbnail_height) / @video.video_thumbnail_width).to_i assert_equal thumbnail_fitted_height, @video.thumbnail_fitted_height - end - + end + should "show a no_browser_support_message" do assert_equal @video.no_browser_support_message, '
To view this video please enable JavaScript, and consider upgrading to a web browser that supports HTML5 video
' end - - + + ### Tests for YouTube should "is_youtube return true when the url contains http://youtube.com" do - @video.url = "http://youtube.com/?v=XXXXX" + @video.video_url = "http://youtube.com/?v=XXXXX" + assert @video.is_youtube? + end + + should "is_youtube return true when the url contains https://youtube.com" do + @video.video_url = "https://youtube.com/?v=XXXXX" assert @video.is_youtube? end - + should "is_youtube return false when the url contains an invalid youtube link" do + @video.video_url = "http://www.yt.com/?v=XXXXX" + assert !@video.is_youtube? + end + + ### Tests for vimeo + + should "is_vimeo return true when the url contains vimeo.com" do + @video.video_url = "vimeo.com/09898" + assert @video.is_vimeo? + end + + should "is_vimeo return false when the url not contains vimeo video ID" do + @video.video_url = "vimeo.com/home" + assert !@video.is_vimeo? + end + + should "is_vimeo return true for https://vimeo.com/channels/staffpicks/XXXXXXXXXX" do + @video.video_url = "https://vimeo.com/channels/staffpicks/122325664" + assert @video.is_vimeo? + end + + + end -- libgit2 0.21.2