Skip to content

test: add unit tests for network-provider.tsx - #552

Merged
Austinaminu2 merged 1 commit into
FlowwStar:mainfrom
esthereze:test/network-provider-unit-tests
Aug 20, 2026
Merged

Austinaminu2 merged 1 commit into
FlowwStar:mainfrom
esthereze:test/network-provider-unit-tests

Conversation

@esthereze

Copy link
Copy Markdown
Contributor

Summary

Adds a comprehensive unit test suite for components/providers/network-provider.tsx, which previously had no test coverage.

Tests added (__tests__/components/network-provider.test.tsx)

18 tests across 6 describe groups:

Group What's tested
Default values Provider defaults to testnet; renders children without crashing
isMockMode true when streamContractId is empty; false when it is set
Context consumption Consumers read network and config.rpcUrl correctly via context
setNetwork Switches to mainnet, config updates, can switch back to testnet
localStorage persistence Saves on setNetwork; reads saved value on mount; ignores invalid values; updates on re-switch
useNetwork error boundary Throws with clear message outside a provider; does not throw inside one
Hook return shape Returns network, setNetwork, config, isMockMode with correct types

Verification

All 18 new tests pass. The 8 pre-existing failures in unrelated files are unchanged.

Closes #531

- 18 tests covering:
  - Default network value ('testnet')
  - Children rendering
  - isMockMode true/false based on streamContractId
  - Context consumption (network name, config.rpcUrl)
  - setNetwork switching testnet ↔ mainnet
  - localStorage persistence (save, read, ignore invalid, update)
  - useNetwork throws outside provider
  - useNetwork does not throw inside provider
  - Hook return shape (network, setNetwork, config, isMockMode)

Closes FlowwStar#531
@Austinaminu2
Austinaminu2 merged commit 154c349 into FlowwStar:main Aug 20, 2026
0 of 6 checks passed

This branch had an error being deployed

1 failed deployment
staging — a859616c Deployed Aug 18, 2026 by esthereze via deploy-staging #150
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.

Add unit tests for components/providers/network-provider.tsx

2 participants