Skip to content

test(repository): settings_repository (+16 tests)#348

Merged
TaprootFreak merged 1 commit into
developfrom
test/api-exception-hierarchy
May 15, 2026
Merged

test(repository): settings_repository (+16 tests)#348
TaprootFreak merged 1 commit into
developfrom
test/api-exception-hierarchy

Conversation

@TaprootFreak
Copy link
Copy Markdown
Contributor

Summary

Stage 24 of the coverage push. The `SettingsRepository` wraps SharedPreferences and is one of the few storage-adjacent files that can be tested directly via `SharedPreferences.setMockInitialValues`.

Group Cases
currentWalletId 3
language 3
currency 3
terms (terms + softwareTerms) 3
networkMode 4

What each group covers

  • currentWalletId: null when not stored; `saveCurrentWalletId` persists; `removeCurrentWalletId` clears.
  • language: falls back to `'en'` for non-German system locales (PlatformDispatcher locale in tests is en_US); returns stored value when set; setter persists.
  • currency: defaults to `'CHF'` when not stored; returns stored value; setter persists.
  • terms: both `termsAccepted` and `softwareTermsAccepted` default to false; setters persist; setting one does not flip the other (independent flags).
  • networkMode: defaults to mainnet when no value AND when stored value is unknown (`firstWhere`'s `orElse`); reads via the enum constructor argument name (`'Mainnet'` / `'Testnet'`) — not the Dart enum identifier (this trap surfaced during the tests because the production code uses `.name` and the constructor arg shadows it); setter persists.

Test plan

  • `flutter analyze` clean
  • `flutter test` — 16 / 16 passing locally
  • CI green

Stage 24 of the coverage push. The SettingsRepository wraps
SharedPreferences and is one of the few storage-adjacent files that
can be tested directly via SharedPreferences.setMockInitialValues.

- currentWalletId (3): null when not stored; save persists;
  remove clears
- language (3): falls back to 'en' for non-German system locales,
  returns stored value, setter persists
- currency (3): defaults to CHF, returns stored value, setter persists
- terms (3): both flags default to false, each setter persists
  independently
- networkMode (4): defaults to mainnet (no value + unknown value),
  reads under the enum constructor name (NOT the Dart identifier —
  the .name getter is shadowed by the constructor arg 'Mainnet' /
  'Testnet'), setter persists
@TaprootFreak TaprootFreak marked this pull request as ready for review May 15, 2026 12:44
@TaprootFreak TaprootFreak merged commit 4d284bf into develop May 15, 2026
1 check passed
@TaprootFreak TaprootFreak deleted the test/api-exception-hierarchy branch May 15, 2026 12:44
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