@@ -31,23 +31,23 @@ import { getTestProjectConfig } from '../../tests/test_data';
3131var  buildLogMessageFromArgs  =  args  =>  sprintf ( args [ 1 ] ,  ...args . splice ( 2 ) ) ; 
3232var  testData  =  getTestProjectConfig ( ) ; 
3333
34- describe ( 'lib/core/bucketer' ,  function ( )  { 
35-   describe ( 'APIs' ,  function ( )  { 
36-     describe ( 'bucket' ,  function ( )  { 
34+ describe ( 'lib/core/bucketer' ,  function   ( )  { 
35+   describe ( 'APIs' ,  function   ( )  { 
36+     describe ( 'bucket' ,  function   ( )  { 
3737      var  configObj ; 
3838      var  createdLogger  =  createLogger ( {  logLevel : LOG_LEVEL . INFO  } ) ; 
3939      var  bucketerParams ; 
4040
41-       beforeEach ( function ( )  { 
41+       beforeEach ( function   ( )  { 
4242        sinon . stub ( createdLogger ,  'log' ) ; 
4343      } ) ; 
4444
45-       afterEach ( function ( )  { 
45+       afterEach ( function   ( )  { 
4646        createdLogger . log . restore ( ) ; 
4747      } ) ; 
4848
49-       describe ( 'return values for bucketing (excluding groups)' ,  function ( )  { 
50-         beforeEach ( function ( )  { 
49+       describe ( 'return values for bucketing (excluding groups)' ,  function   ( )  { 
50+         beforeEach ( function   ( )  { 
5151          configObj  =  projectConfig . createProjectConfig ( cloneDeep ( testData ) ) ; 
5252          bucketerParams  =  { 
5353            experimentId : configObj . experiments [ 0 ] . id , 
@@ -66,11 +66,11 @@ describe('lib/core/bucketer', function() {
6666            . returns ( 50000 ) ; 
6767        } ) ; 
6868
69-         afterEach ( function ( )  { 
69+         afterEach ( function   ( )  { 
7070          bucketer . _generateBucketValue . restore ( ) ; 
7171        } ) ; 
7272
73-         it ( 'should return decision response with correct variation ID when provided bucket value' ,  function ( )  { 
73+         it ( 'should return decision response with correct variation ID when provided bucket value' ,  function   ( )  { 
7474          var  bucketerParamsTest1  =  cloneDeep ( bucketerParams ) ; 
7575          bucketerParamsTest1 . userId  =  'ppid1' ; 
7676          var  decisionResponse  =  bucketer . bucket ( bucketerParamsTest1 ) ; 
@@ -93,9 +93,9 @@ describe('lib/core/bucketer', function() {
9393        } ) ; 
9494      } ) ; 
9595
96-       describe ( 'return values for bucketing (including groups)' ,  function ( )  { 
96+       describe ( 'return values for bucketing (including groups)' ,  function   ( )  { 
9797        var  bucketerStub ; 
98-         beforeEach ( function ( )  { 
98+         beforeEach ( function   ( )  { 
9999          configObj  =  projectConfig . createProjectConfig ( cloneDeep ( testData ) ) ; 
100100          bucketerParams  =  { 
101101            experimentId : configObj . experiments [ 0 ] . id , 
@@ -109,13 +109,13 @@ describe('lib/core/bucketer', function() {
109109          bucketerStub  =  sinon . stub ( bucketer ,  '_generateBucketValue' ) ; 
110110        } ) ; 
111111
112-         afterEach ( function ( )  { 
112+         afterEach ( function   ( )  { 
113113          bucketer . _generateBucketValue . restore ( ) ; 
114114        } ) ; 
115115
116-         describe ( 'random groups' ,  function ( )  { 
116+         describe ( 'random groups' ,  function   ( )  { 
117117          bucketerParams  =  { } ; 
118-           beforeEach ( function ( )  { 
118+           beforeEach ( function   ( )  { 
119119            bucketerParams  =  { 
120120              experimentId : configObj . experiments [ 4 ] . id , 
121121              experimentKey : configObj . experiments [ 4 ] . key , 
@@ -128,7 +128,7 @@ describe('lib/core/bucketer', function() {
128128            } ; 
129129          } ) ; 
130130
131-           it ( 'should return decision response with the proper variation for a user in a grouped experiment' ,  function ( )  { 
131+           it ( 'should return decision response with the proper variation for a user in a grouped experiment' ,  function   ( )  { 
132132            bucketerStub . onFirstCall ( ) . returns ( 50 ) ; 
133133            bucketerStub . onSecondCall ( ) . returns ( 50 ) ; 
134134
@@ -160,7 +160,7 @@ describe('lib/core/bucketer', function() {
160160            ) ; 
161161          } ) ; 
162162
163-           it ( 'should return decision response with variation null when a user is bucketed into a different grouped experiment than the one speicfied' ,  function ( )  { 
163+           it ( 'should return decision response with variation null when a user is bucketed into a different grouped experiment than the one speicfied' ,  function   ( )  { 
164164            bucketerStub . returns ( 5000 ) ; 
165165
166166            var  decisionResponse  =  bucketer . bucket ( bucketerParams ) ; 
@@ -185,7 +185,7 @@ describe('lib/core/bucketer', function() {
185185            ) ; 
186186          } ) ; 
187187
188-           it ( 'should return decision response with variation null when a user is not bucketed into any experiments in the random group' ,  function ( )  { 
188+           it ( 'should return decision response with variation null when a user is not bucketed into any experiments in the random group' ,  function   ( )  { 
189189            bucketerStub . returns ( 50000 ) ; 
190190
191191            var  decisionResponse  =  bucketer . bucket ( bucketerParams ) ; 
@@ -202,7 +202,7 @@ describe('lib/core/bucketer', function() {
202202            expect ( log2 ) . to . equal ( sprintf ( LOG_MESSAGES . USER_NOT_IN_ANY_EXPERIMENT ,  'BUCKETER' ,  'testUser' ,  '666' ) ) ; 
203203          } ) ; 
204204
205-           it ( 'should return decision response with variation null when a user is bucketed into traffic space of deleted experiment within a random group' ,  function ( )  { 
205+           it ( 'should return decision response with variation null when a user is bucketed into traffic space of deleted experiment within a random group' ,  function   ( )  { 
206206            bucketerStub . returns ( 9000 ) ; 
207207
208208            var  decisionResponse  =  bucketer . bucket ( bucketerParams ) ; 
@@ -219,19 +219,19 @@ describe('lib/core/bucketer', function() {
219219            expect ( log2 ) . to . equal ( sprintf ( LOG_MESSAGES . USER_NOT_IN_ANY_EXPERIMENT ,  'BUCKETER' ,  'testUser' ,  '666' ) ) ; 
220220          } ) ; 
221221
222-           it ( 'should throw an error if group ID is not in the datafile' ,  function ( )  { 
222+           it ( 'should throw an error if group ID is not in the datafile' ,  function   ( )  { 
223223            var  bucketerParamsWithInvalidGroupId  =  cloneDeep ( bucketerParams ) ; 
224224            bucketerParamsWithInvalidGroupId . experimentIdMap [ configObj . experiments [ 4 ] . id ] . groupId  =  '6969' ; 
225225
226-             assert . throws ( function ( )  { 
226+             assert . throws ( function   ( )  { 
227227              bucketer . bucket ( bucketerParamsWithInvalidGroupId ) ; 
228228            } ,  sprintf ( ERROR_MESSAGES . INVALID_GROUP_ID ,  'BUCKETER' ,  '6969' ) ) ; 
229229          } ) ; 
230230        } ) ; 
231231
232-         describe ( 'overlapping groups' ,  function ( )  { 
232+         describe ( 'overlapping groups' ,  function   ( )  { 
233233          bucketerParams  =  { } ; 
234-           beforeEach ( function ( )  { 
234+           beforeEach ( function   ( )  { 
235235            bucketerParams  =  { 
236236              experimentId : configObj . experiments [ 6 ] . id , 
237237              experimentKey : configObj . experiments [ 6 ] . key , 
@@ -244,7 +244,7 @@ describe('lib/core/bucketer', function() {
244244            } ; 
245245          } ) ; 
246246
247-           it ( 'should return decision response with variation when a user falls into an experiment within an overlapping group' ,  function ( )  { 
247+           it ( 'should return decision response with variation when a user falls into an experiment within an overlapping group' ,  function   ( )  { 
248248            bucketerStub . returns ( 0 ) ; 
249249
250250            var  decisionResponse  =  bucketer . bucket ( bucketerParams ) ; 
@@ -257,7 +257,7 @@ describe('lib/core/bucketer', function() {
257257            expect ( log1 ) . to . equal ( sprintf ( LOG_MESSAGES . USER_ASSIGNED_TO_EXPERIMENT_BUCKET ,  'BUCKETER' ,  '0' ,  'testUser' ) ) ; 
258258          } ) ; 
259259
260-           it ( 'should return decision response with variation null when a user does not fall into an experiment within an overlapping group' ,  function ( )  { 
260+           it ( 'should return decision response with variation null when a user does not fall into an experiment within an overlapping group' ,  function   ( )  { 
261261            bucketerStub . returns ( 3000 ) ; 
262262
263263            var  decisionResponse  =  bucketer . bucket ( bucketerParams ) ; 
@@ -266,8 +266,8 @@ describe('lib/core/bucketer', function() {
266266        } ) ; 
267267      } ) ; 
268268
269-       describe ( 'when the bucket value falls into empty traffic allocation ranges' ,  function ( )  { 
270-         beforeEach ( function ( )  { 
269+       describe ( 'when the bucket value falls into empty traffic allocation ranges' ,  function   ( )  { 
270+         beforeEach ( function   ( )  { 
271271          configObj  =  projectConfig . createProjectConfig ( cloneDeep ( testData ) ) ; 
272272          bucketerParams  =  { 
273273            experimentId : configObj . experiments [ 0 ] . id , 
@@ -289,14 +289,14 @@ describe('lib/core/bucketer', function() {
289289          } ; 
290290        } ) ; 
291291
292-         it ( 'should return decision response with variation null' ,  function ( )  { 
292+         it ( 'should return decision response with variation null' ,  function   ( )  { 
293293          var  bucketerParamsTest1  =  cloneDeep ( bucketerParams ) ; 
294294          bucketerParamsTest1 . userId  =  'ppid1' ; 
295295          var  decisionResponse  =  bucketer . bucket ( bucketerParamsTest1 ) ; 
296296          expect ( decisionResponse . result ) . to . equal ( null ) ; 
297297        } ) ; 
298298
299-         it ( 'should not log an invalid variation ID warning' ,  function ( )  { 
299+         it ( 'should not log an invalid variation ID warning' ,  function   ( )  { 
300300          bucketer . bucket ( bucketerParams ) 
301301          const  foundInvalidVariationWarning  =  createdLogger . log . getCalls ( ) . some ( ( call )  =>  { 
302302            const  message  =  call . args [ 1 ] ; 
@@ -306,8 +306,8 @@ describe('lib/core/bucketer', function() {
306306        } ) ; 
307307      } ) ; 
308308
309-       describe ( 'when the traffic allocation has invalid variation ids' ,  function ( )  { 
310-         beforeEach ( function ( )  { 
309+       describe ( 'when the traffic allocation has invalid variation ids' ,  function   ( )  { 
310+         beforeEach ( function   ( )  { 
311311          configObj  =  projectConfig . createProjectConfig ( cloneDeep ( testData ) ) ; 
312312          bucketerParams  =  { 
313313            experimentId : configObj . experiments [ 0 ] . id , 
@@ -329,7 +329,7 @@ describe('lib/core/bucketer', function() {
329329          } ; 
330330        } ) ; 
331331
332-         it ( 'should return decision response with variation null' ,  function ( )  { 
332+         it ( 'should return decision response with variation null' ,  function   ( )  { 
333333          var  bucketerParamsTest1  =  cloneDeep ( bucketerParams ) ; 
334334          bucketerParamsTest1 . userId  =  'ppid1' ; 
335335          var  decisionResponse  =  bucketer . bucket ( bucketerParamsTest1 ) ; 
@@ -338,8 +338,8 @@ describe('lib/core/bucketer', function() {
338338      } ) ; 
339339    } ) ; 
340340
341-     describe ( '_generateBucketValue' ,  function ( )  { 
342-       it ( 'should return a bucket value for different inputs' ,  function ( )  { 
341+     describe ( '_generateBucketValue' ,  function   ( )  { 
342+       it ( 'should return a bucket value for different inputs' ,  function   ( )  { 
343343        var  experimentId  =  1886780721 ; 
344344        var  bucketingKey1  =  sprintf ( '%s%s' ,  'ppid1' ,  experimentId ) ; 
345345        var  bucketingKey2  =  sprintf ( '%s%s' ,  'ppid2' ,  experimentId ) ; 
@@ -352,21 +352,21 @@ describe('lib/core/bucketer', function() {
352352        expect ( bucketer . _generateBucketValue ( bucketingKey4 ) ) . to . equal ( 5439 ) ; 
353353      } ) ; 
354354
355-       it ( 'should return an error if it cannot generate the hash value' ,  function ( )  { 
356-         assert . throws ( function ( )  { 
355+       it ( 'should return an error if it cannot generate the hash value' ,  function   ( )  { 
356+         assert . throws ( function   ( )  { 
357357          bucketer . _generateBucketValue ( null ) ; 
358358        } ,  sprintf ( ERROR_MESSAGES . INVALID_BUCKETING_ID ,  'BUCKETER' ,  null ,  "Cannot read property 'length' of null" ) ) ; 
359359      } ) ; 
360360    } ) ; 
361361
362-     describe ( 'testBucketWithBucketingId' ,  function ( )  { 
362+     describe ( 'testBucketWithBucketingId' ,  function   ( )  { 
363363      var  bucketerParams ; 
364364      var  createdLogger  =  createLogger ( { 
365365        logLevel : LOG_LEVEL . INFO , 
366366        logToConsole : false , 
367367      } ) ; 
368368
369-       beforeEach ( function ( )  { 
369+       beforeEach ( function   ( )  { 
370370        var  configObj  =  projectConfig . createProjectConfig ( cloneDeep ( testData ) ) ; 
371371        bucketerParams  =  { 
372372          trafficAllocationConfig : configObj . experiments [ 0 ] . trafficAllocation , 
@@ -377,7 +377,7 @@ describe('lib/core/bucketer', function() {
377377        } ; 
378378      } ) ; 
379379
380-       it ( 'check that a non null bucketingId buckets a variation different than the one expected with userId' ,  function ( )  { 
380+       it ( 'check that a non null bucketingId buckets a variation different than the one expected with userId' ,  function   ( )  { 
381381        var  bucketerParams1  =  cloneDeep ( bucketerParams ) ; 
382382        bucketerParams1 [ 'userId' ]  =  'testBucketingIdControl' ; 
383383        bucketerParams1 [ 'bucketingId' ]  =  '123456789' ; 
@@ -386,7 +386,7 @@ describe('lib/core/bucketer', function() {
386386        expect ( bucketer . bucket ( bucketerParams1 ) . result ) . to . equal ( '111129' ) ; 
387387      } ) ; 
388388
389-       it ( 'check that a null bucketing ID defaults to bucketing with the userId' ,  function ( )  { 
389+       it ( 'check that a null bucketing ID defaults to bucketing with the userId' ,  function   ( )  { 
390390        var  bucketerParams2  =  cloneDeep ( bucketerParams ) ; 
391391        bucketerParams2 [ 'userId' ]  =  'testBucketingIdControl' ; 
392392        bucketerParams2 [ 'bucketingId' ]  =  null ; 
@@ -395,7 +395,7 @@ describe('lib/core/bucketer', function() {
395395        expect ( bucketer . bucket ( bucketerParams2 ) . result ) . to . equal ( '111128' ) ; 
396396      } ) ; 
397397
398-       it ( 'check that bucketing works with an experiment in group' ,  function ( )  { 
398+       it ( 'check that bucketing works with an experiment in group' ,  function   ( )  { 
399399        var  bucketerParams4  =  cloneDeep ( bucketerParams ) ; 
400400        bucketerParams4 [ 'userId' ]  =  'testBucketingIdControl' ; 
401401        bucketerParams4 [ 'bucketingId' ]  =  '123456789' ; 
0 commit comments