Skip to content

Commit 6a158fb

Browse files
committed
Add credit card field name conversion tests for lastDigits
1 parent 1e8ca76 commit 6a158fb

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/request/transaction.spec.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)