Skip to content

Add unit tests for PasswordRulesParser.js#1112

Open
Muneerali199 wants to merge 1 commit into
apple:mainfrom
Muneerali199:add-parser-unit-tests
Open

Add unit tests for PasswordRulesParser.js#1112
Muneerali199 wants to merge 1 commit into
apple:mainfrom
Muneerali199:add-parser-unit-tests

Conversation

@Muneerali199

Copy link
Copy Markdown

Summary

Adds 65 unit tests for tools/PasswordRulesParser.js, closing #98.

The test cases were adapted from the maintainer's Ruby test suite (shared in issue #98) and expanded with additional edge cases covering custom character classes, canonicalization, unicode handling, and invalid inputs.

Changes

  • tools/PasswordRulesParser.test.js: 65 unit tests covering:

    • Empty/whitespace-only input
    • All named character classes (upper, lower, digit, special, ascii-printable, unicode)
    • Multiple required/allowed rules with merging
    • max-consecutive (lowest wins), minlength (highest wins), maxlength (lowest wins)
    • Custom character classes with dash (-) and right-bracket (]) edge cases
    • Non-ASCII character dropping in custom classes
    • Canonicalization (full alphabet → named class)
    • Invalid/malformed inputs that should produce errors
    • Rule ordering after parsing
    • Whitespace tolerance around values
  • .github/workflows/lint.yml: New parser-unit-tests CI job that runs the test suite on every push/PR

Verification

65 of 65 tests passed.

Adds 65 unit tests covering:
- Empty/whitespace input
- Single and multiple required/allowed rules
- max-consecutive, minlength, maxlength
- Custom character classes (including dash/bracket edge cases)
- Unicode handling (non-ASCII characters dropped)
- Canonicalization (full alphabet → named class)
- Invalid/malformed inputs (expected errors)
- Real-world rule patterns

The test suite was adapted from the maintainer's Ruby test suite
(shared in issue apple#98) and runs via Node.js with zero dependencies.

Includes a new CI job in lint.yml to run tests on every push/PR.
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