Skip to content

Commit

Permalink
Added tests for customer redeemable. Fixed formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkaliszuk committed Apr 2, 2024
1 parent b1951c2 commit c7aaa6b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/sdk/src/types/Customers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Legacy code
import {VouchersResponse} from "./Vouchers";
import { VouchersResponse } from './Vouchers'

export interface SimpleCustomer {
id: string
Expand Down Expand Up @@ -127,7 +127,7 @@ export interface CustomerRedeemablesListQueryParams {
limit?: number
page?: number
order?: 'created_at' | '-created_at' | 'id' | '-id'
starting_after_id?: string,
starting_after_id?: string
filters?: Record<string, any>
}

Expand Down
31 changes: 31 additions & 0 deletions packages/sdk/test/customers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { voucherifyClient as client } from './client'
import { generateRandomString } from './utils/generateRandomString'
import { generateCustomerCSV } from './utils/generateCustomerCSV'
import { CustomerRequest, DiscountVouchersTypesEnum, DistributionsPublicationsCreateParams } from '@voucherify/sdk'

jest.setTimeout(15000)

Expand Down Expand Up @@ -173,4 +174,34 @@ describe('Customers API', () => {
}
expect(updatedCustomerWithNoAddress.address).toEqual(removedAddress)
})

it('Should return redeemable for customer', async () => {
const createdCustomer: CustomerRequest = await client.customers.create({ source_id: generateRandomString() })

const discountCampaign = await client.campaigns.create({
campaign_type: 'DISCOUNT_COUPONS',
name: generateRandomString(),
type: 'AUTO_UPDATE',
voucher: {
code_config: {
length: 3,
},
type: 'DISCOUNT_VOUCHER',
discount: {
amount_off: 0,
type: DiscountVouchersTypesEnum.AMOUNT,
},
},
})

const distributionsPublicationsCreateParams: DistributionsPublicationsCreateParams = {
customer: createdCustomer,
campaign: discountCampaign,
}

await client.distributions.publications.create(distributionsPublicationsCreateParams)

const redeemables = await client.customers.listRedeemables(createdCustomer.id as string)
expect(redeemables.data).toBeDefined()
})
})

0 comments on commit c7aaa6b

Please sign in to comment.