@@ -1174,7 +1174,7 @@ test('Should setContextField with userId', async () => {
1174
1174
appName : 'web' ,
1175
1175
} ;
1176
1176
const client = new UnleashClient ( config ) ;
1177
- client . setContextField ( 'userId' , userId ) ;
1177
+ await client . setContextField ( 'userId' , userId ) ;
1178
1178
const context = client . getContext ( ) ;
1179
1179
expect ( context . userId ) . toBe ( userId ) ;
1180
1180
} ) ;
@@ -1188,17 +1188,28 @@ test('Should removeContextField', async () => {
1188
1188
appName : 'web' ,
1189
1189
} ;
1190
1190
const client = new UnleashClient ( config ) ;
1191
- client . setContextField ( 'userId' , userId ) ;
1191
+ await client . setContextField ( 'userId' , userId ) ;
1192
1192
client . setContextField ( 'customField' , customValue ) ;
1193
+ const context1 = client . getContext ( ) ;
1194
+ expect ( context1 ) . toEqual ( {
1195
+ appName : 'web' ,
1196
+ environment : 'default' ,
1197
+ properties : {
1198
+ customField : customValue ,
1199
+ } ,
1200
+ sessionId : expect . any ( String ) ,
1201
+ userId : userId ,
1202
+ } ) ;
1193
1203
1194
- client . removeContextField ( 'userId' ) ;
1195
- client . removeContextField ( 'customField' ) ;
1196
- const context = client . getContext ( ) ;
1204
+ await client . removeContextField ( 'userId' ) ;
1205
+ await client . removeContextField ( 'customField' ) ;
1206
+ const context2 = client . getContext ( ) ;
1197
1207
1198
- expect ( context ) . toEqual ( {
1208
+ expect ( context2 ) . toEqual ( {
1199
1209
appName : 'web' ,
1200
1210
environment : 'default' ,
1201
1211
properties : { } ,
1212
+ sessionId : expect . any ( String ) ,
1202
1213
} ) ;
1203
1214
} ) ;
1204
1215
@@ -1210,7 +1221,7 @@ test('Should setContextField with sessionId', async () => {
1210
1221
appName : 'web' ,
1211
1222
} ;
1212
1223
const client = new UnleashClient ( config ) ;
1213
- client . setContextField ( 'sessionId' , sessionId ) ;
1224
+ await client . setContextField ( 'sessionId' , sessionId ) ;
1214
1225
const context = client . getContext ( ) ;
1215
1226
expect ( context . sessionId ) . toBe ( sessionId ) ;
1216
1227
} ) ;
0 commit comments