Skip to content

test(insurance): expand unit coverage for surcharge merge/generator guards (W-23217457)#174

Open
offlineforce wants to merge 1 commit into
mainfrom
test/insurance-merge-generator-unit-coverage
Open

test(insurance): expand unit coverage for surcharge merge/generator guards (W-23217457)#174
offlineforce wants to merge 1 commit into
mainfrom
test/insurance-merge-generator-unit-coverage

Conversation

@offlineforce

Copy link
Copy Markdown
Collaborator

Summary

Test-only follow-up to PR #168 (surcharge-merge hardening, now on main). Adds automated unit coverage for guard branches and exported collectors that previously had no direct tests. No source files are touched.

What's added (test/shared/insurance/insurance-rule-generator.test.ts)

  • collectEmittedAttributes (new block): returns sanitized attribute names; excludes attributes of conditions dropped by unknown operators or by the safe-literal guard; falls back to sanitized contextTagName.
  • collectAttributeTypes (new block): dataType→CML-type mapping (Number→int, Percent/Currency→decimal, Boolean→boolean, Date→date, String→string); unknown/missing→string; conflicting dataTypes downgrade to string; keys by raw attribute name.
  • buildConstraintDeclaration (added cases): leading-plus numeric literal rejected (+123true); clean ISO datetime accepted through Date Equals; format-only date limitation pinned (2020-13-45 passes shape check); multi-value In drops when any value is unsafe, and a clean multi-value In expands correctly.

Test plan

  • yarn mocha test/shared/insurance/insurance-rule-generator.test.ts — passing locally (86 tests).
  • Full insurance suite green; ESLint clean.
  • Pre-push hook (lint + tests) passed.

@W-23217457@

…@W-23217457@)

Add direct unit tests for two exported collectors that previously had
zero direct coverage, plus uncovered branches of the safe-literal guards
that back the #168 surcharge-merge hardening (now on main):

- collectEmittedAttributes: sanitized output, exclusion of conditions
  dropped by unknown operators / the safe-literal guard, contextTagName
  fallback.
- collectAttributeTypes: dataType->CML-type mapping, unknown/missing
  fallback to string, conflict downgrade to string, raw-name keying.
- buildConstraintDeclaration: leading-plus numeric rejection, clean ISO
  datetime acceptance, format-only date limitation, multi-value In
  heterogeneous-safety drop + clean-expansion regression guard.

Test-only change; no source files touched.
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