Skip to content

test(filter): cover matching and selection helpers - #1108

Open
Qalipso wants to merge 1 commit into
charmbracelet:mainfrom
Qalipso:filter_test_coverage
Open

test(filter): cover matching and selection helpers#1108
Qalipso wants to merge 1 commit into
charmbracelet:mainfrom
Qalipso:filter_test_coverage

Conversation

@Qalipso

@Qalipso Qalipso commented Jul 28, 2026

Copy link
Copy Markdown

The filter package is at 9.5% statement coverage. Most of it is the bubbletea View/Update loop, but the matching and selection helpers underneath are plain functions and struct methods that can be tested without a terminal.

This adds tests for:

  • matchAll and exactMatches, including case-insensitive matching, the empty search, the preserved choice index, and that the first occurrence of the search term is the one reported
  • CursorUp/CursorDown: stepping, wrapping at both ends, the reversed-list behaviour, and the no-matches guard
  • ToggleSelection, including that it stops at limit
  • selectAll (stops at limit, does not double count an already selected item) and deselectAll
  • defaultKeymap/ShortHelp/FullHelp

Coverage goes from 9.5% to 28.3%. The remainder is View, Update and Run, which need a TTY. No non-test code is changed; go vet and go test -race pass.

The filter package was at 9.5% statement coverage. This covers the parts
that do not need a terminal: matchAll, exactMatches, the cursor movement
and wrapping (including reversed lists), selection toggling and its
limit, selectAll/deselectAll, and defaultKeymap.

Coverage goes from 9.5% to 28.3%. No non-test code is changed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant