Skip to content

Improve mathUtils.test.js - Better Coverage & Maintainability #209

@SophiaLi20

Description

@SophiaLi20

Hey ,
I’d like to propose some improvements to mathUtils.test.js to enhance its test coverage, maintainability, and robustness. Before opening a PR, I’d love to get your thoughts on these changes.

Proposed Changes:
Refactor toDirection tests using test.each - This makes test cases cleaner and reduces redundancy.
Add edge case tests for invalid inputs -Ensure toDirection properly handles non-numeric values (null, undefined, NaN, strings).

Enhance calculateMidpoint tests by:

  • Handling large number of stops (performance testing).
  • Ensuring identical points return the same location correctly.
  • Standardize lon usage instead of mixing lng and lon for consistency.

Implementation Plan:

  • Refactor toDirection tests using test.each to reduce duplication.
  • Add edge case handling for invalid inputs (null, undefined, NaN).
  • Expand calculateMidpoint tests:
    Test with large datasets (1000+ stops).
    Verify identical stops return the same result.
  • Ensure consistent variable naming (lon instead of lng).

Relevant File:
mathUtils.test.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions