@@ -3,6 +3,7 @@ import { createTestEvent, createTestIntegration } from '@segment/actions-core'
33import Destination from '../../index'
44import { SegmentEvent } from '@segment/actions-core/*'
55import { InvalidAuthenticationError } from '@segment/actions-core'
6+ import { FLAG_CONSENT_REQUIRED } from '../../utils'
67
78const testDestination = createTestIntegration ( Destination )
89const event = createTestEvent ( {
@@ -111,6 +112,8 @@ const settings = {
111112 region : 'https://advertising-api.amazon.com'
112113}
113114
115+ const features = { [ FLAG_CONSENT_REQUIRED ] : true }
116+
114117describe ( 'AmazonAds.syncAudiencesToDSP' , ( ) => {
115118 beforeEach ( ( ) => {
116119 nock . cleanAll ( )
@@ -128,7 +131,8 @@ describe('AmazonAds.syncAudiencesToDSP', () => {
128131 const response = await testDestination . testAction ( 'syncAudiencesToDSP' , {
129132 event,
130133 settings,
131- useDefaultMappings : true
134+ useDefaultMappings : true ,
135+ features
132136 } )
133137
134138 expect ( response . length ) . toBe ( 1 )
@@ -159,7 +163,8 @@ describe('AmazonAds.syncAudiencesToDSP', () => {
159163 }
160164 } ,
161165 settings,
162- useDefaultMappings : true
166+ useDefaultMappings : true ,
167+ features
163168 } )
164169
165170 expect ( response . length ) . toBe ( 1 )
@@ -190,7 +195,8 @@ describe('AmazonAds.syncAudiencesToDSP', () => {
190195 }
191196 } ,
192197 settings,
193- useDefaultMappings : true
198+ useDefaultMappings : true ,
199+ features
194200 } )
195201
196202 expect ( response . length ) . toBe ( 1 )
@@ -226,7 +232,8 @@ describe('AmazonAds.syncAudiencesToDSP', () => {
226232 }
227233 } ,
228234 settings,
229- useDefaultMappings : true
235+ useDefaultMappings : true ,
236+ features
230237 } )
231238
232239 expect ( response . length ) . toBe ( 1 )
@@ -250,7 +257,8 @@ describe('AmazonAds.syncAudiencesToDSP', () => {
250257 event : 'Audience Exited'
251258 } ,
252259 settings,
253- useDefaultMappings : true
260+ useDefaultMappings : true ,
261+ features
254262 } )
255263
256264 expect ( response . length ) . toBe ( 1 )
@@ -269,7 +277,8 @@ describe('AmazonAds.syncAudiencesToDSP', () => {
269277 userId : 'invalid+1@user.com'
270278 } ,
271279 settings,
272- useDefaultMappings : true
280+ useDefaultMappings : true ,
281+ features
273282 } )
274283 ) . rejects . toThrowError ( 'externalUserId must satisfy regular expression pattern: [0-9a-zA-Z\\-\\_]{1,128}}' )
275284 } )
@@ -283,7 +292,8 @@ describe('AmazonAds.syncAudiencesToDSP', () => {
283292 const response = await testDestination . executeBatch ( 'syncAudiencesToDSP' , {
284293 events,
285294 settings,
286- mapping
295+ mapping,
296+ features
287297 } )
288298 expect ( response . length ) . toBe ( 2 )
289299 expect ( response [ 0 ] ) . toEqual ( {
@@ -327,7 +337,8 @@ describe('AmazonAds.syncAudiencesToDSP', () => {
327337 const response = await testDestination . executeBatch ( 'syncAudiencesToDSP' , {
328338 events,
329339 settings,
330- mapping
340+ mapping,
341+ features
331342 } )
332343 expect ( response . length ) . toBe ( 2 )
333344 expect ( response [ 0 ] ) . toEqual ( {
@@ -395,7 +406,8 @@ describe('AmazonAds.syncAudiencesToDSP', () => {
395406 const response = await testDestination . executeBatch ( 'syncAudiencesToDSP' , {
396407 events,
397408 settings,
398- mapping
409+ mapping,
410+ features
399411 } )
400412
401413 expect ( response . length ) . toBe ( 2 )
@@ -422,7 +434,8 @@ describe('AmazonAds.syncAudiencesToDSP', () => {
422434 testDestination . executeBatch ( 'syncAudiencesToDSP' , {
423435 events,
424436 settings,
425- mapping
437+ mapping,
438+ features
426439 } )
427440 ) . rejects . toThrowError ( new InvalidAuthenticationError ( 'Unauthorized' ) )
428441 } )
@@ -458,7 +471,8 @@ describe('AmazonAds.syncAudiencesToDSP', () => {
458471 amznAdStorage : { '@path' : '$.properties.amznAdStorage' } ,
459472 amznUserData : { '@path' : '$.properties.amznUserData' }
460473 }
461- }
474+ } ,
475+ features
462476 } )
463477
464478 expect ( response . length ) . toBe ( 1 )
@@ -487,7 +501,8 @@ describe('AmazonAds.syncAudiencesToDSP', () => {
487501 const response = await testDestination . executeBatch ( 'syncAudiencesToDSP' , {
488502 events : [ { ...event , userId : 'test_kochar-02' } ] ,
489503 settings,
490- mapping
504+ mapping,
505+ features
491506 } )
492507
493508 expect ( response . length ) . toBe ( 1 )
@@ -523,7 +538,8 @@ describe('AmazonAds.syncAudiencesToDSP', () => {
523538 testDestination . testAction ( 'syncAudiencesToDSP' , {
524539 event : deEvent ,
525540 settings,
526- useDefaultMappings : true
541+ useDefaultMappings : true ,
542+ features
527543 } )
528544 ) . rejects . toThrowError ( 'Non US country codes must provide valid consent data.' )
529545 } )
@@ -546,7 +562,8 @@ describe('AmazonAds.syncAudiencesToDSP', () => {
546562 const response = await testDestination . executeBatch ( 'syncAudiencesToDSP' , {
547563 events : [ deEvent ] ,
548564 settings,
549- mapping
565+ mapping,
566+ features
550567 } )
551568
552569 expect ( response . length ) . toBe ( 1 )
@@ -589,7 +606,8 @@ describe('AmazonAds.syncAudiencesToDSP', () => {
589606 consent : {
590607 ipAddress : { '@path' : '$.context.ip' }
591608 }
592- }
609+ } ,
610+ features
593611 } )
594612
595613 expect ( response . length ) . toBe ( 1 )
0 commit comments