@@ -468,6 +468,68 @@ describe('ServerModel', () => {
468468 expect ( mPStore . sessionStartDate ) . to . eql ( null ) ;
469469 } ) ;
470470
471+ describe ( 'EventName coercion for lifecycle events with no name' , ( ) => {
472+ beforeEach ( async ( ) => {
473+ await waitForCondition ( hasIdentifyReturned ) ;
474+ } ) ;
475+
476+ it ( 'should produce a string EventName for SessionStart' , ( ) => {
477+ const event : BaseEvent = {
478+ messageType : Types . MessageType . SessionStart ,
479+ eventType : Types . EventType . Other ,
480+ } ;
481+
482+ const actualEventObject = mParticle
483+ . getInstance ( )
484+ . _ServerModel . createEventObject ( event ) as IUploadObject ;
485+
486+ expect ( typeof actualEventObject . EventName ) . to . equal ( 'string' ) ;
487+ expect ( actualEventObject . EventName ) . to . equal ( '1' ) ;
488+ } ) ;
489+
490+ it ( 'should produce a string EventName for SessionEnd' , ( ) => {
491+ const event : BaseEvent = {
492+ messageType : Types . MessageType . SessionEnd ,
493+ eventType : Types . EventType . Other ,
494+ } ;
495+
496+ const actualEventObject = mParticle
497+ . getInstance ( )
498+ . _ServerModel . createEventObject ( event ) as IUploadObject ;
499+
500+ expect ( typeof actualEventObject . EventName ) . to . equal ( 'string' ) ;
501+ expect ( actualEventObject . EventName ) . to . equal ( '2' ) ;
502+ } ) ;
503+
504+ it ( 'should produce a string EventName for AppStateTransition' , ( ) => {
505+ const event : BaseEvent = {
506+ messageType : Types . MessageType . AppStateTransition ,
507+ eventType : Types . EventType . Other ,
508+ } ;
509+
510+ const actualEventObject = mParticle
511+ . getInstance ( )
512+ . _ServerModel . createEventObject ( event ) as IUploadObject ;
513+
514+ expect ( typeof actualEventObject . EventName ) . to . equal ( 'string' ) ;
515+ expect ( actualEventObject . EventName ) . to . equal ( '10' ) ;
516+ } ) ;
517+
518+ it ( 'should use the event name when provided, not the messageType' , ( ) => {
519+ const event : BaseEvent = {
520+ name : 'My Custom Event' ,
521+ messageType : Types . MessageType . PageEvent ,
522+ eventType : Types . EventType . Navigation ,
523+ } ;
524+
525+ const actualEventObject = mParticle
526+ . getInstance ( )
527+ . _ServerModel . createEventObject ( event ) as IUploadObject ;
528+
529+ expect ( actualEventObject . EventName ) . to . equal ( 'My Custom Event' ) ;
530+ } ) ;
531+ } ) ;
532+
471533 it ( 'should set necessary attributes if MessageType is AppStateTransition' , ( ) => {
472534 const event : BaseEvent = {
473535 name : 'Test Event' ,
0 commit comments