-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #879 from opentripplanner/unchanged-files-check-an…
…notations Address unchanged files with check annotations
- Loading branch information
Showing
3 changed files
with
183 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
/* globals describe, expect, it */ | ||
|
||
import { | ||
getItineraryDefaultMonitoredDays, | ||
itineraryCanBeMonitored | ||
} from '../../lib/util/itinerary' | ||
import { WEEKDAYS, WEEKEND_DAYS } from '../../lib/util/monitored-trip' | ||
|
||
const walkLeg = { | ||
mode: 'WALK' | ||
} | ||
|
||
describe('util > itinerary', () => { | ||
describe('itineraryCanBeMonitored', () => { | ||
const transitLeg = { | ||
mode: 'BUS', | ||
transitLeg: true | ||
} | ||
const rentalBikeLeg = { | ||
mode: 'BICYCLE_RENT', | ||
rentedBike: true | ||
} | ||
const rentalCarLeg = { | ||
mode: 'CAR_RENT', | ||
rentedCar: true | ||
} | ||
const rentalMicromobilityLeg = { | ||
mode: 'MICROMOBILITY_RENT', | ||
rentedVehicle: true | ||
} | ||
const rideHailLeg = { | ||
hailedCar: true, | ||
mode: 'CAR_HAIL' | ||
} | ||
|
||
const testCases = [ | ||
{ | ||
expected: true, | ||
itinerary: { | ||
legs: [transitLeg, walkLeg] | ||
}, | ||
title: | ||
'should be true for an itinerary with transit, no rentals/ride hail.' | ||
}, | ||
{ | ||
expected: false, | ||
itinerary: { | ||
legs: [walkLeg, rentalBikeLeg] | ||
}, | ||
title: 'should be false for an itinerary without transit.' | ||
}, | ||
{ | ||
expected: false, | ||
itinerary: { | ||
legs: [walkLeg, transitLeg, rentalBikeLeg] | ||
}, | ||
title: 'should be false for an itinerary with transit and rental bike.' | ||
}, | ||
{ | ||
expected: false, | ||
itinerary: { | ||
legs: [walkLeg, transitLeg, rentalCarLeg] | ||
}, | ||
title: 'should be false for an itinerary with transit and rental car.' | ||
}, | ||
{ | ||
expected: false, | ||
itinerary: { | ||
legs: [walkLeg, transitLeg, rentalMicromobilityLeg] | ||
}, | ||
title: | ||
'should be false for an itinerary with transit and rental micromobility.' | ||
}, | ||
{ | ||
expected: false, | ||
itinerary: { | ||
legs: [walkLeg, transitLeg, rideHailLeg] | ||
}, | ||
title: 'should be false for an itinerary with transit and ride hail.' | ||
}, | ||
{ | ||
expected: false, | ||
itinerary: {}, | ||
title: 'should be false for a blank itinerary.' | ||
}, | ||
{ | ||
expected: false, | ||
itinerary: null, | ||
title: 'should be false for a null itinerary.' | ||
} | ||
] | ||
|
||
testCases.forEach(({ expected, itinerary, title }) => { | ||
it(`${title}`, () => { | ||
expect(itineraryCanBeMonitored(itinerary)).toBe(expected) | ||
}) | ||
}) | ||
}) | ||
describe('getItineraryDefaultMonitoredDays', () => { | ||
const transitLegWeekday = { | ||
mode: 'BUS', | ||
serviceDate: '20210609', // Wednesday | ||
transitLeg: true | ||
} | ||
const transitLegSaturday = { | ||
mode: 'BUS', | ||
serviceDate: '20210612', // Saturday | ||
transitLeg: true | ||
} | ||
const transitLegSunday = { | ||
mode: 'BUS', | ||
serviceDate: '20210613', // Sunday | ||
transitLeg: true | ||
} | ||
|
||
const testCases = [ | ||
{ | ||
expected: WEEKDAYS, | ||
itinerary: { | ||
legs: [walkLeg, transitLegWeekday] | ||
}, | ||
title: | ||
"should be ['monday' thru 'friday'] for an itinerary starting on a weekday." | ||
}, | ||
{ | ||
expected: WEEKEND_DAYS, | ||
itinerary: { | ||
legs: [walkLeg, transitLegSaturday] | ||
}, | ||
title: | ||
"should be ['saturday', 'sunday'] for an itinerary starting on a Saturday." | ||
}, | ||
{ | ||
expected: WEEKEND_DAYS, | ||
itinerary: { | ||
legs: [walkLeg, transitLegSunday] | ||
}, | ||
title: | ||
"should be ['saturday', 'sunday'] for an itinerary starting on a Sunday." | ||
}, | ||
{ | ||
expected: WEEKDAYS, | ||
itinerary: { | ||
legs: [walkLeg], | ||
startTime: 1623341891000 // Thursday 2021-06-10 12:18 pm EDT | ||
}, | ||
title: | ||
"should be ['monday' thru 'friday'] for an itinerary without transit starting on a weekday (fallback case)." | ||
}, | ||
{ | ||
expected: WEEKEND_DAYS, | ||
itinerary: { | ||
legs: [walkLeg], | ||
startTime: 1623514691000 // Saturday 2021-06-12 12:18 pm EDT | ||
}, | ||
title: | ||
"should be ['saturday', 'sunday'] for an itinerary without transit starting on a Saturday (fallback case)." | ||
}, | ||
{ | ||
expected: WEEKEND_DAYS, | ||
itinerary: { | ||
legs: [walkLeg], | ||
startTime: 1623601091000 // Sunday 2021-06-13 12:18 pm EDT | ||
}, | ||
title: | ||
"should be ['saturday', 'sunday'] for an itinerary without transit starting on a Sunday (fallback case)." | ||
} | ||
] | ||
|
||
testCases.forEach(({ expected, itinerary, title }) => { | ||
it(`${title}`, () => { | ||
expect(getItineraryDefaultMonitoredDays(itinerary)).toBe(expected) | ||
}) | ||
}) | ||
}) | ||
}) |