Sha256: e382d23ebe077937c945031e6dfccc65689d01cc6a323f61668774a087b56109

Contents?: true

Size: 1.07 KB

Versions: 25

Compression:

Stored size: 1.07 KB

Contents

require 'test_helper'

class CheckboxTest < ActiveSupport::TestCase
  def assigns
    {resource: resource}
  end

  test "checkbox places the label before the input" do
    html = arbre {
      express_form(:account) {
        checkbox :eula
      }
    }
    label = '<label for="account_eula"'
    field = 'input type="checkbox" value="1" name="account\[eula\]"'
    assert_match /#{label}/, html
    assert_match /#{field}/, html
    label_idx = html.index(label)
    field_idx = html.index(field.gsub('\\', ''))
    assert (field_idx > label_idx), "label must come first"
  end

  test "checkbox respects label_after: true " do
    html = arbre {
      express_form(:account) {
        checkbox :eula, label_after: true
      }
    }
    label = '<label for="account_eula"'
    field = 'input type="checkbox" value="1" name="account\[eula\]"'
    assert_match /#{label}/, html
    assert_match /#{field}/, html
    label_idx = html.index(label)
    field_idx = html.index(field.gsub('\\', ''))
    assert (field_idx < label_idx), "label must come after when label_after: true"
  end

end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
express_admin-1.3.2 vendor/gems/express_templates/test/components/forms/checkbox_test.rb
express_admin-1.3.1 vendor/gems/express_templates/test/components/forms/checkbox_test.rb
express_templates-0.7.1 test/components/forms/checkbox_test.rb
express_templates-0.7.0 test/components/forms/checkbox_test.rb
express_admin-1.3.0 vendor/gems/express_templates/test/components/forms/checkbox_test.rb