Sha256: 3c1130fbf99cc8d4282255e357e16ce9f7f1a39bde4dd999369c0cc7601c4c21

Contents?: true

Size: 1.84 KB

Versions: 3

Compression:

Stored size: 1.84 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\"><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\"><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\"><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

3 entries across 3 versions & 1 rubygems

Version Path
ui_bibz-2.0.2 test/ui/core/forms/choices/choice_group_test.rb
ui_bibz-2.0.1 test/ui/core/forms/choices/choice_group_test.rb
ui_bibz-2.0.0 test/ui/core/forms/choices/choice_group_test.rb