File tree Expand file tree Collapse file tree 5 files changed +22
-16
lines changed
Expand file tree Collapse file tree 5 files changed +22
-16
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ export const offersSuccess = () => ({
2626 ] ,
2727} ) ;
2828
29+ // This happens when product doesn't have any proof points but its brand has
2930export const offersNoProofPoints = ( ) => ( {
3031 trustBadge : {
3132 backgroundColor : '#dedede' ,
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ describe('getOffers', () => {
6969 } ) ;
7070
7171 describe ( 'when proof points were not found' , ( ) => {
72- it ( 'is not shown ' , async ( ) => {
72+ it ( 'returns the fetched data ' , async ( ) => {
7373 global . fetch = jest . fn ( ( ) => ( {
7474 ok : true ,
7575 json : ( ) => Promise . resolve ( offersNoProofPoints ( ) ) ,
@@ -78,9 +78,6 @@ describe('getOffers', () => {
7878 const result = await getOffers ( 'fakeSku' ) ;
7979
8080 expect ( result ) . toEqual ( offersNoProofPoints ( ) ) ;
81- expect ( Errors . warn ) . toHaveBeenCalledWith (
82- expect . stringContaining ( 'No proof points found for the SKU: fakeSku' )
83- ) ;
8481 } ) ;
8582 } ) ;
8683} ) ;
Original file line number Diff line number Diff line change @@ -83,14 +83,28 @@ describe('TrustBadge', () => {
8383 } ) ;
8484
8585 describe ( 'when proof points were not found' , ( ) => {
86- it ( 'is not shown' , async ( ) => {
87- whenTrustBadgeRendered ( ) ;
86+ describe ( 'when Tick variant' , ( ) => {
87+ it ( 'is still shown as success response from API without proof points indicates there are brand proof points' , async ( ) => {
88+ whenTrustBadgeRendered ( ) ;
8889
89- await act ( ( ) => {
90- getOffersPromiseResolve ( offersNoProofPoints ( ) ) ;
90+ await act ( ( ) => {
91+ getOffersPromiseResolve ( offersNoProofPoints ( ) ) ;
92+ } ) ;
93+
94+ expect ( screen . root ) . toHaveTextContent ( / S u s t a i n a b i l i t y c l a i m s / i) ;
9195 } ) ;
96+ } ) ;
9297
93- expect ( screen . root ) . not . toHaveTextContent ( / S u s t a i n a b i l i t y c l a i m s / i) ;
98+ describe ( 'when ProofPoint variant' , ( ) => {
99+ it ( 'is still shown as success response from API without proof points indicates there are brand proof points' , async ( ) => {
100+ whenTrustBadgeRendered ( 'ProofPoint' ) ;
101+
102+ await act ( ( ) => {
103+ getOffersPromiseResolve ( offersNoProofPoints ( ) ) ;
104+ } ) ;
105+
106+ expect ( screen . queryAllByLabelText ( 'Provenance logo' ) ) . toHaveLength ( 1 ) ;
107+ } ) ;
94108 } ) ;
95109
96110 describe ( 'when no offers' , ( ) => {
Original file line number Diff line number Diff line change @@ -122,11 +122,6 @@ export async function getOffers(sku: string): Promise<OffersData | null> {
122122 ) ;
123123 return null ;
124124 }
125- if ( data . proofPoints . length === 0 ) {
126- Errors . warn (
127- `No proof points found for the SKU: ${ sku } , it could be a valid case but better double check that the SKU is valid.`
128- ) ;
129- }
130125 return data ;
131126 } else {
132127 const message = await response . text ( ) ;
Original file line number Diff line number Diff line change @@ -95,8 +95,7 @@ const TrustBadgeComponent = ({
9595 const trustBadgeHeight =
9696 variant === 'Tick' ? Tick . getHeight ( ) : ProofPoint . getHeight ( ) ;
9797
98- if ( ! offers || ! offers . proofPoints || offers . proofPoints . length === 0 )
99- return < > </ > ;
98+ if ( ! offers || ! offers . proofPoints ) return < > </ > ;
10099
101100 return (
102101 < View style = { { flexBasis : scaled ( trustBadgeHeight ) } } >
You can’t perform that action at this time.
0 commit comments