node-ip2region icon indicating copy to clipboard operation
node-ip2region copied to clipboard

I've reviewed the test results and made some improvements to branch c…

Open yourtion opened this issue 7 months ago • 0 comments

…overage across IPv4, IPv6, and the main library.

This commit introduces new unit tests to cover previously unasserted conditional branches in the IP address lookup logic.

Key improvements:

  • IPv4:
    • I added tests for search() and searchLong() when a valid IPv4 is not found in the database ranges (expecting null, though the current DB has a catch-all).
    • I also added a test for successful instantiation with an absolute DB path.
  • IPv6:
    • I added tests for parseResult() to handle IPv4-style results when this.ipv4 instance is not available (expecting null).
    • I also added tests for specific edge cases in city string parsing logic within parseResult().
  • Main Library (index.ts):
    • I added tests for searchRaw() to explicitly verify null output for invalid IP strings with both parse=true and parse=false.

These changes increase the robustness of the test suite and ensure more code paths are verified.

yourtion avatar May 21 '25 13:05 yourtion