Skip to content

Commit

Permalink
test(util/ui): Refactor test.
Browse files Browse the repository at this point in the history
  • Loading branch information
binh-dam-ibigroup committed Oct 6, 2023
1 parent a200fcf commit 2419489
Showing 1 changed file with 24 additions and 36 deletions.
60 changes: 24 additions & 36 deletions __tests__/util/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,21 @@ describe('util > ui', () => {
)
})
it('returns an itinerary list view if URL contains ui_activeItinerary=-1 regardless of ui_itineraryView', () => {
expect(
getItineraryView({
ui_activeItinerary: -1,
ui_itineraryView: ItineraryView.FULL
})
).toBe(ItineraryView.LIST)
expect(
getItineraryView({
ui_activeItinerary: -1,
ui_itineraryView: ItineraryView.LEG
})
).toBe(ItineraryView.LIST)
expect(
getItineraryView({
ui_activeItinerary: -1,
ui_itineraryView: ItineraryView.LEG_HIDDEN
})
).toBe(ItineraryView.LIST)
expect(
getItineraryView({
ui_activeItinerary: -1,
ui_itineraryView: ItineraryView.LIST_HIDDEN
})
).toBe(ItineraryView.LIST_HIDDEN)
const expectedValues = {
[ItineraryView.FULL]: ItineraryView.LIST,
[ItineraryView.LEG]: ItineraryView.LIST,
[ItineraryView.LEG_HIDDEN]: ItineraryView.LIST,
[ItineraryView.LIST]: ItineraryView.LIST,
[ItineraryView.LIST_HIDDEN]: ItineraryView.LIST_HIDDEN
}
Object.entries(expectedValues).forEach(([k, v]) => {
expect(
getItineraryView({
ui_activeItinerary: -1,
ui_itineraryView: k
})
).toBe(v)
})
})
it('returns the specified view mode when set in URL', () => {
expect(
Expand All @@ -57,18 +48,15 @@ describe('util > ui', () => {
})
describe('getMapToggleNewItineraryView', () => {
it('should obtain the new itinerary view value', () => {
expect(getMapToggleNewItineraryView(ItineraryView.LEG)).toBe(
ItineraryView.LEG_HIDDEN
)
expect(getMapToggleNewItineraryView(ItineraryView.LIST)).toBe(
ItineraryView.LIST_HIDDEN
)
expect(getMapToggleNewItineraryView(ItineraryView.LEG_HIDDEN)).toBe(
ItineraryView.LEG
)
expect(getMapToggleNewItineraryView(ItineraryView.LIST_HIDDEN)).toBe(
ItineraryView.LIST
)
const expectedValues = {
[ItineraryView.LEG]: ItineraryView.LEG_HIDDEN,
[ItineraryView.LEG_HIDDEN]: ItineraryView.LEG,
[ItineraryView.LIST]: ItineraryView.LIST_HIDDEN,
[ItineraryView.LIST_HIDDEN]: ItineraryView.LIST
}
Object.entries(expectedValues).forEach(([k, v]) => {
expect(getMapToggleNewItineraryView(k)).toBe(v)
})
})
})
})

0 comments on commit 2419489

Please sign in to comment.