Skip to content

Commit

Permalink
Adds a unit test for multiple payloads. Generates types
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-Ag committed Jul 28, 2024
1 parent fa0131d commit a174a3c
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,76 @@ describe('Facebook Custom Audiences', () => {
])
})

it('should generate data correctly for multiple users', async () => {})
it('should generate data correctly for multiple users', async () => {
const payloads: Payload[] = new Array(2)

payloads[0] = {
email: '[email protected]',
phone: '555-555-5555',
name: {
first: 'Henry',
last: 'Aaron'
},
externalId: '5'
}

payloads[1] = {
email: '[email protected]',
gender: 'male',
birth: {
year: '1960',
month: 'May',
day: '9'
},
name: {
first: 'Tony',
last: 'Gwynn',
firstInitial: 'T'
},
address: {
city: 'San Diego',
state: 'CA',
zip: '92000',
country: 'US'
}
}

expect(generateData(payloads)).toEqual([
[
hash(payloads[0].externalId || ''), // external_id
hash(payloads[0].email || ''), // email
hash(payloads[0].phone || ''), // phone
EMPTY, // gender
EMPTY, // year
EMPTY, // month
EMPTY, // day
hash(payloads[0].name?.last || ''), // last_name
hash(payloads[0].name?.first || ''), // first_name
EMPTY, // first_initial
EMPTY, // city
EMPTY, // state
EMPTY, // zip
EMPTY, // mobile_advertiser_id,
EMPTY // country
],
[
EMPTY, // external_id
hash(payloads[1].email || ''), // email
EMPTY, // phone
hash(payloads[1].gender || ''), // gender
hash(payloads[1].birth?.year || ''), // year
hash(payloads[1].birth?.month || ''), // month
hash(payloads[1].birth?.day || ''), // day
hash(payloads[1].name?.last || ''), // last_name
hash(payloads[1].name?.first || ''), // first_name
hash(payloads[1].name?.firstInitial || ''), // first_initial
hash(payloads[1].address?.city || ''), // city
hash(payloads[1].address?.state || ''), // state
hash(payloads[1].address?.zip || ''), // zip
EMPTY, // mobile_advertiser_id,
hash(payloads[1].address?.country || '') // country
]
])
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ export default class FacebookClient {

syncAudience = async (input: { audienceId: string; payloads: Payload[]; deleteUsers?: boolean }) => {
const data = generateData(input.payloads)
console.log('data', data)

const params = {
payload: {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a174a3c

Please sign in to comment.