@@ -757,7 +757,7 @@ describe('ConditionEvaluator', () => {
757757 // evaluate percent conditions. It creates a set of 10 conditions targeting 50%
758758 // with randomizationIds 0-9 and a constant `seed` value.
759759 const conditionEvaluator = new ConditionEvaluator ( ) ;
760-
760+
761761 const percentCondition = {
762762 percentOperator : PercentConditionOperator . BETWEEN ,
763763 microPercentRange : {
@@ -767,23 +767,26 @@ describe('ConditionEvaluator', () => {
767767 } ;
768768
769769 const testCases = [
770- { seed : '' , randomizationId : 'zero' , result : true } ,
771770 { seed : '1' , randomizationId : 'one' , result : false } ,
772771 { seed : '2' , randomizationId : 'two' , result : false } ,
773772 { seed : '3' , randomizationId : 'three' , result : true } ,
774773 { seed : '4' , randomizationId : 'four' , result : false } ,
775774 { seed : '5' , randomizationId : 'five' , result : true } ,
776- { seed : '6' , randomizationId : 'six' , result : true } ,
777- { seed : '7' , randomizationId : 'seven' , result : true } ,
778- { seed : '8' , randomizationId : 'eight' , result : true } ,
779- { seed : '9' , randomizationId : 'nine' , result : false } ,
780775 { seed : '' , randomizationId : '😊' , result : true } ,
781776 { seed : '' , randomizationId : '😀' , result : false } ,
782- { seed : 'hêl£o' , randomizationId : 'wørlÐ' , result : false }
777+ { seed : 'hêl£o' , randomizationId : 'wørlÐ' , result : false } ,
778+ { seed : 'řemøťe' , randomizationId : 'çōnfįġ' , result : true } ,
779+ { seed : 'long' , randomizationId : Array . from ( { length : 100 } ) . map ( ( ) => '.' ) . join ( '' ) , result : true } ,
780+ { seed : 'very-long' , randomizationId : Array . from ( { length : 1000 } ) . map ( ( ) => '.' ) . join ( '' ) , result : false } ,
783781 ]
784782
785783 testCases . map ( ( { randomizationId, seed, result } ) => {
786- it ( `should evaluate "${ randomizationId } " with seed "${ seed } " to ${ result } ` , ( ) => {
784+
785+ const idSummary = randomizationId . length > 25
786+ ? `a ${ randomizationId . length } character randomizationID`
787+ : `"${ randomizationId } "` ;
788+
789+ it ( `should evaluate ${ idSummary } with seed "${ seed } " to ${ result } ` , ( ) => {
787790 const context = { randomizationId } ;
788791 const evalResult = conditionEvaluator . evaluateConditions ( [ {
789792 name : 'is_enabled' ,
@@ -993,15 +996,15 @@ describe('ConditionEvaluator', () => {
993996 describe ( 'STRING_CONTAINS' , ( ) => {
994997 const testCases : CustomSignalTestCase [ ] = [
995998 { targets : [ 'foo' , 'biz' ] , actual : 'foobar' , outcome : true } ,
996- { targets : [ 'foo' , 'biz' ] , actual : 'bar' , outcome : false } ,
999+ { targets : [ 'foo' , 'biz' ] , actual : 'bar' , outcome : false } ,
9971000 ] ;
9981001
9991002 testCases . forEach ( runCustomSignalTestCase ( CustomSignalOperator . STRING_CONTAINS ) ) ;
10001003 } ) ;
10011004
10021005 describe ( 'STRING_DOES_NOT_CONTAIN' , ( ) => {
10031006 const testCases : CustomSignalTestCase [ ] = [
1004- { targets : [ 'foo' , 'biz' ] , actual : 'bar' , outcome : true } ,
1007+ { targets : [ 'foo' , 'biz' ] , actual : 'bar' , outcome : true } ,
10051008 { targets : [ 'foo' , 'biz' ] , actual : 'foobar' , outcome : false } ,
10061009 ] ;
10071010
@@ -1170,72 +1173,4 @@ describe('ConditionEvaluator', () => {
11701173 } ) ;
11711174 } ) ;
11721175 } ) ;
1173-
1174- // describe('hashSeededRandomizationId', () => {
1175- // // We convert to a signed integer for legacy compatibility.
1176- // // This has caused confusion in the past, so we explicitly
1177- // // test here.
1178- // it('should leave numbers <= 2^63-1 (max signed long) as is', function () {
1179- // if (nodeVersion.startsWith('14')) {
1180- // this.skip();
1181- // }
1182-
1183- // const stub = sinon.stub(crypto.Hash.prototype, 'digest');
1184- // // 2^63-1 = 9223372036854775807
1185- // stub.withArgs('hex').returns(BigInt('9223372036854775807').toString(16));
1186- // stubs.push(stub);
1187-
1188- // const actual = ConditionEvaluator.hashSeededRandomizationId('anything');
1189-
1190- // expect(actual).to.equal(BigInt('9223372036854775807'))
1191- // });
1192-
1193- // it('should convert 2^63 to negative (min signed long) and then find the absolute value', function () {
1194- // if (nodeVersion.startsWith('14')) {
1195- // this.skip();
1196- // }
1197-
1198- // const stub = sinon.stub(crypto.Hash.prototype, 'digest');
1199- // // 2^63 = 9223372036854775808
1200- // stub.withArgs('hex').returns(BigInt('9223372036854775808').toString(16));
1201- // stubs.push(stub);
1202-
1203- // const actual = ConditionEvaluator.hashSeededRandomizationId('anything');
1204-
1205- // // 2^63 is the negation of 2^63-1
1206- // expect(actual).to.equal(BigInt('9223372036854775808'))
1207- // });
1208-
1209- // it('should convert 2^63+1 to negative and then find the absolute value', function () {
1210- // if (nodeVersion.startsWith('14')) {
1211- // this.skip();
1212- // }
1213-
1214- // const stub = sinon.stub(crypto.Hash.prototype, 'digest');
1215- // // 2^63+1 = 9223372036854775809
1216- // stub.withArgs('hex').returns(BigInt('9223372036854775809').toString(16));
1217- // stubs.push(stub);
1218-
1219- // const actual = ConditionEvaluator.hashSeededRandomizationId('anything');
1220-
1221- // // 2^63+1 is larger than 2^63, so the absolute value is smaller
1222- // expect(actual).to.equal(BigInt('9223372036854775809'))
1223- // });
1224-
1225- // it('should handle the value that initially caused confusion', function () {
1226- // if (nodeVersion.startsWith('14')) {
1227- // this.skip();
1228- // }
1229-
1230- // const stub = sinon.stub(crypto.Hash.prototype, 'digest');
1231- // // We were initially confused about the nature of this value ...
1232- // stub.withArgs('hex').returns(BigInt('16081085603393958147').toString(16));
1233- // stubs.push(stub);
1234-
1235- // const actual = ConditionEvaluator.hashSeededRandomizationId('anything');
1236-
1237- // // ... Now we know it's the unsigned equivalent of this absolute value.
1238- // expect(actual).to.equal(BigInt('2365658470315593469'))
1239- // });
1240- // });
12411176} ) ;
0 commit comments