Skip to content

test(edge): edge cases and regression tests #68

@wazolab

Description

@wazolab

Parent

Part of the Testing & Code Quality milestone. Related to #30.

Description

Add edge case and regression tests to harden the library against unexpected inputs and state transitions. These tests prevent future regressions as the codebase evolves.

Edge cases to cover

Case Expected behavior
Empty feature collection (no features from source) No markers created, no errors, stale markers cleaned up
Non-Point geometry feature `console.error` logged, feature skipped, rendering continues
Cluster with 0 leaves (empty cluster) `console.error` logged, cluster skipped
`loadClusterLeaves` rejection (source error) Returns `false`, logs warning, rendering aborted gracefully
Feature with duplicate IDs in source Last feature wins in `featuresMap`, no crash
Rapid consecutive `moveend` events Only the final render completes (abort counter works)
`onRemove` called before `onAdd` No-op, no error
`setSelectedFeature` called before `onAdd` Pin marker placed at coordinates (no map interaction)
`resetSelectedFeature` when no selection exists No-op, no error
Cluster with leaves exactly at `unfoldedClusterMaxLeaves` Renders as unfolded (boundary condition)
Zoom exactly at `clusterMaxZoom` All clusters unfold regardless of leaf count
Zoom exactly at `clusterMinZoom` Clusters start unfolding
`getFeatureId` with `properties.id = 0` Returns `"0"`, not falsy
`getFeatureId` with neither metadata.id nor properties.id Currently throws TypeError — document and/or fix
`deepMerge` with `null` values in source Should replace target value with `null`

Acceptance Criteria

  • All edge cases listed above have corresponding tests
  • No test relies on implementation details (test behavior, not internals)
  • Each edge case test is documented with a comment explaining the scenario
  • `yarn test` passes
  • `yarn coverage` shows meaningful improvement

Files Likely Involved

  • `tests/edge-cases.test.ts` (new)
  • `tests/utils/deep-merge.test.ts` (extend)
  • `tests/utils/index.test.ts` (extend)

Dependencies

Parallelizable

no — final tier, builds on all prior test infrastructure

Metadata

Metadata

Assignees

No one assigned

    Labels

    testWrite or update test files

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions