test: improve coverage for utils, SyncConfig, and Waf#698
Merged
Conversation
Pure test additions (no production code changed). - 248 → 287 tests - Branches: 73.25% → 75.67% (+2.42%) - SyncConfig: 92% → 100% on every metric - Waf: branches 80.7% → 87.71% - utils: branches 75% → 95% Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pure test additions (no production code changed).
PR description: improve test coverage on utils, SyncConfig, and Waf
What
Targeted unit-test additions for the lowest-coverage files in the codebase.
Pure test additions — no production code changes.
Results
Per-file improvements:
src/resources/SyncConfig.tssrc/resources/Waf.tssrc/utils.tsWhat's new
src/__tests__/utils.test.ts(+26 tests)parseDuration: every supported time unit (y,q,M,w,d,h,m,s,ms), the number-input branch, default-to-hours behavior, and descriptive error pathsparseDateTimeOrDuration: explicit day/week duration casesgetHostedZoneName/getWildCardDomainName: two-part and deep-subdomain edge casestoCfnKeys(previously untested): top-level capitalization, recursion, idempotency on already-capitalized keys, primitive scalarswait: fake-timer-driven verificationsrc/__tests__/syncConfig.test.ts(new file, 6 tests)undefinedwhen nosyncblock is presentVERSION+OPTIMISTIC_CONCURRENCYwhen sync is enabled with no fields setNONEconflict detection short-circuits (no handler emitted)LAMBDAhandler with explicitfunctionArnLAMBDAhandler with inline function definitionAUTOMERGEhandlersrc/__tests__/waf.test.ts(+7 tests in a new "Edge cases" group)defaultAction(not just'Allow' | 'Block')${apiName}Waf)enabled: falseshort-circuits even when rules are presentrulesarray doesn't crashNotes for reviewers
A few tests document existing quirks rather than introduce assertions about
ideal behavior, with explanatory comments inline:
toCfnKeys({ value: null })returns{ Value: {} }because theisRecordhelper relies on
typeof null === 'object'. Pinned down so any futurerefactor of
isRecordis intentional.1q→P3M).1year/1yearsregex branch inparseDurationis unreachablevia the outer regex — only
1yever hits the auto-fix path. Documentedvia test omission and an inline comment in the code, not "fixed", since
that would be a behavior change inappropriate for a test-only PR.
Verification
npm test— 287/287 passingnpm run lint— cleannpm run build— cleannpx jest --coverageconfirms numbers aboveNot in scope
src/index.ts(67% statements, ~33% uncovered) — the uncovered code is theAWS CLI command handlers that talk to AppSync/CloudFormation/CloudWatch.
Bringing those to high coverage requires SDK mocking (probably
aws-sdk-client-mock), which is a substantial effort better trackedseparately.
src/resources/Api.tsremaining ~15% — would require either expandedsnapshot tests or refactoring; not as high-leverage as the Waf/SyncConfig
gains in this PR.