Sha256: 5ac61a39751d8e4da03eabfa1a48484e82e1813410a12a79adb1e1b0cef71f3f

Contents?: true

Size: 1.93 KB

Versions: 3

Compression:

Stored size: 1.93 KB

Contents

require "test_helper"

module Workarea
  module Storefront
    class ProductVideoViewModelTest < TestCase
      def test_iframe_attrs_for_all_videos
        @product = create_product(
          name: "test",
          videos: [{ embed_code: youtube_embed, display_option: "embedded" }]
        )

        view_model = ProductVideoViewModel.wrap(@product.videos.first)
        assert_equal("youtube-rSGnNMnvM6M", view_model.iframe_attrs[:id])
        assert_equal("0", view_model.iframe_attrs[:frameborder])
        assert_equal("padding-bottom: 56.25%", view_model.iframe_attrs[:container_style])
        assert_equal("", view_model.iframe_attrs[:allowfullscreen])
      end

      def test_iframe_attrs_for_youtube_videos
        @product = create_product(
          name: "test",
          videos: [{ embed_code: youtube_embed, display_option: "embedded" }]
        )

        view_model = ProductVideoViewModel.wrap(@product.videos.first)
        assert_equal("https://www.youtube.com/embed/rSGnNMnvM6M?enablejsapi=1&autoplay=0&loop=0&videoId=youtube-rSGnNMnvM6M", view_model.iframe_attrs[:src])
        assert(view_model.iframe_attrs[:data].key?(:youtube_api))
      end

      def test_iframe_attrs_for_youtube_video
        @product = create_product(
          name: "vimeo test",
          videos: [{ embed_code: vimeo_embed, display_option: "embedded" }]
        )

        view_model = ProductVideoViewModel.wrap(@product.videos.first)
        assert_equal("153825647", view_model.iframe_attrs[:id])
        assert_equal("padding-bottom: 56.25%", view_model.iframe_attrs[:container_style])
        assert_equal("https://player.vimeo.com/video/153825647?api=1&autoplay&loop&player_id=153825647", view_model.iframe_attrs[:src])
        assert_equal("", view_model.iframe_attrs[:webkitallowfullscreen])
        assert_equal("", view_model.iframe_attrs[:mozallowfullscreen])
        assert(view_model.iframe_attrs[:data].key?(:vimeo_api))
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-product_videos-1.3.0 test/view_models/workarea/storefront/product_video_view_model_test.rb
workarea-product_videos-1.2.3 test/view_models/workarea/storefront/product_video_view_model_test.rb
workarea-product_videos-1.2.2 test/view_models/workarea/storefront/product_video_view_model_test.rb