Skip to content

test: bring 6 packages to 100% line coverage#38

Open
ProjectAJ14 wants to merge 1 commit into
mainfrom
test-coverage-100-percent
Open

test: bring 6 packages to 100% line coverage#38
ProjectAJ14 wants to merge 1 commit into
mainfrom
test-coverage-100-percent

Conversation

@ProjectAJ14
Copy link
Copy Markdown
Contributor

Summary

  • Adds 304 tests across timer_button, html_rich_text, cli_core, connectivity_wrapper, morse_tap, and ns_utils, bringing all six to 100% line coverage.
  • Introduces small, localized test seams (@visibleForTesting hooks) and a few narrow coverage:ignore pragmas on genuinely unreachable-in-tests branches (web-only code, defensive cleanups in error catch blocks).
  • Widens three on Exception catch blocks in ns_utils to catch because json.encode throws Error-typed objects — the previous on Exception catches were dead code.

Coverage results

Package Files Coverage
timer_button 1 75/75 (100%)
html_rich_text 1 73/73 (100%)
cli_core 5 83/83 (100%)
connectivity_wrapper 9 145/145 (100%)
morse_tap 7 414/414 (100%)
ns_utils 19 488/488 (100%)

Production-code changes (minimal, test-enablers)

  • cli_core/logger_extension.dart: extracted stdoutTerminalColumnsResolver as a @visibleForTesting function pointer so tests can stub the terminal-columns lookup.
  • morse_tap/haptic_utils.dart: added @visibleForTesting debugHapticSupportedOverride so haptic paths work off-device.
  • connectivity_wrapper/connectivity_wrapper.dart: // coverage:ignore-line on the kIsWeb branch of _defaultAddresses, a sock?.destroy() cleanup that is unreachable in practice, and a timer?.cancel() that only runs when _maybeEmitStatusUpdate is passed a Timer (the one-shot Timer constructor never does).
  • ns_utils/extensions/list.dart, extensions/map.dart, extensions/context.dart, methods/conversion.dart: swap on Exception catchcatch where the thrown type is Error-typed (JsonUnsupportedObjectError, etc.).
  • ns_utils/extensions/list.dart: refactor toComaSeparatedValues so the catch is reachable (previously the initializer data = toString() threw before entering try).
  • ns_utils/utils/sizes.dart: // coverage:ignore-line on the private Sizes._() constructor.

Remaining work (not in this PR)

5 packages still need coverage work: ns_firebase_utils, ns_intl_phone_input, dzod, nonstop_cli, contact_permission.

Test plan

  • cd packages/timer_button && flutter test — 31 tests pass
  • cd packages/html_rich_text && flutter test — 21 tests pass
  • cd packages/cli_core && dart test — 27 tests pass
  • cd packages/connectivity_wrapper && flutter test — 57 tests pass
  • cd packages/morse_tap && flutter test — 70 tests pass
  • cd packages/ns_utils && flutter test — 98 tests pass
  • melos lint — format + analyze clean

🤖 Generated with Claude Code

Covers timer_button, html_rich_text, cli_core, connectivity_wrapper,
morse_tap, and ns_utils. Adds 304 tests total, all passing.

Minor production adjustments to enable testing:
- cli_core: extract stdoutTerminalColumnsResolver as a @VisibleForTesting
  seam so the wrap()'s non-length branch is reachable from tests.
- morse_tap: add @VisibleForTesting debugHapticSupportedOverride on
  HapticUtils so haptic paths can be exercised off-device.
- connectivity_wrapper: narrow 3 truly-unreachable-in-tests branches
  with coverage:ignore pragmas (kIsWeb, sock?.destroy, timer?.cancel).
- ns_utils: widen 3 'on Exception catch' to 'catch' (json encoding
  errors are Error-typed so the previous catches were dead); refactor
  List.toComaSeparatedValues so the catch is reachable; mark the
  private Sizes._() constructor with coverage:ignore.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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