# frozen_string_literal: true require 'test_helper' class CardTest < ActionView::TestCase include UiBibz::Helpers::Ui::UxHelper test 'create panel' do actual = ui_panel do |p| p.header tap: true do |h| h.title 'My header' h.actions size: :sm, outline: true, status: :secondary do |a| a.button 'Minimize', glyph: 'caret-up', text: false a.button 'Options', glyph: 'cog', text: false a.button 'Close', glyph: 'Close', text: false end end p.toolbar justify: true, size: :sm do |t| t.button_group do |bg| bg.button 'Copy' bg.button 'Cut' bg.button 'Paste' end t.spacer 2 t.button_group do |bg| bg.button 'Delete' end end p.body 'Body' p.toolbar size: :sm do |t| t.button_group size: :sm do |bg| bg.button 'Add', glyph: 'plus-circle', status: :success, text: false bg.button 'Remove', glyph: 'minus-circle', status: :danger, text: false end end p.footer 'Footer' end expected = '
My header
Body
' assert_equal expected, actual end test 'panel with group' do actual = ui_panel do |p| p.header tap: true do |h| h.title 'Main panel header' end p.toolbar justify: true, size: :sm do |t| t.button_group do |bg| bg.button 'Copy' bg.button 'Cut' bg.button 'Paste' end t.spacer 2 t.button_group do |bg| bg.button 'Delete' end end p.group do |d| d.panel do |b| b.header 'Left Panel Header' b.body 'Left Panel Body' b.footer 'Left Panel Footer' end d.panel do |b| b.header 'Right Panel Header' b.body 'Right Panel Body' end end p.footer 'Main Panel Footer' end expected = '
Main panel header
Left Panel Header
Left Panel Body
Right Panel Header
Right Panel Body
' assert_equal expected, actual end test 'panel with deck' do actual = ui_panel do |p| p.header tap: true do |h| h.title 'Main panel header' end p.toolbar justify: true, size: :sm do |t| t.button_group do |bg| bg.button 'Copy' bg.button 'Cut' bg.button 'Paste' end t.spacer 2 t.button_group do |bg| bg.button 'Delete' end end p.deck do |d| d.panel do |b| b.header 'Left Panel Header' b.body 'Left Panel Body' b.footer 'Left Panel Footer' end d.panel do |b| b.header 'Right Panel Header' b.body 'Right Panel Body' end end p.footer 'Main Panel Footer' end expected = '
Main panel header
Left Panel Header
Left Panel Body
Right Panel Header
Right Panel Body
' assert_equal expected, actual end test 'panel with column' do actual = ui_panel do |p| p.header tap: true do |h| h.title 'Main panel header' end p.toolbar justify: true, size: :sm do |t| t.button_group do |bg| bg.button 'Copy' bg.button 'Cut' bg.button 'Paste' end t.spacer 2 t.button_group do |bg| bg.button 'Delete' end end p.column do |d| d.panel do |b| b.header 'Left Panel Header' b.body 'Left Panel Body' b.footer 'Left Panel Footer' end d.panel do |b| b.header 'Right Panel Header' b.body 'Right Panel Body' end end p.footer 'Main Panel Footer' end expected = '
Main panel header
Left Panel Header
Left Panel Body
Right Panel Header
Right Panel Body
' assert_equal expected, actual end end