test/devcenter-parser_test.rb in devcenter-parser-2.4.0 vs test/devcenter-parser_test.rb in devcenter-parser-2.5.1

- old
+ new

@@ -58,14 +58,20 @@ it 'allows embedding youtube videos from its no-cookies domain' do src = '<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/123456ABCDEF" frameborder="0" allowfullscreen=""></iframe>' assert_parsing_result src, src end - it 'removes youtube videos embedded from the with-cookies domain' do - src = '<iframe width="560" height="315" src="https://www.youtube.com/embed/123456ABCDEF" frameborder="0" allowfullscreen=""></iframe>' - assert_parsing_result src, '' + it 'allows embedding youtube videos from its no-cookies domain with allow attribute' do + src = '<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/123456ABCDEF" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen=""></iframe>' + assert_parsing_result src, src end + + it 'converts youtube videos embedded from the with-cookies domain to the no-cookies domain' do + src = '<iframe width="560" height="315" src="https://www.youtube.com/embed/123456ABCDEF" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen=""></iframe>' + src_result = '<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/123456ABCDEF" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen=""></iframe>' + assert_parsing_result src, src_result + end it 'does not allow embedding vimeo videos when their do-no-track param is set to something different than true' do src = '<iframe src="https://player.vimeo.com/video/143343818?api=1&amp;dnt=foo&amp;title=foo" width="50" height="281" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>' assert_parsing_result src, '' end @@ -73,10 +79,15 @@ it 'does not allow embedding vimeo videos when their do-no-track param is not passed' do src = '<iframe src="https://player.vimeo.com/video/143343818?api=1&&amp;title=foo" width="50" height="281" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>' assert_parsing_result src, '' end + it 'allows embedding vidyard videos with data attributes' do + src = '<p><img style="width: 100%; margin: auto; display: block;" class="vidyard-player-embed" src="https://play.vidyard.com/123456ABCDEFG.jpg" data-uuid="123456ABCDEFG" data-v="4" data-type="inline"></p>' + assert_parsing_result src, src + end + it 'allows images' do src = '<p><img src="http://nav.heroku.com/images/logos/logo.png" alt="image"></p>' assert_parsing_result src, src end @@ -513,8 +524,12 @@ assert_equal expected.strip, result.strip, "Failed when parsing on unsanitized mode\n#{md}\n.\n\nExpected:\n#{expected}\n\nActual result:\n#{result}\n\n" end def assert_header_id(md, header, id) assert DevcenterParser.to_html(md).include?("<#{header} id=\"#{id}\">"), "GitHub does not generate a #{header} with id #{id}" + end + + def assert_contains(md, contains) + assert DevcenterParser.to_html(md).include?(contains), "Failed when parsing #{md}\n.\n\nDid not contain: #{contains}\n\n" end end