@@ -985,6 +985,7 @@ describe('User ID', function() {
985
985
sinon . stub ( utils , 'triggerPixel' ) ;
986
986
utils . setCookie ( 'pubcid' , '' , EXPIRED_COOKIE_DATE ) ;
987
987
utils . setCookie ( 'unifiedid' , '' , EXPIRED_COOKIE_DATE ) ;
988
+ utils . setCookie ( '_parrable_eid' , '' , EXPIRED_COOKIE_DATE ) ;
988
989
} ) ;
989
990
990
991
afterEach ( function ( ) {
@@ -993,6 +994,7 @@ describe('User ID', function() {
993
994
utils . triggerPixel . restore ( ) ;
994
995
utils . setCookie ( 'pubcid' , '' , EXPIRED_COOKIE_DATE ) ;
995
996
utils . setCookie ( 'unifiedid' , '' , EXPIRED_COOKIE_DATE ) ;
997
+ utils . setCookie ( '_parrable_eid' , '' , EXPIRED_COOKIE_DATE ) ;
996
998
} ) ;
997
999
998
1000
it ( 'pubcid callback with url' , function ( ) {
@@ -1042,5 +1044,73 @@ describe('User ID', function() {
1042
1044
events . emit ( CONSTANTS . EVENTS . AUCTION_END , { } ) ;
1043
1045
expect ( requests [ 0 ] . url ) . to . equal ( '//match.adsrvr.org/track/rid?ttd_pid=rubicon&fmt=json' ) ;
1044
1046
} ) ;
1047
+
1048
+ it ( 'callback for submodules that always need to refresh stored id' , function ( done ) {
1049
+ let adUnits = [ getAdUnitMock ( ) ] ;
1050
+ let innerAdUnits ;
1051
+ const parrableStoredId = '01.1111111111.test-eid' ;
1052
+ const parrableRefreshedId = '02.2222222222.test-eid' ;
1053
+ utils . setCookie ( '_parrable_eid' , parrableStoredId , ( new Date ( Date . now ( ) + 5000 ) . toUTCString ( ) ) ) ;
1054
+
1055
+ const parrableIdSubmoduleMock = {
1056
+ name : 'parrableId' ,
1057
+ decode : function ( value ) {
1058
+ return { 'parrableid' : value } ;
1059
+ } ,
1060
+ getId : function ( ) {
1061
+ return {
1062
+ callback : function ( cb ) {
1063
+ cb ( parrableRefreshedId ) ;
1064
+ }
1065
+ } ;
1066
+ }
1067
+ } ;
1068
+
1069
+ const parrableConfigMock = {
1070
+ userSync : {
1071
+ syncDelay : 0 ,
1072
+ userIds : [ {
1073
+ name : 'parrableId' ,
1074
+ storage : {
1075
+ type : 'cookie' ,
1076
+ name : '_parrable_eid'
1077
+ }
1078
+ } ]
1079
+ }
1080
+ } ;
1081
+
1082
+ setSubmoduleRegistry ( [ parrableIdSubmoduleMock ] ) ;
1083
+ attachIdSystem ( parrableIdSubmoduleMock ) ;
1084
+ init ( config ) ;
1085
+ config . setConfig ( parrableConfigMock ) ;
1086
+
1087
+ // make first bid request, should use stored id value
1088
+ requestBidsHook ( ( config ) => { innerAdUnits = config . adUnits } , { adUnits} ) ;
1089
+ innerAdUnits . forEach ( unit => {
1090
+ unit . bids . forEach ( bid => {
1091
+ expect ( bid ) . to . have . deep . nested . property ( 'userId.parrableid' ) ;
1092
+ expect ( bid . userId . parrableid ) . to . equal ( parrableStoredId ) ;
1093
+ } ) ;
1094
+ } ) ;
1095
+
1096
+ // attach a handler for auction end event to run the second bid request
1097
+ events . on ( CONSTANTS . EVENTS . AUCTION_END , function handler ( submodule ) {
1098
+ if ( submodule === 'parrableIdSubmoduleMock' ) {
1099
+ // make the second bid request, id should have been refreshed
1100
+ requestBidsHook ( ( config ) => { innerAdUnits = config . adUnits } , { adUnits} ) ;
1101
+ innerAdUnits . forEach ( unit => {
1102
+ unit . bids . forEach ( bid => {
1103
+ expect ( bid ) . to . have . deep . nested . property ( 'userId.parrableid' ) ;
1104
+ expect ( bid . userId . parrableid ) . to . equal ( parrableRefreshedId ) ;
1105
+ } ) ;
1106
+ } ) ;
1107
+ events . off ( CONSTANTS . EVENTS . AUCTION_END , handler ) ;
1108
+ done ( ) ;
1109
+ }
1110
+ } ) ;
1111
+
1112
+ // emit an auction end event to run the submodule callback
1113
+ events . emit ( CONSTANTS . EVENTS . AUCTION_END , 'parrableIdSubmoduleMock' ) ;
1114
+ } ) ;
1045
1115
} ) ;
1046
1116
} ) ;
0 commit comments