@@ -117,4 +117,123 @@ describe('Breinify', function () {
117117 done ( ) ;
118118 } ) ;
119119 } ) ;
120+
121+
122+ //noinspection JSUnresolvedFunction
123+ it ( 'handlesGetParameters' , function ( ) {
124+ var oldParams = Breinify . UTL . loc . params ;
125+ var oldActivity = Breinify . activity ;
126+
127+ var test = [ ] ;
128+ var value = { } ;
129+
130+ Breinify . activity = function ( user , type , category , description , tags , sign , onReady ) {
131+
132+ // create a unique new identifier for the test
133+ test . push ( true ) ;
134+
135+ // add the information
136+ value [ test . length ] = {
137+ user : user ,
138+ type : type ,
139+ category : category ,
140+ description : description ,
141+ tags : tags ,
142+ sign : sign
143+ } ;
144+ } ;
145+
146+ // use some old configuration without any marker
147+ Breinify . UTL . loc . params = function ( done ) {
148+ return {
149+ 'brec' : 'eyJ1c2VyIjogeyJlbWFpbCI6ICJwaGlsaXBwQG1laXNlbi5uZXQiLCJ1c2VySWQiOiAiNDAyODAxOTMxNTQifSwiYWN0aXZpdHkiOiB7InRhZ3MiOiB7InByb2R1Y3RQcmljZXMiOiBbMzkuOTldLCJwcm9kdWN0SWRzIjogWyIyMTg2Il0sIndpZGdldElkIjogIm1heUxpa2UyIiwid2lkZ2V0VHlwZSI6ICJpbWFnZSIsImNhbXBhaWduSWQiOiAiYmV2bW9GcmlkYXlFbWFpbHwyMDE5LTA0LTEyIiwiY2FtcGFpZ25UeXBlIjogImJldm1vRnJpZGF5RW1haWwifX19'
150+ } ;
151+ } ;
152+ Breinify . setConfig ( {
153+ 'apiKey' : '5555-064C-F007-4F92-A8DC-D06B-56B4-FAD8' ,
154+ 'category' : 'other' ,
155+ 'handleParameters' : true
156+ } ) ;
157+
158+ // another old configuration without marker
159+ Breinify . UTL . loc . params = function ( done ) {
160+ return {
161+ 'brec' : 'eyJ1c2VyIjogeyJlbWFpbCI6ICJwaGlsaXBwQG1laXNlbi5uZXQiLCJ1c2VySWQiOiAiNDAyODAxOTMxNTQifSwiYWN0aXZpdHkiOiB7InRhZ3MiOiB7InByb2R1Y3RQcmljZXMiOiBbMjYuOTldLCJwcm9kdWN0SWRzIjogWyI1MTIwNCJdLCJ3aWRnZXRJZCI6ICJtYXlMaWtlNCIsIndpZGdldFR5cGUiOiAiaW1hZ2UiLCJjYW1wYWlnbklkIjogImJldm1vRnJpZGF5RW1haWx8MjAxOS0wNC0xMiIsImNhbXBhaWduVHlwZSI6ICJiZXZtb0ZyaWRheUVtYWlsIn19fQ%3D%3D'
162+ } ;
163+ } ;
164+ Breinify . setConfig ( {
165+ 'apiKey' : '5555-064C-F007-4F92-A8DC-D06B-56B4-FAD8' ,
166+ 'category' : 'other' ,
167+ 'handleParameters' : true
168+ } ) ;
169+
170+ // use some new configuration with the marker
171+ Breinify . UTL . loc . params = function ( done ) {
172+ return {
173+ 'brec' : '.eyJhY3Rpdml0eSI6eyJ0eXBlIjoiY2xpY2tlZFJlY29tbWVuZGF0aW9uIiwidGFncyI6eyJwcm9kdWN0SWRzIjpbIjU0MTIzIl19fSwidXNlciI6eyJlbWFpbCI6InBoaWxpcHBAYnJlaW5pZnkuY29tIn19'
174+ } ;
175+ } ;
176+ Breinify . setConfig ( {
177+ 'apiKey' : '5555-064C-F007-4F92-A8DC-D06B-56B4-FAD8' ,
178+ 'category' : 'other' ,
179+ 'handleParameters' : true
180+ } ) ;
181+
182+ // reset everything
183+ Breinify . UTL . loc . params = oldParams ;
184+ Breinify . activity = oldActivity ;
185+
186+ //noinspection JSUnresolvedFunction
187+ expect ( value ) . toEqual ( {
188+ "1" : {
189+ "user" : {
190+ "email" : "philipp@meisen.net" ,
191+ "userId" : "40280193154"
192+ } ,
193+ "type" : "clickedRecommendation" ,
194+ "category" : null ,
195+ "description" : null ,
196+ "tags" : {
197+ "productPrices" : [ 39.99 ] ,
198+ "productIds" : [ "2186" ] ,
199+ "widgetId" : "mayLike2" ,
200+ "widgetType" : "image" ,
201+ "campaignId" : "bevmoFridayEmail|2019-04-12" ,
202+ "campaignType" : "bevmoFridayEmail"
203+ } ,
204+ "sign" : null
205+ } ,
206+ "2" : {
207+ "user" : {
208+ "email" : "philipp@meisen.net" ,
209+ "userId" : "40280193154"
210+ } ,
211+ "type" : "clickedRecommendation" ,
212+ "category" : null ,
213+ "description" : null ,
214+ "tags" : {
215+ "productPrices" : [ 26.99 ] ,
216+ "productIds" : [ "51204" ] ,
217+ "widgetId" : "mayLike4" ,
218+ "widgetType" : "image" ,
219+ "campaignId" : "bevmoFridayEmail|2019-04-12" ,
220+ "campaignType" : "bevmoFridayEmail"
221+ } ,
222+ "sign" : null
223+ } ,
224+ "3" : {
225+ "user" : {
226+ "email" : "philipp@breinify.com"
227+ } ,
228+ "type" : "clickedRecommendation" ,
229+ "category" : null ,
230+ "description" : null ,
231+ "tags" : {
232+ "productIds" : [ "54123" ]
233+ } ,
234+ "sign" : null
235+ }
236+ } ) ;
237+ } ) ;
238+
120239} ) ;
0 commit comments