mirror of
https://github.com/we-promise/sure.git
synced 2026-05-30 07:49:01 +00:00
DS::SelectableCard — a checkbox rendered as a selectable card (whole card toggles; brand-accent border + bg-surface when selected via peer-checked on the sibling). Submits like a normal checkbox, so the bucket's replace-all form is unchanged. Lookbook preview + component test. Retirement bucket now renders each account as a DS::SelectableCard (name · type · balance) instead of a bare checkbox row. Money stays privacy-sensitive.
26 lines
925 B
Ruby
26 lines
925 B
Ruby
require "test_helper"
|
|
|
|
class DS::SelectableCardTest < ViewComponent::TestCase
|
|
test "renders a checkbox with title, subtitle, amount" do
|
|
render_inline(DS::SelectableCard.new(
|
|
name: "bucket[account_ids][]", value: "a1",
|
|
title: "Brokerage", subtitle: "ETF", amount: "$100,000"
|
|
))
|
|
|
|
assert_selector "input[type=checkbox][name='bucket[account_ids][]'][value='a1']", visible: false
|
|
assert_text "Brokerage"
|
|
assert_text "ETF"
|
|
assert_text "$100,000"
|
|
end
|
|
|
|
test "checked renders the checkbox checked" do
|
|
render_inline(DS::SelectableCard.new(name: "n", value: "v", title: "T", checked: true))
|
|
assert_selector "input[type=checkbox][checked]", visible: false
|
|
end
|
|
|
|
test "unchecked omits the checked attribute" do
|
|
render_inline(DS::SelectableCard.new(name: "n", value: "v", title: "T", checked: false))
|
|
assert_no_selector "input[type=checkbox][checked]", visible: false
|
|
end
|
|
end
|