Skip to content

fix: add null safeguard and source-asymmetry test for buildVehiclePopupData#511

Open
VishalRaut2106 wants to merge 1 commit into
OneBusAway:developfrom
VishalRaut2106:fix/vehicleUtils-null-safeguard-508
Open

fix: add null safeguard and source-asymmetry test for buildVehiclePopupData#511
VishalRaut2106 wants to merge 1 commit into
OneBusAway:developfrom
VishalRaut2106:fix/vehicleUtils-null-safeguard-508

Conversation

@VishalRaut2106

@VishalRaut2106 VishalRaut2106 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

This PR addresses the two follow-up suggestions from the maintainer regarding buildVehiclePopupData edge cases.

Changes

  1. Null Safeguard: Added optional chaining (activeTrip?.tripHeadsign) inside buildVehiclePopupData so that if activeTripMap.get(...) ever returns undefined, the code gracefully returns undefined instead of throwing a fatal TypeError.
  2. Asymmetry Test: Added a new test in vehicleUtils.test.js where vehicle and activeTrip have identically-named properties with different values. This explicitly proves that the helper is pulling data from the correct source object.
  3. Null-State Test: Added a test that passes undefined for activeTrip to guarantee the optional chaining correctly prevents crashes.

Closes #508

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage is 81.05%VishalRaut2106:fix/vehicleUtils-null-safeguard-508 into OneBusAway:develop. No base build found for OneBusAway:develop.

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.

Follow-up: harden buildVehiclePopupData tests and guard against null activeTrip

2 participants