-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(PC-32988) fix(offerToHeadlineOfferData): fix naming and upgrade cove…
…rage
- Loading branch information
1 parent
c3b1062
commit 581e840
Showing
4 changed files
with
90 additions
and
32 deletions.
There are no files selected for viewing
30 changes: 0 additions & 30 deletions
30
src/features/headlineOffer/adapters/headlineOfferData.native.test.ts
This file was deleted.
Oops, something went wrong.
88 changes: 88 additions & 0 deletions
88
src/features/headlineOffer/adapters/offerToHeadlineOfferData.native.test.ts
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,88 @@ | ||
import { offerToHeadlineOfferData } from 'features/headlineOffer/adapters/offerToHeadlineOfferData' | ||
import { mockLabelMapping, mockMapping } from 'features/headlineOffer/fixtures/mockMapping' | ||
import { Currency } from 'shared/currency/useGetCurrencyToDisplay' | ||
import { offersFixture } from 'shared/offer/offer.fixture' | ||
|
||
describe('offerToHeadlineOfferData', () => { | ||
it('should transform headline offer data correctly', () => { | ||
const result = offerToHeadlineOfferData({ | ||
offer: offersFixture[0], | ||
transformParameters: { | ||
mapping: mockMapping, | ||
labelMapping: mockLabelMapping, | ||
currency: Currency.EURO, | ||
euroToPacificFrancRate: 10, | ||
userLocation: { latitude: 1, longitude: 1 }, | ||
}, | ||
}) | ||
|
||
expect(result).toEqual({ | ||
id: '102280', | ||
categoryId: 'LIVRE', | ||
category: 'Livre papier', | ||
imageUrl: | ||
'https://storage.googleapis.com/passculture-metier-prod-production-assets-fine-grained/thumbs/mediations/CDNQ', | ||
offerTitle: 'La nuit des temps', | ||
price: 'Dès 28\u00a0€', | ||
distance: '900+ km', | ||
}) | ||
}) | ||
|
||
it('should return null if offer is null', () => { | ||
const result = offerToHeadlineOfferData({ | ||
offer: null, | ||
transformParameters: { | ||
mapping: mockMapping, | ||
labelMapping: mockLabelMapping, | ||
currency: Currency.EURO, | ||
euroToPacificFrancRate: 10, | ||
userLocation: { latitude: 1, longitude: 1 }, | ||
}, | ||
}) | ||
|
||
expect(result).toBeNull() | ||
}) | ||
|
||
it('should return an empty string if imageUrl is undefined', () => { | ||
const offerWithoutImage = { | ||
...offersFixture[0], | ||
offer: { ...offersFixture[0].offer, thumbUrl: undefined }, | ||
} | ||
|
||
const result = offerToHeadlineOfferData({ | ||
offer: offerWithoutImage, | ||
transformParameters: { | ||
mapping: mockMapping, | ||
labelMapping: mockLabelMapping, | ||
currency: Currency.EURO, | ||
euroToPacificFrancRate: 10, | ||
userLocation: { latitude: 1, longitude: 1 }, | ||
}, | ||
}) | ||
|
||
expect(result?.imageUrl).toBe('') | ||
}) | ||
|
||
it('should return undefined if geolocation is missing', () => { | ||
const offerWithoutGeoloc = { | ||
...offersFixture[0], | ||
_geoloc: { | ||
lat: null, | ||
lng: null, | ||
}, | ||
} | ||
|
||
const result = offerToHeadlineOfferData({ | ||
offer: offerWithoutGeoloc, | ||
transformParameters: { | ||
mapping: mockMapping, | ||
labelMapping: mockLabelMapping, | ||
currency: Currency.EURO, | ||
euroToPacificFrancRate: 10, | ||
userLocation: { latitude: 1, longitude: 1 }, | ||
}, | ||
}) | ||
|
||
expect(result?.distance).toBeUndefined() | ||
}) | ||
}) |
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 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