# frozen_string_literal: true require 'test_helper' class SurroundFieldTest < ActionView::TestCase test 'surround_field with glyph' do actual = UiBibz::Ui::Core::Forms::Surrounds::SurroundField.new.tap do |sf| sf.glyph 'pencil' end.render expected = '
' assert_equal expected, actual end test 'surround_field with addon' do actual = UiBibz::Ui::Core::Forms::Surrounds::SurroundField.new.tap do |sf| sf.addon 'content addon' end.render expected = '
content addon
' assert_equal expected, actual end test 'surround_field with dropdown' do actual = UiBibz::Ui::Core::Forms::Surrounds::SurroundField.new.tap do |sf| sf.dropdown 'Dropdown', {}, { id: 'dropdown-test' } do |d| d.link 'Link 1', url: '#link1', glyph: 'eye' d.header 'header' d.link 'Link 2', url: '#link2' d.divider d.link 'Link3', url: '#link3' end end.render expected = "
Link 1
header
Link 2
Link3
" assert_equal expected, actual end test 'surround_field with button' do actual = UiBibz::Ui::Core::Forms::Surrounds::SurroundField.new.tap do |sf| sf.button 'Submit' end.render expected = "
" assert_equal expected, actual end test 'surround_field with button, addon, glyph' do actual = UiBibz::Ui::Core::Forms::Surrounds::SurroundField.new.tap do |sf| sf.button 'Submit' sf.addon '€' sf.glyph 'pencil' end.render expected = "
" assert_equal expected, actual end test 'surround_field with html' do actual = UiBibz::Ui::Core::Forms::Surrounds::SurroundField.new.tap do |sf| sf.html 'Content' sf.html do " Content 2" end end.render expected = "
Content Content 2
" assert_equal expected, actual end test "surround with all fields" do actual = UiBibz::Ui::Core::Forms::Surrounds::SurroundField.new.tap do |sf| sf.glyph 'gem' sf.addon "test" sf.button "button" sf.button_group do |bg| bg.button "test" end sf.button_link "link", url: "#" sf.checkbox_field :check sf.radio_field :radio sf.text_field :text sf.date_picker_field :date sf.dropdown_select_field :dropdown_select sf.select_field :select sf.auto_complete_field :auto sf.button_refresh end.render expected = "
test
link
" assert_equal expected, actual end end