# frozen_string_literal: true require 'test_helper' class CardTest < ActionView::TestCase include UiBibz::Helpers::Ui::CoreHelper test 'create card' do actual = ui_card do 'test' end expected = '
test
' assert_equal expected, actual end test 'card status' do actual = ui_card 'test', status: :primary expected = '
test
' assert_equal expected, actual end test 'card outline' do actual = ui_card 'test', status: :success, outline: true do |c| c.header 'header' c.body 'header' c.footer 'header' end expected = '
header
test
header
' assert_equal expected, actual end test 'create card with image, list and body' do actual = ui_card(tap: true) do |c| c.image 'image.svg' c.body do 'test' end c.list_group do |lg| lg.list 'Cras justo odio' lg.list 'Dapibas ac facilisis in' lg.list 'vestibulum at eros' end c.body do link_to 'Card link', '#', class: 'card-link' link_to 'Card link', '#', class: 'card-link' end end expected = '
test
Card link
' assert_equal expected, actual end test 'create card with header, body and footer' do actual = ui_card tap: true, class: 'state' do |p| p.header 'state', glyph: 'eye' p.body 'state' p.footer 'state' end expected = "
state
state
state
" assert_equal expected, actual end test 'position' do actual = ui_card text: { position: :right, size: :md } do |p| p.body do |b| b.title 'Special title treatment' b.subtitle 'The subtitle' b.text 'With supporting text below as a natural lead-in to additional content.' b.link 'Go somewhere', url: '#go-somewhere', class: 'btn btn-primary' end end expected = "
Special title treatment
The subtitle

With supporting text below as a natural lead-in to additional content.

Go somewhere
" assert_equal expected, actual end test 'create card group' do actual = ui_card_group do |cg| cg.card 'test 1', body: true cg.card 'test 2', body: true cg.card 'test 3', body: true end expected = '
test 1
test 2
test 3
' assert_equal expected, actual end test 'create card deck' do actual = ui_card_deck do |cg| cg.card 'test 1', body: true cg.card 'test 2', body: true cg.card 'test 3', body: true end expected = '
test 1
test 2
test 3
' assert_equal expected, actual end test 'create card column' do actual = ui_card_column do |cg| cg.card 'test 1', body: true cg.card 'test 2', body: true cg.card 'test 3', body: true end expected = '
test 1
test 2
test 3
' assert_equal expected, actual end test 'card list group' do actual = ui_card do |c| c.list_group do |lg| lg.list 'list 1' lg.list 'list 2' lg.list 'list 3' end end expected = '
' assert_equal expected, actual end test 'card body parameters' do actual = ui_card do |c| c.body do |b| b.title 'title' b.text 'text' b.link 'link', url: '#' end end expected = '
title

text

link
' assert_equal expected, actual end test 'card tab' do actual = ui_card tabbed: true do |c| c.header do |h| h.tab_group do |cg| cg.tab 'link1', url: '#link1' cg.tab 'link2', url: '#link2' end end c.body tab_pan: "link1", state: :active c.body tab_pan: "link2" end expected = "
" assert_equal expected, actual end test 'card row' do actual = ui_card do |c| c.row class: "g-0" do |r| r.col num: 4 do |col| col.image "https://picsum.photos/700/200", position: :left end r.col num: 8 do |col| col.body do |b| b.title "card title" b.subtitle "card subtitle" b.text "some quick example text to build on the card title and make up the bulk of the card's content." end end end end expected = "
card title
card subtitle

some quick example text to build on the card title and make up the bulk of the card's content.

" assert_equal expected, actual end test "card with html" do actual = ui_card do |c| c.html "content" c.html do " content 2" end end expected = "
content content 2
" assert_equal expected, actual end end