Sha256: 164094f421187bd813186664b08998acf6611553d660b3e21b658fa5b2872347

Contents?: true

Size: 1.89 KB

Versions: 34

Compression:

Stored size: 1.89 KB

Contents

require 'test_helper'

class ChoiceGroupTest < ActionView::TestCase
  include UiBibz::Helpers::Ui::CoreHelper

  test 'Choice group checkbox' do
    actual   = ui_choice_group do |bc|
      bc.choice 'Checkbox 1'
      bc.choice 'Checkbox 2', state: :active
    end
    expected = "<div data-toggle=\"buttons\" class=\"btn-group button-choice btn-group-toggle\"><label class=\"btn-secondary btn checkbox\"><input type=\"checkbox\" autocomplete=\"off\" />Checkbox 1</label><label class=\"active btn-secondary btn checkbox\" aria-pressed=\"true\"><input type=\"checkbox\" autocomplete=\"off\" checked=\"checked\" />Checkbox 2</label></div>"

    assert_equal expected, actual
  end

  test 'Choice group radio' do
    actual = ui_choice_group type: :radio do |bc|
      bc.choice 'Radio 1'
      bc.choice 'Radio 2', state: :active
    end
    expected = "<div data-toggle=\"buttons\" class=\"btn-group button-choice btn-group-toggle\"><label class=\"btn-secondary btn radio\"><input type=\"radio\" autocomplete=\"off\" />Radio 1</label><label class=\"active btn-secondary btn radio\" aria-pressed=\"true\"><input type=\"radio\" autocomplete=\"off\" checked=\"checked\" />Radio 2</label></div>"

    assert_equal expected, actual
  end

  test 'Choice group options' do
    actual = ui_choice_group size: :lg, outline: true, type: :radio do |bc|
      bc.choice 'Radio 1', glyph: 'diamond', status: :primary
      bc.choice 'Radio 2', state: :active
    end
    expected = "<div data-toggle=\"buttons\" class=\"btn-group btn-group-lg button-choice btn-group-toggle\"><label class=\"btn-outline-primary btn btn-lg radio\"><input type=\"radio\" autocomplete=\"off\" /><i class=\"glyph fas fa-diamond\"></i>  Radio 1</label><label class=\"active btn-outline-secondary btn btn-lg radio\" aria-pressed=\"true\"><input type=\"radio\" autocomplete=\"off\" checked=\"checked\" />Radio 2</label></div>"

    assert_equal expected, actual
  end

end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
ui_bibz-2.4.0 test/ui/core/forms/choices/choice_group_test.rb
ui_bibz-2.3.15 test/ui/core/forms/choices/choice_group_test.rb
ui_bibz-2.3.14 test/ui/core/forms/choices/choice_group_test.rb
ui_bibz-2.3.13 test/ui/core/forms/choices/choice_group_test.rb
ui_bibz-2.3.12 test/ui/core/forms/choices/choice_group_test.rb
ui_bibz-2.3.11 test/ui/core/forms/choices/choice_group_test.rb
ui_bibz-2.3.10 test/ui/core/forms/choices/choice_group_test.rb
ui_bibz-2.3.9 test/ui/core/forms/choices/choice_group_test.rb
ui_bibz-2.3.8 test/ui/core/forms/choices/choice_group_test.rb
ui_bibz-2.3.7 test/ui/core/forms/choices/choice_group_test.rb
ui_bibz-2.3.6 test/ui/core/forms/choices/choice_group_test.rb
ui_bibz-2.3.5 test/ui/core/forms/choices/choice_group_test.rb
ui_bibz-2.3.4 test/ui/core/forms/choices/choice_group_test.rb
ui_bibz-2.3.3 test/ui/core/forms/choices/choice_group_test.rb
ui_bibz-2.3.2 test/ui/core/forms/choices/choice_group_test.rb
ui_bibz-2.3.1 test/ui/core/forms/choices/choice_group_test.rb
ui_bibz-2.3.0 test/ui/core/forms/choices/choice_group_test.rb
ui_bibz-2.2.2 test/ui/core/forms/choices/choice_group_test.rb
ui_bibz-2.2.1 test/ui/core/forms/choices/choice_group_test.rb
ui_bibz-2.2.0 test/ui/core/forms/choices/choice_group_test.rb