Sha256: 81c23677a9aa22e20100b391afa946df8da826b8c6a93ec5b6b3829ab090f1f9

Contents?: true

Size: 1.6 KB

Versions: 9

Compression:

Stored size: 1.6 KB

Contents

# frozen_string_literal: true
require 'test_helper'

require_relative '../../app/helpers/shoelace/tag_helper'

class TagHelperTest < ActionView::TestCase
  include Shoelace::TagHelper

  test "#sl_button_tag" do
    assert_dom_equal(<<~HTML, sl_button_tag { "Submit" })
      <sl-button>Submit</sl-button>
    HTML
  end

  test "#sl_button_to" do
    assert_dom_equal <<~HTML, sl_button_to("Next", "/next")
      <sl-button href="/next">Next</sl-button>
    HTML

    assert_dom_equal <<~HTML, sl_button_to("Next", "/next", class: "mt-1")
      <sl-button href="/next" class="mt-1">Next</sl-button>
    HTML

    assert_dom_equal(<<~HTML, sl_button_to("/next") { "Next" })
      <sl-button href="/next">Next</sl-button>
    HTML

    assert_dom_equal(<<~HTML, sl_button_to("/next", class: "mt-1") { "Next" })
      <sl-button href="/next" class="mt-1">Next</sl-button>
    HTML

    assert_dom_equal <<~HTML, sl_button_to("Next")
      <sl-button>Next</sl-button>
    HTML
  end

  test "#sl_icon_tag"do
    assert_dom_equal <<~HTML, sl_icon_tag("0-circle-fill")
      <sl-icon name="0-circle-fill"></sl-icon>
    HTML

    assert_dom_equal <<~HTML, sl_icon_tag("0-circle-fill", slot: "icon")
      <sl-icon name="0-circle-fill" slot="icon"></sl-icon>
    HTML
  end

  test "#sl_avatar_tag"do
    assert_dom_equal <<~HTML, sl_avatar_tag("/path/to/image.jpg")
      <sl-avatar image="/path/to/image.jpg"></sl-avatar>
    HTML

    assert_dom_equal(<<~HTML, sl_avatar_tag("/path/to/image.jpg", slot: "trigger") { "Body" })
      <sl-avatar image="/path/to/image.jpg" slot="trigger">
        Body
      </sl-avatar>
    HTML
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
shoelace-rails-0.8.0 test/helpers/tag_helper_test.rb
shoelace-rails-0.7.0 test/helpers/tag_helper_test.rb
shoelace-rails-0.6.2 test/helpers/tag_helper_test.rb
shoelace-rails-0.6.1 test/helpers/tag_helper_test.rb
shoelace-rails-0.6.0 test/helpers/tag_helper_test.rb
shoelace-rails-0.5.0 test/helpers/tag_helper_test.rb
shoelace-rails-0.4.1 test/helpers/tag_helper_test.rb
shoelace-rails-0.4.0 test/helpers/tag_helper_test.rb
shoelace-rails-0.3.0 test/helpers/tag_helper_test.rb