Skip to content

⏳ Add unit tests#740

Open
SusaTyrniluoto wants to merge 2 commits intoOpenVAA:mainfrom
SusaTyrniluoto:add-unit-tests
Open

⏳ Add unit tests#740
SusaTyrniluoto wants to merge 2 commits intoOpenVAA:mainfrom
SusaTyrniluoto:add-unit-tests

Conversation

@SusaTyrniluoto
Copy link

Pull Request: Add Unit Tests and Improve Core Utility Functions

These changes are implemented in the add-unit-tests branch (previously named improve-link-text-extraction).
All updates are covered with comprehensive unit tests.

Closes


What has been changed

This PR updates two core utility modules (links.ts and merge.ts) and adds thorough unit tests to ensure robust and correct behavior across various edge cases.

links.ts

  • Replaces basic domain splitting with the psl (Public Suffix List) library to correctly extract registered domain names.
  • Adds support for internationalized domains (IDNs) by decoding Punycode using the punycode library.
  • Handles edge cases such as trailing dots in hostnames.
  • Improves readability and accuracy of link labels (e.g., https://subdomain.example.co.uk → Example).
  • Unit tests added in links.test.ts.

merge.ts

  • Rewrites the deep merge logic to correctly handle:
    • Primitive values (e.g., number overwritten by object)
    • Constructed objects (e.g., Date instances preserved with .getTime())
    • Arrays (which are replaced, not merged)
    • Functions (overwritten)
    • Circular references (better error safety)
  • Adds full test coverage in merge.test.ts for flat, nested, and edge case scenarios.

Checklist

  • I have reviewed the changes myself in this PR.
  • I have added or edited unit tests.
  • I have run the unit tests successfully.
  • I have run the e2e tests successfully.
  • I have tested this change on my own device.
  • I have tested this change on other devices (Using Browserstack is recommended).
  • I have tested my changes using the WAVE extension
  • I have tested my changes using keyboard navigation and screen-reading
  • I have added documentation where necessary.
  • I have cleaned up the commit history and ensured the commits follow the guidelines

…#727)

Use Public Suffix List and punycode to accurately parse and display internationalized domains.
…jects, circular references and better error handling. Update merge.test.ts accordingly.
@kaljarv kaljarv changed the title Add unit tests ⏳ Add unit tests Aug 23, 2025
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.

Improve Deep Merge Function in merge.ts to Handle Primitives, Date Objects, and Circular References

1 participant