From d927fe03ddc068c43b4a44910008bf2fff2080c3 Mon Sep 17 00:00:00 2001 From: Alexander Sandor Date: Fri, 14 Feb 2025 15:28:35 +0100 Subject: [PATCH 1/3] test: Add test to validate wrap around in select list works. --- test/prompts/multiple_select_test.dart | 30 ++++++++++++++++++++++++++ test/prompts/select_test.dart | 25 +++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/test/prompts/multiple_select_test.dart b/test/prompts/multiple_select_test.dart index 6177154..16d2b64 100644 --- a/test/prompts/multiple_select_test.dart +++ b/test/prompts/multiple_select_test.dart @@ -245,4 +245,34 @@ ${underline('(●) Option 2')} Press [Space] to toggle selection, [Enter] to confirm. '''); }); + + test( + 'Given multiple select prompt with multiple options ' + 'when moving past the last option and pressing Enter ' + 'then first option is selected', () async { + late Future> result; + var options = [Option('Option 1'), Option('Option 2'), Option('Option 3')]; + + await collectOutput( + keyInputs: [ + ...arrowDownSequence, // Move to Option 2 + ...arrowDownSequence, // Move to Option 3 + ...arrowDownSequence, // Move to Option 1 + KeyCodes.space, // Select Option 1 + KeyCodes.enterCR + ], + () { + result = multiselect( + 'Choose multiple options:', + options: options, + logger: logger, + ); + }, + ); + + await expectLater( + result, + completion(containsAllOptions([Option('Option 1')])), + ); + }); } diff --git a/test/prompts/select_test.dart b/test/prompts/select_test.dart index b615726..b492693 100644 --- a/test/prompts/select_test.dart +++ b/test/prompts/select_test.dart @@ -173,4 +173,29 @@ ${underline('(●) Option 2')} Press [Enter] to confirm. '''); }); + + test( + 'Given select prompt with multiple options ' + 'when moving past the last option ' + 'then should wrap around to the first option', () async { + late Future