node-ip2region
node-ip2region copied to clipboard
I've reviewed the test results and made some improvements to branch c…
…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()andsearchLong()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.
- I added tests for
- IPv6:
- I added tests for
parseResult()to handle IPv4-style results whenthis.ipv4instance is not available (expecting null). - I also added tests for specific edge cases in city string parsing logic within
parseResult().
- I added tests for
- Main Library (index.ts):
- I added tests for
searchRaw()to explicitly verify null output for invalid IP strings with bothparse=trueandparse=false.
- I added tests for
These changes increase the robustness of the test suite and ensure more code paths are verified.