refactor(helcim): normalize listHelcimCustomerCards return shape
This commit is contained in:
parent
5f93d4c2e3
commit
0a41b30db7
6 changed files with 58 additions and 33 deletions
|
|
@ -82,28 +82,6 @@ describe('helcim existing-card endpoint', () => {
|
|||
expect(result.cardToken).toBe('tok-b')
|
||||
})
|
||||
|
||||
it('unwraps a { cards: [...] } response envelope', async () => {
|
||||
requireAuth.mockResolvedValue({ _id: 'm1', helcimCustomerId: 9876 })
|
||||
listHelcimCustomerCards.mockResolvedValue({
|
||||
cards: [{ cardToken: 'tok-only' }]
|
||||
})
|
||||
|
||||
const result = await existingCardHandler(newEvent())
|
||||
|
||||
expect(result.cardToken).toBe('tok-only')
|
||||
})
|
||||
|
||||
it('unwraps a { data: [...] } response envelope', async () => {
|
||||
requireAuth.mockResolvedValue({ _id: 'm1', helcimCustomerId: 9876 })
|
||||
listHelcimCustomerCards.mockResolvedValue({
|
||||
data: [{ cardToken: 'tok-only' }]
|
||||
})
|
||||
|
||||
const result = await existingCardHandler(newEvent())
|
||||
|
||||
expect(result.cardToken).toBe('tok-only')
|
||||
})
|
||||
|
||||
it('returns { cardToken: null } if the resolved card has no cardToken', async () => {
|
||||
requireAuth.mockResolvedValue({ _id: 'm1', helcimCustomerId: 9876 })
|
||||
listHelcimCustomerCards.mockResolvedValue([{ default: true }])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue