Skip to content

Commit

Permalink
fix(util/ui): Display itins as list items of no itin active and url p…
Browse files Browse the repository at this point in the history
…aram is full.
  • Loading branch information
binh-dam-ibigroup committed Oct 4, 2023
1 parent dce2cec commit 05deb14
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
22 changes: 18 additions & 4 deletions __tests__/util/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,29 @@ describe('util > ui', () => {
ItineraryView.LIST
)
})
it('returns a full itinerary view if URL contains ui_activeItinerary', () => {
it('returns a full itinerary view if URL contains ui_activeItinerary that is not -1', () => {
expect(getItineraryView({ ui_activeItinerary: 2 })).toBe(
ItineraryView.FULL
)
})
it('returns the specified view mode when set in URL', () => {
expect(getItineraryView({ ui_itineraryView: 'leg' })).toBe(
ItineraryView.LEG
it('returns an itinerary list view if URL contains ui_activeItinerary=-1 regardless of ui_itineraryView', () => {
expect(getItineraryView({ ui_activeItinerary: -1 })).toBe(
ItineraryView.LIST
)
expect(
getItineraryView({
ui_activeItinerary: -1,
ui_itineraryView: ItineraryView.FULL
})
).toBe(ItineraryView.LIST)
})
it('returns the specified view mode when set in URL', () => {
expect(
getItineraryView({
ui_activeItinerary: 0,
ui_itineraryView: ItineraryView.LEG
})
).toBe(ItineraryView.LEG)
})
})
})
4 changes: 4 additions & 0 deletions lib/util/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ export function getItineraryView({
ui_itineraryView
}: UrlParams): ItineraryView {
return (
((ui_activeItinerary === null ||
ui_activeItinerary === undefined ||
`${ui_activeItinerary}` === '-1') &&
ItineraryView.LIST) ||
ui_itineraryView ||
(isDefinedAndNotEqual(ui_activeItinerary, -1) && ItineraryView.FULL) ||
ItineraryView.LIST
Expand Down

0 comments on commit 05deb14

Please sign in to comment.