Sha256: 9ccfd72497802b63effff86239fce98486fb38d4f3efb846b5670ced04bede4b

Contents?: true

Size: 994 Bytes

Versions: 1

Compression:

Stored size: 994 Bytes

Contents

require 'test_helper'

module Workarea
  module Storefront
    class HoverZoomTest < Workarea::SystemTest
      include BreakpointHelpers

      def test_setup_zoom_image_on_desktop
        visit storefront.product_path(create_product)

        primary_image_link.hover
        wait_for_xhr

        assert plugin_magnify?
      end

      def test_setup_zoom_image_on_mobile
        resize_window_to('small')
        visit storefront.product_path(create_product)

        wait_for_xhr

        assert plugin_zoom?
      end

      private

      def primary_image
        page.find('.product-details__primary-image')
      end

      def primary_image_link
        primary_image.find('a')
      end

      def plugin_magnify?
        has_class?(primary_image, 'hover-zoom--magnify')
      end

      def plugin_zoom?
        has_class?(primary_image, 'hover-zoom--zoom')
      end

      def has_class?(element, klass)
        element[:class].split.include?(klass)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
workarea-hover_zoom-3.0.0 test/system/workarea/storefront/hover_zoom_test.rb