Sha256: 90a1f1aa0c4a022309fea873709866f5a02b1411f79588984897c396d4e87e4b

Contents?: true

Size: 1.79 KB

Versions: 2

Compression:

Stored size: 1.79 KB

Contents

require 'test_helper'

module ExpressAdmin

  class IconLinkTest < ActiveSupport::TestCase

    def assigns
      {resource: resource}
    end

    def resource
      @resource ||= OpenStruct.new(
      text: 'Beer',
      title: 'beer icon',
      target: '_blank',
      right: true,
      delete: true,
      confirm: true,
      href: 'http://something.com'
      )
    end

    def helpers
      mock_action_view(assigns)
    end

    def rendered_icon_link(*args)
      arbre {
       icon_link(:beer, *args)
      }.to_s
    end

    test "renders" do
      assert rendered_icon_link
    end

    test "icon link href default is set to #" do
      assert_match /href="#"/, rendered_icon_link
    end

    test "icon-link target set to blank" do
      # binding.pry
      assert_match /target="_blank"/, rendered_icon_link(target: "#{resource[:target]}")
    end

    test "delete attribute is true" do
      assert_match /data-delete="true"/, rendered_icon_link(delete: resource[:delete])
    end

    test "confirm attribute is true" do
      assert_match /data-confirm="true"/, rendered_icon_link(confirm: resource[:confirm])
    end

    test "icon link has title set" do
      assert_match /title="beer icon"/, rendered_icon_link(title: "#{resource[:title]}")
    end

    test "icon link has accompanying text" do
      assert_match /i>\nBeer<\/a>/, rendered_icon_link(text: "#{resource[:text]}")
    end

    test "icon link has link set" do
      assert_match /href="#{resource[:href]}"/, rendered_icon_link(href: "#{resource[:href]}")
    end

    MARKUP_RIGHT = <<-HTML
<a class="icon-link" href="#">
Beer  <i class="icon ion-beer"></i>
</a>
HTML

    test "if icon-link is set to right" do
      assert_equal MARKUP_RIGHT, rendered_icon_link(text: "#{resource[:text]}", right: "#{resource[:right]}")
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
express_admin-1.4.10 test/dummy/test/components/icon_link_test.rb
express_admin-1.4.9 test/dummy/test/components/icon_link_test.rb