@@ -24,7 +24,7 @@ declare global {
2424const mParticle = window . mParticle as IMParticleInstanceManager ;
2525
2626describe ( 'Integration Capture' , ( ) => {
27- beforeEach ( function ( ) {
27+ beforeEach ( async function ( ) {
2828 mParticle . _resetForTests ( MPConfig ) ;
2929 fetchMock . post ( urls . events , 200 ) ;
3030 delete mParticle . _instances [ 'default_instance' ] ;
@@ -44,20 +44,19 @@ describe('Integration Capture', () => {
4444 window . document . cookie = 'baz=qux' ;
4545 window . document . cookie = '_ttp=45670808' ;
4646 mParticle . init ( apiKey , window . mParticle . config ) ;
47- return waitForCondition ( hasIdentifyReturned ) . then ( function ( ) {
48- const integrationCapture = window . mParticle . getInstance ( ) . _IntegrationCapture ;
49- // Mock the query params capture function because we cannot mock window.location.href
50- sinon . stub ( integrationCapture , 'getQueryParams' ) . returns ( {
51- fbclid : '1234' ,
52- gclid : '234' ,
53- gbraid : '6574' ,
54- rtid : '45670808' ,
55- rclid : '7183717' ,
56- wbraid : '1234111' ,
57- ScCid : '1234' ,
58- } ) ;
59- integrationCapture . capture ( ) ;
47+ await waitForCondition ( hasIdentifyReturned ) ;
48+ const integrationCapture = window . mParticle . getInstance ( ) . _IntegrationCapture ;
49+ // Mock the query params capture function because we cannot mock window.location.href
50+ sinon . stub ( integrationCapture , 'getQueryParams' ) . returns ( {
51+ fbclid : '1234' ,
52+ gclid : '234' ,
53+ gbraid : '6574' ,
54+ rtid : '45670808' ,
55+ rclid : '7183717' ,
56+ wbraid : '1234111' ,
57+ ScCid : '1234' ,
6058 } ) ;
59+ integrationCapture . capture ( ) ;
6160 } ) ;
6261
6362 afterEach ( function ( ) {
@@ -90,6 +89,7 @@ describe('Integration Capture', () => {
9089 expect ( testEvent . data . custom_flags [ 'GoogleEnhancedConversions.Wbraid' ] , 'Google Enhanced Conversions Wbraid' ) . to . equal ( '1234111' ) ;
9190 expect ( testEvent . data . custom_flags [ 'SnapchatConversions.ClickId' ] , 'Snapchat Click ID' ) . to . equal ( '1234' ) ;
9291 } ) ;
92+
9393 it ( 'should add captured integrations to event custom flags, prioritizing passed in custom flags' , async ( ) => {
9494 await waitForCondition ( hasIdentifyReturned ) ;
9595 window . mParticle . logEvent (
0 commit comments