@@ -1995,6 +1995,12 @@ describe('Rokt Forwarder', () => {
19951995 } ;
19961996 } ) ;
19971997
1998+ afterEach ( ( ) => {
1999+ window . mParticle . forwarder . eventQueue = [ ] ;
2000+ window . mParticle . forwarder . isInitialized = false ;
2001+ window . mParticle . Rokt . attachKitCalled = false ;
2002+ } ) ;
2003+
19982004 it ( 'set a local session selection attribute if the event is a mapped placement event' , async ( ) => {
19992005 // Mocks hashed values for testing
20002006 const placementEventMapping = JSON . stringify ( [
@@ -2035,6 +2041,62 @@ describe('Rokt Forwarder', () => {
20352041 'foo-mapped-flag' : true ,
20362042 } ) ;
20372043 } ) ;
2044+
2045+ it ( 'should add the event to the event queue if the kit is not initialized' , async ( ) => {
2046+ await window . mParticle . forwarder . init (
2047+ {
2048+ accountId : '123456' ,
2049+ } ,
2050+ reportService . cb ,
2051+ true ,
2052+ null ,
2053+ { }
2054+ ) ;
2055+
2056+ window . mParticle . forwarder . process ( {
2057+ EventName : 'Video Watched A' ,
2058+ EventCategory : EventType . Other ,
2059+ EventDataType : MessageType . PageEvent ,
2060+ } ) ;
2061+
2062+ window . mParticle . forwarder . eventQueue . should . deepEqual ( [
2063+ {
2064+ EventName : 'Video Watched A' ,
2065+ EventCategory : EventType . Other ,
2066+ EventDataType : MessageType . PageEvent ,
2067+ } ,
2068+ ] ) ;
2069+ } ) ;
2070+
2071+ it ( 'should process queued events once the kit is ready' , async ( ) => {
2072+ await window . mParticle . forwarder . init (
2073+ {
2074+ accountId : '123456' ,
2075+ } ,
2076+ reportService . cb ,
2077+ true ,
2078+ null ,
2079+ { }
2080+ ) ;
2081+
2082+ window . mParticle . forwarder . process ( {
2083+ EventName : 'Video Watched B' ,
2084+ EventCategory : EventType . Other ,
2085+ EventDataType : MessageType . PageEvent ,
2086+ } ) ;
2087+
2088+ window . mParticle . forwarder . eventQueue . should . deepEqual ( [
2089+ {
2090+ EventName : 'Video Watched B' ,
2091+ EventCategory : EventType . Other ,
2092+ EventDataType : MessageType . PageEvent ,
2093+ } ,
2094+ ] ) ;
2095+
2096+ await waitForCondition ( ( ) => window . mParticle . Rokt . attachKitCalled ) ;
2097+
2098+ window . mParticle . forwarder . eventQueue . should . deepEqual ( [ ] ) ;
2099+ } ) ;
20382100 } ) ;
20392101
20402102 describe ( '#parseSettingsString' , ( ) => {
0 commit comments