Commit b1fc3ce6316b08a0c7d0cc41757d36be4559b63b
1 parent
e7386559
Exists in
staging
and in
7 other branches
new tests
Showing
4 changed files
with
73 additions
and
23 deletions
Show diff stats
plugins/video/test/unit/video_block_test.rb
... | ... | @@ -15,12 +15,6 @@ class VideoBlockTest < ActiveSupport::TestCase |
15 | 15 | assert block.is_youtube? |
16 | 16 | end |
17 | 17 | |
18 | - should "is_youtube return true when the url contains https://www.youtube.com" do | |
19 | - block = VideoPlugin::VideoBlock.new | |
20 | - block.url = "https://www.youtube.com/?v=XXXXX" | |
21 | - assert block.is_youtube? | |
22 | - end | |
23 | - | |
24 | 18 | should "is_youtube return true when the url contains www.youtube.com" do |
25 | 19 | block = VideoPlugin::VideoBlock.new |
26 | 20 | block.url = "www.youtube.com/?v=XXXXX" | ... | ... |
... | ... | @@ -0,0 +1,12 @@ |
1 | +require File.dirname(__FILE__) + '/../test_helper' | |
2 | +class VideoGaleryBlockTest < ActiveSupport::TestCase | |
3 | + | |
4 | + should "define its description" do | |
5 | + assert_equal VideoPlugin::VideoGalleryBlock.description, _('Display a Video Gallery') | |
6 | + end | |
7 | + | |
8 | + should "define its help description" do | |
9 | + assert_equal VideoPlugin::VideoGalleryBlock.new.help, _('This block presents a video gallery') | |
10 | + end | |
11 | + | |
12 | +end | ... | ... |
... | ... | @@ -0,0 +1,16 @@ |
1 | +require File.dirname(__FILE__) + '/../test_helper' | |
2 | +class VideoGaleryTest < ActiveSupport::TestCase | |
3 | + | |
4 | + should "define its type_name as Video Gallery" do | |
5 | + assert_equal VideoPlugin::VideoGallery.type_name, _('Video Gallery') | |
6 | + end | |
7 | + | |
8 | + should "define its short_description" do | |
9 | + assert_equal VideoPlugin::VideoGallery.short_description, _('Video Gallery') | |
10 | + end | |
11 | + | |
12 | + should "define its description" do | |
13 | + assert_equal VideoPlugin::VideoGallery.description, _('A gallery of link to videos that are hosted elsewhere.') | |
14 | + end | |
15 | + | |
16 | +end | ... | ... |
plugins/video/test/unit/video_test.rb
... | ... | @@ -7,15 +7,15 @@ class VideoTest < ActiveSupport::TestCase |
7 | 7 | def setup |
8 | 8 | @video = VideoPlugin::Video.new |
9 | 9 | end |
10 | - | |
10 | + | |
11 | 11 | should "define its type_name as video" do |
12 | - assert_equal VideoPlugin::Video.type_name, _('Video') | |
12 | + assert_equal VideoPlugin::Video.type_name, _('Video') | |
13 | 13 | end |
14 | - | |
14 | + | |
15 | 15 | should "display version" do |
16 | 16 | assert @video.can_display_versions? |
17 | 17 | end |
18 | - | |
18 | + | |
19 | 19 | should "define its short_description" do |
20 | 20 | assert_equal VideoPlugin::Video.short_description, _('Embedded Video') |
21 | 21 | end |
... | ... | @@ -23,40 +23,68 @@ class VideoTest < ActiveSupport::TestCase |
23 | 23 | should "define its description" do |
24 | 24 | assert_equal VideoPlugin::Video.description, _('Display embedded videos.') |
25 | 25 | end |
26 | - | |
26 | + | |
27 | 27 | should "define a fitted_width" do |
28 | 28 | assert_equal @video.fitted_width, 499 |
29 | 29 | end |
30 | 30 | |
31 | 31 | should "eval a fitted_height" do |
32 | - @video.video_height = 1000 | |
33 | - @video.video_width = 2000 | |
32 | + @video.video_height = 1000 | |
33 | + @video.video_width = 2000 | |
34 | 34 | fitted_height = ((@video.fitted_width * @video.video_height) / @video.video_width).to_i |
35 | 35 | assert_equal fitted_height, @video.fitted_height |
36 | - end | |
37 | - | |
36 | + end | |
37 | + | |
38 | 38 | should "define a thumbnail_fitted_width" do |
39 | 39 | assert_equal @video.thumbnail_fitted_width, 80 |
40 | 40 | end |
41 | 41 | |
42 | 42 | should "eval a thumbnail_fitted_height" do |
43 | - @video.video_thumbnail_height = 60 | |
44 | - @video.video_thumbnail_width = 30 | |
43 | + @video.video_thumbnail_height = 60 | |
44 | + @video.video_thumbnail_width = 30 | |
45 | 45 | thumbnail_fitted_height = ((@video.thumbnail_fitted_width * @video.video_thumbnail_height) / @video.video_thumbnail_width).to_i |
46 | 46 | assert_equal thumbnail_fitted_height, @video.thumbnail_fitted_height |
47 | - end | |
48 | - | |
47 | + end | |
48 | + | |
49 | 49 | should "show a no_browser_support_message" do |
50 | 50 | assert_equal @video.no_browser_support_message, '<p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p>' |
51 | 51 | end |
52 | - | |
53 | - | |
52 | + | |
53 | + | |
54 | 54 | ### Tests for YouTube |
55 | 55 | |
56 | 56 | should "is_youtube return true when the url contains http://youtube.com" do |
57 | - @video.url = "http://youtube.com/?v=XXXXX" | |
57 | + @video.video_url = "http://youtube.com/?v=XXXXX" | |
58 | + assert @video.is_youtube? | |
59 | + end | |
60 | + | |
61 | + should "is_youtube return true when the url contains https://youtube.com" do | |
62 | + @video.video_url = "https://youtube.com/?v=XXXXX" | |
58 | 63 | assert @video.is_youtube? |
59 | 64 | end |
60 | 65 | |
61 | - | |
66 | + should "is_youtube return false when the url contains an invalid youtube link" do | |
67 | + @video.video_url = "http://www.yt.com/?v=XXXXX" | |
68 | + assert !@video.is_youtube? | |
69 | + end | |
70 | + | |
71 | + ### Tests for vimeo | |
72 | + | |
73 | + should "is_vimeo return true when the url contains vimeo.com" do | |
74 | + @video.video_url = "vimeo.com/09898" | |
75 | + assert @video.is_vimeo? | |
76 | + end | |
77 | + | |
78 | + should "is_vimeo return false when the url not contains vimeo video ID" do | |
79 | + @video.video_url = "vimeo.com/home" | |
80 | + assert !@video.is_vimeo? | |
81 | + end | |
82 | + | |
83 | + should "is_vimeo return true for https://vimeo.com/channels/staffpicks/XXXXXXXXXX" do | |
84 | + @video.video_url = "https://vimeo.com/channels/staffpicks/122325664" | |
85 | + assert @video.is_vimeo? | |
86 | + end | |
87 | + | |
88 | + | |
89 | + | |
62 | 90 | end | ... | ... |