@@ -7,6 +7,14 @@ import { type RampsOrder, RampsOrderStatus } from '@metamask/ramps-controller';
77import Clipboard from '@react-native-clipboard/clipboard' ;
88import InAppBrowser from 'react-native-inappbrowser-reborn' ;
99
10+ type RampsOrderWithPaymentDetails = RampsOrder & {
11+ paymentDetails : {
12+ fiatCurrency : string ;
13+ paymentMethod : string ;
14+ fields : { name : string ; id : string ; value : string } [ ] ;
15+ } [ ] ;
16+ } ;
17+
1018const mockNavigate = jest . fn ( ) ;
1119jest . mock ( '@react-navigation/native' , ( ) => ( {
1220 ...jest . requireActual ( '@react-navigation/native' ) ,
@@ -82,13 +90,14 @@ describe('OrderContent', () => {
8290 const pendingOrder : RampsOrder = {
8391 ...mockOrder ,
8492 fiatAmount : 0 ,
93+ cryptoAmount : 0 ,
8594 status : RampsOrderStatus . Pending ,
8695 } ;
8796 renderOrder ( pendingOrder ) ;
8897 expect ( screen . toJSON ( ) ) . toMatchSnapshot ( ) ;
8998 } ) ;
9099
91- it ( 'shows ellipsis for token amount when cryptoAmount is 0 or missing' , ( ) => {
100+ it ( 'shows placeholder for token amount when cryptoAmount is 0 or missing' , ( ) => {
92101 const orderWithZeroCrypto : RampsOrder = {
93102 ...mockOrder ,
94103 cryptoAmount : 0 ,
@@ -177,6 +186,84 @@ describe('OrderContent', () => {
177186 ) . toBeOnTheScreen ( ) ;
178187 } ) ;
179188
189+ it ( 'does not render bank details section when paymentDetails is absent' , ( ) => {
190+ renderOrder ( mockOrder ) ;
191+
192+ expect ( screen . queryByText ( 'To complete your order' ) ) . toBeNull ( ) ;
193+ } ) ;
194+
195+ it ( 'does not render bank details section when paymentDetails has no matching fields' , ( ) => {
196+ const orderWithPaymentDetails : RampsOrderWithPaymentDetails = {
197+ ...mockOrder ,
198+ paymentDetails : [
199+ {
200+ fiatCurrency : 'USD' ,
201+ paymentMethod : 'credit_debit_card' ,
202+ fields : [ ] ,
203+ } ,
204+ ] ,
205+ } ;
206+
207+ renderOrder ( orderWithPaymentDetails ) ;
208+
209+ expect ( screen . queryByText ( 'To complete your order' ) ) . toBeNull ( ) ;
210+ } ) ;
211+
212+ it ( 'renders bank details section when paymentDetails has bank transfer fields' , ( ) => {
213+ const orderWithPaymentDetails : RampsOrderWithPaymentDetails = {
214+ ...mockOrder ,
215+ paymentDetails : [
216+ {
217+ fiatCurrency : 'USD' ,
218+ paymentMethod : 'manual_bank_transfer' ,
219+ fields : [
220+ { name : 'Amount' , id : 'amount' , value : '$100.00' } ,
221+ {
222+ name : 'Routing Number' ,
223+ id : 'routingNumber' ,
224+ value : '021000021' ,
225+ } ,
226+ {
227+ name : 'Account Number' ,
228+ id : 'accountNumber' ,
229+ value : '1234567890' ,
230+ } ,
231+ ] ,
232+ } ,
233+ ] ,
234+ } ;
235+
236+ renderOrder ( orderWithPaymentDetails ) ;
237+
238+ expect ( screen . getByText ( 'To complete your order' ) ) . toBeOnTheScreen ( ) ;
239+ expect ( screen . getByText ( / R o u t i n g n u m b e r / i) ) . toBeOnTheScreen ( ) ;
240+ expect ( screen . getByText ( '021000021' ) ) . toBeOnTheScreen ( ) ;
241+ } ) ;
242+
243+ it ( 'renders bank details section when paymentDetails only includes SEPA fields' , ( ) => {
244+ const orderWithPaymentDetails : RampsOrderWithPaymentDetails = {
245+ ...mockOrder ,
246+ paymentDetails : [
247+ {
248+ fiatCurrency : 'EUR' ,
249+ paymentMethod : 'sepa_bank_transfer' ,
250+ fields : [
251+ { name : 'IBAN' , id : 'iban' , value : 'DE89370400440532013000' } ,
252+ { name : 'BIC' , id : 'bic' , value : 'COBADEFFXXX' } ,
253+ ] ,
254+ } ,
255+ ] ,
256+ } ;
257+
258+ renderOrder ( orderWithPaymentDetails ) ;
259+
260+ expect ( screen . getByText ( 'To complete your order' ) ) . toBeOnTheScreen ( ) ;
261+ expect ( screen . getByText ( / ^ I B A N $ / i) ) . toBeOnTheScreen ( ) ;
262+ expect ( screen . getByText ( 'DE89370400440532013000' ) ) . toBeOnTheScreen ( ) ;
263+ expect ( screen . getByText ( / ^ B I C $ / i) ) . toBeOnTheScreen ( ) ;
264+ expect ( screen . getByText ( 'COBADEFFXXX' ) ) . toBeOnTheScreen ( ) ;
265+ } ) ;
266+
180267 it ( 'truncates long crypto amounts to 5 decimal places' , ( ) => {
181268 const longDecimalOrder : RampsOrder = {
182269 ...mockOrder ,
@@ -195,11 +282,11 @@ describe('OrderContent', () => {
195282 } ;
196283 renderOrder ( tinyAmountOrder ) ;
197284 const tokenAmount = screen . getByTestId ( 'ramps-order-details-token-amount' ) ;
198- // 0.00000614 has 5 leading zeros → "0.0₅614"
285+ // 0.00000614 has 5 leading zeros -> "0.0₅614"
199286 expect ( tokenAmount ) . toHaveTextContent ( '0.0₅614 ETH' ) ;
200287 } ) ;
201288
202- it ( 'shows "..." when cryptoAmount is missing' , ( ) => {
289+ it ( 'shows placeholder when cryptoAmount is missing' , ( ) => {
203290 const noAmountOrder : RampsOrder = {
204291 ...mockOrder ,
205292 cryptoAmount : undefined as unknown as number ,
@@ -209,14 +296,32 @@ describe('OrderContent', () => {
209296 expect ( tokenAmount ) . toHaveTextContent ( '... ETH' ) ;
210297 } ) ;
211298
212- it ( 'renders "0" when cryptoAmount is zero' , ( ) => {
299+ it ( 'shows placeholder when cryptoAmount is zero' , ( ) => {
213300 const zeroAmountOrder : RampsOrder = {
214301 ...mockOrder ,
215302 cryptoAmount : 0 ,
216303 } ;
217304 renderOrder ( zeroAmountOrder ) ;
218305 const tokenAmount = screen . getByTestId ( 'ramps-order-details-token-amount' ) ;
219- expect ( tokenAmount ) . toHaveTextContent ( '0 ETH' ) ;
306+ expect ( tokenAmount ) . toHaveTextContent ( '... ETH' ) ;
307+ } ) ;
308+
309+ it ( 'shows placeholder amounts for terminal orders with no amounts' , ( ) => {
310+ const failedOrder : RampsOrder = {
311+ ...mockOrder ,
312+ cryptoAmount : 0 ,
313+ fiatAmount : 0 ,
314+ totalFeesFiat : 0 ,
315+ status : RampsOrderStatus . Failed ,
316+ } ;
317+
318+ renderOrder ( failedOrder ) ;
319+
320+ expect ( screen . getByText ( 'Failed' ) ) . toBeOnTheScreen ( ) ;
321+ expect (
322+ screen . getByTestId ( 'ramps-order-details-token-amount' ) ,
323+ ) . toHaveTextContent ( '... ETH' ) ;
324+ expect ( screen . getAllByText ( '...' ) ) . toHaveLength ( 2 ) ;
220325 } ) ;
221326
222327 it ( 'does not render info row when statusDescription is absent' , ( ) => {
0 commit comments