@@ -315,7 +315,7 @@ describe('Transaction()', () => {
315315 } ) ;
316316
317317 describe ( 'key casing conversion' , ( ) => {
318- describe ( '`creditCard.last4digits` => `creditCard.last_4_digits `' , ( ) => {
318+ describe ( '`creditCard.lastDigits/ last4digits` => `creditCard.lastDigits `' , ( ) => {
319319 test ( 'typed value is mapped' , ( ) => {
320320 const test = JSON . parse (
321321 new Transaction ( {
@@ -343,6 +343,34 @@ describe('Transaction()', () => {
343343
344344 expect ( test . credit_card ) . toHaveProperty ( 'last_digits' , null ) ;
345345 } ) ;
346+
347+ test ( 'typed value is mapped' , ( ) => {
348+ const test = JSON . parse (
349+ new Transaction ( {
350+ device : new Device ( {
351+ ipAddress : '1.1.1.1' ,
352+ } ) ,
353+ creditCard : new CreditCard ( { lastDigits : '1234' } ) ,
354+ } ) . toString ( )
355+ ) ;
356+
357+ expect ( test . credit_card ) . toHaveProperty ( 'last_digits' , '1234' ) ;
358+ } ) ;
359+
360+ test ( 'null value is mapped' , ( ) => {
361+ const test = JSON . parse (
362+ new Transaction ( {
363+ device : new Device ( {
364+ ipAddress : '1.1.1.1' ,
365+ } ) ,
366+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
367+ // @ts -ignore explicit null
368+ creditCard : new CreditCard ( { lastDigits : null } ) ,
369+ } ) . toString ( )
370+ ) ;
371+
372+ expect ( test . credit_card ) . toHaveProperty ( 'last_digits' , null ) ;
373+ } ) ;
346374 } ) ;
347375
348376 describe ( '`billing.address2` => `billing.address_2`' , ( ) => {
0 commit comments