Sha256: 80416288d817c941b81010bbf4a110a673dbff8112ae4950cada1e74fa432309

Contents?: true

Size: 1.8 KB

Versions: 34

Compression:

Stored size: 1.8 KB

Contents

require 'test_helper'

module Workarea
  module Admin
    class IconsHelperTest < ViewTest
      include Admin::Engine.routes.url_helpers

      def current_user
        @user ||= create_user(admin: true)
      end

      def inline_svg(path, options = {})
        [path, *options.values]
      end

      def link_to(content, path, options = {})
        [*content, path, *options.values]
      end

      def insights_path_for(model)
        ''
      end

      def test_comments_icon_for
        page = create_page
        comment = create_comment(commentable: page)

        view_model = PageViewModel.wrap(page)
        result = comments_icon_for(view_model)

        assert_equal('workarea/admin/icons/comments.svg', result.first)
        assert_equal(t('workarea.admin.comments.icon.unviewed'), result.second)

        comment.update(viewed_by_ids: [current_user.id])

        view_model = PageViewModel.wrap(page)
        result = comments_icon_for(view_model)

        assert_equal('workarea/admin/icons/comments_viewed.svg', result.first)
        assert_equal(t('workarea.admin.comments.icon.viewed'), result.second)
      end

      def test_top_icon_for
        product = create_product
        assert_nil(top_icon_for(ProductViewModel.wrap(product)))

        create_top_products(results: [{ product_id: product.id }])
        result = top_icon_for(ProductViewModel.wrap(product))
        assert_equal('workarea/admin/icons/star.svg', result.first)
      end

      def test_trending_icon_for
        product = create_product
        assert_nil(trending_icon_for(ProductViewModel.wrap(product)))

        create_trending_products(results: [{ product_id: product.id }])
        result = trending_icon_for(ProductViewModel.wrap(product))
        assert_equal('workarea/admin/icons/fire.svg', result.first)
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-admin-3.4.45 test/helpers/workarea/admin/icons_helper_test.rb
workarea-admin-3.4.44 test/helpers/workarea/admin/icons_helper_test.rb
workarea-admin-3.4.43 test/helpers/workarea/admin/icons_helper_test.rb
workarea-admin-3.4.42 test/helpers/workarea/admin/icons_helper_test.rb
workarea-admin-3.4.41 test/helpers/workarea/admin/icons_helper_test.rb
workarea-admin-3.4.40 test/helpers/workarea/admin/icons_helper_test.rb
workarea-admin-3.4.39 test/helpers/workarea/admin/icons_helper_test.rb
workarea-admin-3.4.38 test/helpers/workarea/admin/icons_helper_test.rb
workarea-admin-3.4.37 test/helpers/workarea/admin/icons_helper_test.rb
workarea-admin-3.4.36 test/helpers/workarea/admin/icons_helper_test.rb
workarea-admin-3.4.35 test/helpers/workarea/admin/icons_helper_test.rb
workarea-admin-3.4.34 test/helpers/workarea/admin/icons_helper_test.rb
workarea-admin-3.4.33 test/helpers/workarea/admin/icons_helper_test.rb
workarea-admin-3.4.32 test/helpers/workarea/admin/icons_helper_test.rb
workarea-admin-3.4.31 test/helpers/workarea/admin/icons_helper_test.rb
workarea-admin-3.4.30 test/helpers/workarea/admin/icons_helper_test.rb
workarea-admin-3.4.29 test/helpers/workarea/admin/icons_helper_test.rb
workarea-admin-3.4.28 test/helpers/workarea/admin/icons_helper_test.rb
workarea-admin-3.4.27 test/helpers/workarea/admin/icons_helper_test.rb
workarea-admin-3.4.26 test/helpers/workarea/admin/icons_helper_test.rb