From ef6eba1b89c009b3dfd8ae76c9cf6ed18c50288e Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sat, 18 Apr 2026 13:10:40 +0900 Subject: [PATCH] Add a test case for click-header with --header and --header-lines combined The two sections swap order between layouts, and header-lines are reversed under layout=default, so expected LINE values differ per layout. --- test/test_layout.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/test_layout.rb b/test/test_layout.rb index 6f2c029c..2a521bf6 100644 --- a/test/test_layout.rb +++ b/test/test_layout.rb @@ -1372,5 +1372,25 @@ class TestLayout < TestInteractive input: 'seq 5', clicks: [%w[Foo 1], %w[Bar 2], %w[Baz 3]]) end + + # --header and --header-lines combined. Click-header numbering concatenates the two + # sections, but the order depends on the layout: + # layoutReverse: custom header (1..N), then header-lines (N+1..N+M) + # layoutDefault: header-lines (1..M, reversed visually), then custom header (M+1..M+N) + # layoutReverseList: header-lines (1..M), then custom header (M+1..M+N) + define_method(:"test_click_header_combined_#{slug}") do + clicks = case layout + when 'reverse' + [%w[Aaa 1], %w[Bbb 2], %w[Ccc 3], %w[Xaa 4], %w[Ybb 5], %w[Zcc 6]] + when 'default' + [%w[Aaa 4], %w[Bbb 5], %w[Ccc 6], %w[Xaa 3], %w[Ybb 2], %w[Zcc 1]] + else # reverse-list + [%w[Aaa 4], %w[Bbb 5], %w[Ccc 6], %w[Xaa 1], %w[Ybb 2], %w[Zcc 3]] + end + verify_clicks(kind: :header, + opts: %(--layout=#{layout} --header $'Aaa\\nBbb\\nCcc' --header-lines 3), + input: "(printf 'Xaa\\nYbb\\nZcc\\n'; seq 5)", + clicks: clicks) + end end end