Sha256: bb7a02dab9b8493337c9ff5496537b303a1f164424fcf2a9f71307165670de5b

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 KB

Contents

require 'test_helper'

module Components

  class CommandButtonTest < ActiveSupport::TestCase

    def assigns
      {}
    end

    def helpers
      mock_action_view do
        def twiddle_widget_path(id)
          "/widgets/#{id}/twiddle"
        end
      end
    end

    def command_button(*args)
      arbre(widget: widgets(:one)) {
        command_button(*args)
      }
    end

    test "command button creates a form with a submit button having the correct name and correct data attributes" do
      assert_match /form.*action="\/widgets\/\d+\/twiddle"/, command_button(:twiddle, resource_name: :widget)
      assert_match /input data-command="Twiddle" type="submit" value="Twiddle"/, command_button(:twiddle, resource_name: :widget)
    end

    def command_button_list(*args)
      arbre(widget: widgets(:one)) {
        command_button_list(*args)
      }
    end

    test "command_button_list creates a list of command buttons" do
      assert_match /ul class="command-button-list"/, command_button_list(:widget)
      assert_match /li.*<form.*\<\/li>/, command_button_list(:widget).split("\n").join
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
express_admin-1.7.11 test/dummy/test/components/command_button_test.rb
express_admin-1.7.10 test/dummy/test/components/command_button_test.rb
express_admin-1.7.9 test/dummy/test/components/command_button_test.rb
express_admin-1.7.8 test/dummy/test/components/command_button_test.rb
express_admin-1.7.7 test/dummy/test/components/command_button_test.rb