@@ -833,9 +833,7 @@ describe('javascript-sdk (Browser)', function() {
833
833
} ) ;
834
834
projectConfigManager . pushUpdate ( config ) ;
835
835
836
- const readyData = await client . onReady ( ) ;
837
- assert . equal ( readyData . success , true ) ;
838
- assert . isUndefined ( readyData . reason ) ;
836
+ await client . onReady ( ) ;
839
837
840
838
sinon . assert . called ( fakeEventManager . start ) ;
841
839
} ) ;
@@ -869,9 +867,7 @@ describe('javascript-sdk (Browser)', function() {
869
867
} ) ;
870
868
871
869
projectConfigManager . pushUpdate ( config ) ;
872
- const readyData = await client . onReady ( ) ;
873
- assert . equal ( readyData . success , true ) ;
874
- assert . isUndefined ( readyData . reason ) ;
870
+ await client . onReady ( ) ;
875
871
876
872
client . sendOdpEvent ( ODP_EVENT_ACTION . INITIALIZED ) ;
877
873
@@ -916,10 +912,7 @@ describe('javascript-sdk (Browser)', function() {
916
912
} ,
917
913
} ) ;
918
914
projectConfigManager . pushUpdate ( config ) ;
919
- const readyData = await client . onReady ( ) ;
920
-
921
- assert . equal ( readyData . success , true ) ;
922
- assert . isUndefined ( readyData . reason ) ;
915
+ await client . onReady ( ) ;
923
916
924
917
client . sendOdpEvent ( 'test' , '' , new Map ( [ [ 'eamil' , '[email protected] ' ] ] ) , new Map ( [ [ 'key' , 'value' ] ] ) ) ;
925
918
clock . tick ( 10000 ) ;
@@ -961,9 +954,7 @@ describe('javascript-sdk (Browser)', function() {
961
954
} ) ;
962
955
963
956
projectConfigManager . pushUpdate ( config ) ;
964
- const readyData = await client . onReady ( ) ;
965
- assert . equal ( readyData . success , true ) ;
966
- assert . isUndefined ( readyData . reason ) ;
957
+ await client . onReady ( ) ;
967
958
968
959
// fs-user-id
969
960
client . sendOdpEvent ( ODP_EVENT_ACTION . INITIALIZED , undefined , new Map ( [ [ 'fs-user-id' , 'fsUserA' ] ] ) ) ;
@@ -1021,8 +1012,15 @@ describe('javascript-sdk (Browser)', function() {
1021
1012
flush : sinon . spy ( ) ,
1022
1013
} ;
1023
1014
1015
+ const config = createProjectConfig ( testData . getOdpIntegratedConfigWithoutSegments ( ) ) ;
1016
+ const projectConfigManager = getMockProjectConfigManager ( {
1017
+ initConfig : config ,
1018
+ onRunning : Promise . resolve ( ) ,
1019
+ } ) ;
1020
+
1021
+
1024
1022
const client = optimizelyFactory . createInstance ( {
1025
- datafile : testData . getOdpIntegratedConfigWithSegments ( ) ,
1023
+ projectConfigManager ,
1026
1024
errorHandler : fakeErrorHandler ,
1027
1025
eventDispatcher : fakeEventDispatcher ,
1028
1026
eventBatchSize : null ,
@@ -1032,9 +1030,8 @@ describe('javascript-sdk (Browser)', function() {
1032
1030
} ,
1033
1031
} ) ;
1034
1032
1035
- const readyData = await client . onReady ( ) ;
1036
- assert . equal ( readyData . success , true ) ;
1037
- assert . isUndefined ( readyData . reason ) ;
1033
+ projectConfigManager . pushUpdate ( config ) ;
1034
+ await client . onReady ( ) ;
1038
1035
1039
1036
client . sendOdpEvent ( '' ) ;
1040
1037
sinon . assert . called ( logger . error ) ;
@@ -1059,8 +1056,14 @@ describe('javascript-sdk (Browser)', function() {
1059
1056
flush : sinon . spy ( ) ,
1060
1057
} ;
1061
1058
1059
+ const config = createProjectConfig ( testData . getOdpIntegratedConfigWithoutSegments ( ) ) ;
1060
+ const projectConfigManager = getMockProjectConfigManager ( {
1061
+ initConfig : config ,
1062
+ onRunning : Promise . resolve ( ) ,
1063
+ } ) ;
1064
+
1062
1065
const client = optimizelyFactory . createInstance ( {
1063
- datafile : testData . getOdpIntegratedConfigWithSegments ( ) ,
1066
+ projectConfigManager ,
1064
1067
errorHandler : fakeErrorHandler ,
1065
1068
eventDispatcher : fakeEventDispatcher ,
1066
1069
eventBatchSize : null ,
@@ -1069,10 +1072,8 @@ describe('javascript-sdk (Browser)', function() {
1069
1072
eventManager : fakeEventManager ,
1070
1073
} ,
1071
1074
} ) ;
1072
-
1073
- const readyData = await client . onReady ( ) ;
1074
- assert . equal ( readyData . success , true ) ;
1075
- assert . isUndefined ( readyData . reason ) ;
1075
+ projectConfigManager . pushUpdate ( config ) ;
1076
+ await client . onReady ( ) ;
1076
1077
1077
1078
client . sendOdpEvent ( 'dummy-action' , '' ) ;
1078
1079
@@ -1083,8 +1084,14 @@ describe('javascript-sdk (Browser)', function() {
1083
1084
} ) ;
1084
1085
1085
1086
it ( 'should log an error when attempting to send an odp event when odp is disabled' , async ( ) => {
1087
+ const config = createProjectConfig ( testData . getTestProjectConfigWithFeatures ( ) ) ;
1088
+ const projectConfigManager = getMockProjectConfigManager ( {
1089
+ initConfig : config ,
1090
+ onRunning : Promise . resolve ( ) ,
1091
+ } ) ;
1092
+
1086
1093
const client = optimizelyFactory . createInstance ( {
1087
- datafile : testData . getTestProjectConfigWithFeatures ( ) ,
1094
+ projectConfigManager ,
1088
1095
errorHandler : fakeErrorHandler ,
1089
1096
eventDispatcher : fakeEventDispatcher ,
1090
1097
eventBatchSize : null ,
@@ -1094,9 +1101,10 @@ describe('javascript-sdk (Browser)', function() {
1094
1101
} ,
1095
1102
} ) ;
1096
1103
1097
- const readyData = await client . onReady ( ) ;
1098
- assert . equal ( readyData . success , true ) ;
1099
- assert . isUndefined ( readyData . reason ) ;
1104
+ projectConfigManager . pushUpdate ( config ) ;
1105
+
1106
+ await client . onReady ( ) ;
1107
+
1100
1108
assert . isUndefined ( client . odpManager ) ;
1101
1109
sinon . assert . calledWith ( logger . log , optimizelyFactory . enums . LOG_LEVEL . INFO , 'ODP Disabled.' ) ;
1102
1110
@@ -1109,8 +1117,14 @@ describe('javascript-sdk (Browser)', function() {
1109
1117
} ) ;
1110
1118
1111
1119
it ( 'should log a warning when attempting to use an event batch size other than 1' , async ( ) => {
1120
+ const config = createProjectConfig ( testData . getTestProjectConfigWithFeatures ( ) ) ;
1121
+ const projectConfigManager = getMockProjectConfigManager ( {
1122
+ initConfig : config ,
1123
+ onRunning : Promise . resolve ( ) ,
1124
+ } ) ;
1125
+
1112
1126
const client = optimizelyFactory . createInstance ( {
1113
- datafile : testData . getOdpIntegratedConfigWithSegments ( ) ,
1127
+ projectConfigManager ,
1114
1128
errorHandler : fakeErrorHandler ,
1115
1129
eventDispatcher : fakeEventDispatcher ,
1116
1130
eventBatchSize : null ,
@@ -1120,9 +1134,9 @@ describe('javascript-sdk (Browser)', function() {
1120
1134
} ,
1121
1135
} ) ;
1122
1136
1123
- const readyData = await client . onReady ( ) ;
1124
- assert . equal ( readyData . success , true ) ;
1125
- assert . isUndefined ( readyData . reason ) ;
1137
+ projectConfigManager . pushUpdate ( config ) ;
1138
+
1139
+ await client . onReady ( ) ;
1126
1140
1127
1141
client . sendOdpEvent ( ODP_EVENT_ACTION . INITIALIZED ) ;
1128
1142
@@ -1147,9 +1161,14 @@ describe('javascript-sdk (Browser)', function() {
1147
1161
} ) ;
1148
1162
1149
1163
let datafile = testData . getOdpIntegratedConfigWithSegments ( ) ;
1164
+ const config = createProjectConfig ( datafile ) ;
1165
+ const projectConfigManager = getMockProjectConfigManager ( {
1166
+ initConfig : config ,
1167
+ onRunning : Promise . resolve ( ) ,
1168
+ } ) ;
1150
1169
1151
1170
const client = optimizelyFactory . createInstance ( {
1152
- datafile ,
1171
+ projectConfigManager ,
1153
1172
errorHandler : fakeErrorHandler ,
1154
1173
eventDispatcher : fakeEventDispatcher ,
1155
1174
eventBatchSize : null ,
@@ -1160,9 +1179,8 @@ describe('javascript-sdk (Browser)', function() {
1160
1179
} ,
1161
1180
} ) ;
1162
1181
1163
- const readyData = await client . onReady ( ) ;
1164
- assert . equal ( readyData . success , true ) ;
1165
- assert . isUndefined ( readyData . reason ) ;
1182
+ projectConfigManager . pushUpdate ( config ) ;
1183
+ await client . onReady ( ) ;
1166
1184
1167
1185
client . sendOdpEvent ( ODP_EVENT_ACTION . INITIALIZED ) ;
1168
1186
@@ -1201,8 +1219,14 @@ describe('javascript-sdk (Browser)', function() {
1201
1219
logger,
1202
1220
} ) ;
1203
1221
const datafile = testData . getOdpIntegratedConfigWithSegments ( ) ;
1222
+ const config = createProjectConfig ( datafile ) ;
1223
+ const projectConfigManager = getMockProjectConfigManager ( {
1224
+ initConfig : config ,
1225
+ onRunning : Promise . resolve ( ) ,
1226
+ } ) ;
1227
+
1204
1228
const client = optimizelyFactory . createInstance ( {
1205
- datafile ,
1229
+ projectConfigManager ,
1206
1230
errorHandler : fakeErrorHandler ,
1207
1231
eventDispatcher : fakeEventDispatcher ,
1208
1232
eventBatchSize : null ,
@@ -1213,9 +1237,8 @@ describe('javascript-sdk (Browser)', function() {
1213
1237
} ,
1214
1238
} ) ;
1215
1239
1216
- const readyData = await client . onReady ( ) ;
1217
- assert . equal ( readyData . success , true ) ;
1218
- assert . isUndefined ( readyData . reason ) ;
1240
+ projectConfigManager . pushUpdate ( config ) ;
1241
+ await client . onReady ( ) ;
1219
1242
1220
1243
clock . tick ( 100 ) ;
1221
1244
0 commit comments