#19104: test(discord): improve gateway logging test coverage
channel: discord
size: XS
trusted-contributor
Cluster:
Test Coverage Enhancements
Adds 2 tests to gateway-logging.test.ts:
- formatGatewayMetrics edge cases: null, undefined, string, number, boolean, bigint, circular/unserializable objects
- No-op cleanup when emitter is undefined
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR adds two new tests to `src/discord/gateway-logging.test.ts` to improve coverage of the `attachDiscordGatewayLogging` function:
- **Metrics formatting edge cases**: Tests `formatGatewayMetrics` with `null`, `undefined`, string, number, boolean, `BigInt`, and a circular reference object. All assertions correctly match the implementation's branching logic.
- **No-op cleanup for undefined emitter**: Verifies that when no emitter is provided, the function returns a callable no-op cleanup without throwing.
Both tests follow the existing test patterns in the file, use proper mocking via `vi.mocked`, and clean up after themselves. No issues found.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge — it only adds test coverage with no changes to production code.
- The PR exclusively adds test code. All test assertions correctly match the source implementation. No production code is modified, and the tests follow established patterns in the file.
- No files require special attention.
<sub>Last reviewed commit: 375ecb6</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#15569: test: comprehensive test coverage expansion (57 new test files)
by tangcruz · 2026-02-13
76.4%
#4095: Test/add format duration tests
by TechWizard9999 · 2026-01-29
75.9%
#19095: test(discord): add unit tests for presence cache module
by Clawborn · 2026-02-17
75.9%
#11864: fix: add missing methods to BASE_METHODS for client discovery
by Yida-Dev · 2026-02-08
75.1%
#19255: feat(gateway): add WebSocket connection metrics monitoring
by Wike-CHI · 2026-02-17
75.1%
#12684: Test: add missing unit tests for src/utils modules
by shaynhornik · 2026-02-09
74.9%
#10731: fix(discord): add outer retry loop for gateway reconnect exhaustion
by Milofax · 2026-02-06
74.5%
#23139: test: fix flaky auth tests when OPENCLAW_GATEWAY_TOKEN is present
by Imccccc · 2026-02-22
74.3%
#20496: test(utils): add comprehensive unit tests for utility functions
by masifislamm · 2026-02-19
74.1%
#4086: Test/add backoff tests
by TechWizard9999 · 2026-01-29
73.8%