File tree 5 files changed +22
-16
lines changed
5 files changed +22
-16
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ export const offersSuccess = () => ({
26
26
] ,
27
27
} ) ;
28
28
29
+ // This happens when product doesn't have any proof points but its brand has
29
30
export const offersNoProofPoints = ( ) => ( {
30
31
trustBadge : {
31
32
backgroundColor : '#dedede' ,
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ describe('getOffers', () => {
69
69
} ) ;
70
70
71
71
describe ( 'when proof points were not found' , ( ) => {
72
- it ( 'is not shown ' , async ( ) => {
72
+ it ( 'returns the fetched data ' , async ( ) => {
73
73
global . fetch = jest . fn ( ( ) => ( {
74
74
ok : true ,
75
75
json : ( ) => Promise . resolve ( offersNoProofPoints ( ) ) ,
@@ -78,9 +78,6 @@ describe('getOffers', () => {
78
78
const result = await getOffers ( 'fakeSku' ) ;
79
79
80
80
expect ( result ) . toEqual ( offersNoProofPoints ( ) ) ;
81
- expect ( Errors . warn ) . toHaveBeenCalledWith (
82
- expect . stringContaining ( 'No proof points found for the SKU: fakeSku' )
83
- ) ;
84
81
} ) ;
85
82
} ) ;
86
83
} ) ;
Original file line number Diff line number Diff line change @@ -83,14 +83,28 @@ describe('TrustBadge', () => {
83
83
} ) ;
84
84
85
85
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 ( ) ;
88
89
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) ;
91
95
} ) ;
96
+ } ) ;
92
97
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
+ } ) ;
94
108
} ) ;
95
109
96
110
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> {
122
122
) ;
123
123
return null ;
124
124
}
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
- }
130
125
return data ;
131
126
} else {
132
127
const message = await response . text ( ) ;
Original file line number Diff line number Diff line change @@ -95,8 +95,7 @@ const TrustBadgeComponent = ({
95
95
const trustBadgeHeight =
96
96
variant === 'Tick' ? Tick . getHeight ( ) : ProofPoint . getHeight ( ) ;
97
97
98
- if ( ! offers || ! offers . proofPoints || offers . proofPoints . length === 0 )
99
- return < > </ > ;
98
+ if ( ! offers || ! offers . proofPoints ) return < > </ > ;
100
99
101
100
return (
102
101
< View style = { { flexBasis : scaled ( trustBadgeHeight ) } } >
You can’t perform that action at this time.
0 commit comments