Skip to content

Commit

Permalink
test(Stack): use stack property instead of responsiveArg descendants
Browse files Browse the repository at this point in the history
  • Loading branch information
francinelucca committed Oct 2, 2024
1 parent fb2208c commit 7442ddb
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions test/components/alpha/stack_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,20 @@ def test_allows_customizing_tag
end

# Responsive arg tests, i.e. Stack.new(justify: [:center, :center, ...])
Primer::ResponsiveArg.descendants.each do |descendant|
# TODO: fix this (StackItem's arg)
next unless descendant.arg_name != :grow
descendant::OPTIONS.each do |option|
Primer::Alpha::Stack::ARG_CLASSES.each do |arg_class|
next unless arg_class.arg_name != :grow
arg_class::OPTIONS.each do |option|
next unless option

define_method("test_renders_responsive_arg_#{descendant.arg_name}_with_#{option}_option") do
define_method("test_renders_responsive_arg_#{arg_class.arg_name}_with_#{option}_option") do
# create a Stack for rendering, eg. Stack.new(:justify, [five-element responsive values array])
stack = Primer::Alpha::Stack.new(
descendant.arg_name => [option] * Primer::ResponsiveArg::BREAKPOINTS.size
arg_class.arg_name => [option] * Primer::ResponsiveArg::BREAKPOINTS.size
)

render_inline(stack) { "content" }

dasherized_arg = descendant.arg_name.to_s.dasherize
dasherized_arg = arg_class.arg_name.to_s.dasherize
dasherized_option = option.to_s.dasherize

assert_selector(".Stack[data-#{dasherized_arg}=\"#{dasherized_option}\"]")
Expand Down

0 comments on commit 7442ddb

Please sign in to comment.