Sha256: 88bea961c2b239d8f407e5e9602183981bde1679116d87b12973ef2a4bc28443

Contents?: true

Size: 1.84 KB

Versions: 1

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 fa 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

1 entries across 1 versions & 1 rubygems

Version Path
ui_bibz-2.0.0.beta2.6 test/ui/core/forms/choices/choice_group_test.rb